diff --git a/src/Extensions/SiteConfigExtension.php b/src/Extensions/SiteConfigExtension.php index 83e4a64..762dd6c 100755 --- a/src/Extensions/SiteConfigExtension.php +++ b/src/Extensions/SiteConfigExtension.php @@ -160,9 +160,24 @@ class SiteConfigExtension extends DataExtension )*/ } - public function MapAPIKey() + public static function MapAPIKey(): string { - return MapboxField::config()->get('access_token'); + $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 = $cfg['api_key']; + break; + default: + $key = ''; + break; + } + + return $key; } public function MapStyle()