Merge pull request #3 from towercreative/towercreative-override-coordinates

Update MarkerExtension.php
This commit is contained in:
Nathan Bullivant 2023-09-02 18:02:05 +08:00 committed by GitHub
commit 08defb3f15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 12 deletions

View File

@ -4,6 +4,7 @@
namespace A2nt\SilverStripeMapboxField;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\FieldList;
use Symbiote\Addressable\Geocodable;
use Symbiote\Addressable\Addressable;
@ -36,19 +37,20 @@ class MarkerExtension extends Geocodable
$fields->addFieldsToTab('Root.Map', [
CheckboxField::create('LatLngOverride', 'Override Latitude and Longitude?')
->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 {
$fields->addFieldsToTab('Root.Map', [
MapboxField::create('Map', 'Choose a location', 'Lat', 'Lng'),
]);
}
#Show map, or coordinates if override is ticked.
if ($record->LatLngOverride) {
$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()