Update MarkerExtension.php
Add conditional logic to MarkerExtension - display coordinates or MapBox
This commit is contained in:
parent
a40520d3c6
commit
5bae62a619
|
@ -4,6 +4,7 @@
|
||||||
namespace A2nt\SilverStripeMapboxField;
|
namespace A2nt\SilverStripeMapboxField;
|
||||||
|
|
||||||
use SilverStripe\Forms\CheckboxField;
|
use SilverStripe\Forms\CheckboxField;
|
||||||
|
use SilverStripe\Forms\TextField;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use Symbiote\Addressable\Geocodable;
|
use Symbiote\Addressable\Geocodable;
|
||||||
use Symbiote\Addressable\Addressable;
|
use Symbiote\Addressable\Addressable;
|
||||||
|
@ -36,19 +37,20 @@ class MarkerExtension extends Geocodable
|
||||||
$fields->addFieldsToTab('Root.Map', [
|
$fields->addFieldsToTab('Root.Map', [
|
||||||
CheckboxField::create('LatLngOverride', 'Override Latitude and Longitude?')
|
CheckboxField::create('LatLngOverride', 'Override Latitude and Longitude?')
|
||||||
->setDescription('Check this box and save to be able to set the latitude and longitude manually.'),
|
->setDescription('Check this box and save to be able to set the latitude and longitude manually.'),
|
||||||
]);
|
|
||||||
#Show map, or coordinates if override is ticked.
|
|
||||||
if ($record->LatLngOverride) {
|
|
||||||
$fields->addFieldsToTab('Root.Map', [
|
|
||||||
TextField::create('Lat', 'Latitude'),
|
|
||||||
TextField::create('Lng', 'Longitude'),
|
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
else {
|
#Show map, or coordinates if override is ticked.
|
||||||
$fields->addFieldsToTab('Root.Map', [
|
if ($record->LatLngOverride) {
|
||||||
MapboxField::create('Map', 'Choose a location', 'Lat', 'Lng'),
|
$fields->addFieldsToTab('Root.Map', [
|
||||||
]);
|
TextField::create('Lat', 'Latitude'),
|
||||||
}
|
TextField::create('Lng', 'Longitude'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$fields->addFieldsToTab('Root.Map', [
|
||||||
|
MapboxField::create('Map', 'Choose a location', 'Lat', 'Lng'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDirectionsURL()
|
public function getDirectionsURL()
|
||||||
|
|
Loading…
Reference in New Issue