You are here

public function GoogleMapsProviderBase::getGoogleMapsApiUrl in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 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 111

Class

GoogleMapsProviderBase
Class GoogleMapsProviderBase.

Namespace

Drupal\geolocation_google_maps

Code

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();
}