Compare commits
5 Commits
4f3d39f7ad
...
18e242c17a
Author | SHA1 | Date |
---|---|---|
Tony Air | 18e242c17a | |
Tony Air | b91f53db10 | |
Tony Air | da367a4428 | |
Tony Air | 75dde6ce2c | |
Tony Air | 3442745c4e |
|
@ -10,6 +10,7 @@ SilverStripe\Core\Injector\Injector:
|
|||
class: Symbiote\Addressable\MapboxGeocodeService
|
||||
|
||||
SilverStripe\SiteConfig\SiteConfig:
|
||||
map_type: "google-maps"
|
||||
extensions:
|
||||
- A2nt\SilverStripeMapboxField\SiteConfigExtension
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
namespace A2nt\SilverStripeMapboxField;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
|
||||
class SiteConfigExtension extends Extension
|
||||
{
|
||||
|
@ -11,6 +12,26 @@ class SiteConfigExtension extends Extension
|
|||
{
|
||||
return MapboxField::getAccessToken();
|
||||
}
|
||||
|
||||
public function MapAPIKeyFrontend(): string
|
||||
{
|
||||
$type = $this->owner->config()->get('map_type');
|
||||
|
||||
switch ($type) {
|
||||
case 'mapbox':
|
||||
$key = MapboxField::getAccessToken();
|
||||
break;
|
||||
case 'google-maps':
|
||||
$cfg = Config::inst()->get(GoogleMapField::class, 'default_options');
|
||||
$key = isset($cfg['api_key']) ? $cfg['api_key'] : '';
|
||||
break;
|
||||
default:
|
||||
$key = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function MapStyle()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue