Update SiteConfigExtension.php

This commit is contained in:
Tony Air 2022-06-16 00:25:09 +02:00 committed by GitHub
parent 4f3d39f7ad
commit 3442745c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -11,6 +11,26 @@ class SiteConfigExtension extends Extension
{
return MapboxField::getAccessToken();
}
public static 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 = $cfg['api_key'];
break;
default:
$key = '';
break;
}
return $key;
}
public function MapStyle()
{