public function GoogleMapsProviderBase::getGoogleMapsApiUrl in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 modules/geolocation_google_maps/src/GoogleMapsProviderBase.php \Drupal\geolocation_google_maps\GoogleMapsProviderBase::getGoogleMapsApiUrl()
Return the fully build URL to load Google Maps API.
Parameters
array $additional_parameters: Additional parameters.
Return value
string Google Maps API URL
1 call to GoogleMapsProviderBase::getGoogleMapsApiUrl()
- GoogleStaticMaps::alterRenderArray in modules/
geolocation_google_maps/ modules/ geolocation_google_static_maps/ src/ Plugin/ geolocation/ MapProvider/ GoogleStaticMaps.php - Alter render array.
File
- modules/
geolocation_google_maps/ src/ GoogleMapsProviderBase.php, line 110
Class
- GoogleMapsProviderBase
- Class GoogleMapsProviderBase.
Namespace
Drupal\geolocation_google_mapsCode
public function getGoogleMapsApiUrl(array $additional_parameters = []) {
$config = \Drupal::config('geolocation_google_maps.settings');
if (!empty($config
->get('google_maps_base_url'))) {
$google_url = $config
->get('google_maps_base_url');
}
elseif ($config
->get('china_mode')) {
$google_url = static::$GOOGLEMAPSAPIURLBASECHINA;
}
else {
$google_url = static::$GOOGLEMAPSAPIURLBASE;
}
$parameters = [];
foreach ($this
->getGoogleMapsApiParameters($additional_parameters) as $parameter => $value) {
$parameters[$parameter] = is_array($value) ? implode(',', $value) : $value;
}
$url = Url::fromUri($google_url . static::$GOOGLEMAPSAPIURLPATH, [
'query' => $parameters,
'https' => TRUE,
]);
return $url
->toString();
}