From 110ec251a7e2d3ad74ff2ba256088f54c3a7359c Mon Sep 17 00:00:00 2001 From: Tony Air Date: Thu, 16 Jun 2022 00:16:25 +0200 Subject: [PATCH] FIX: MapAPI key --- src/Extensions/SiteConfigExtension.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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()