FIX: MapAPI key

This commit is contained in:
Tony Air 2022-06-16 00:16:25 +02:00
parent 883e0c193d
commit 110ec251a7
1 changed files with 17 additions and 2 deletions

View File

@ -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()