You are here

public function GoogleMapsProviderBase::getGoogleMapsApiParameters 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::getGoogleMapsApiParameters()

Return all module and custom defined parameters.

Parameters

array $additional_parameters: Additional parameters.

Return value

array Parameters

2 calls to GoogleMapsProviderBase::getGoogleMapsApiParameters()
GoogleMaps::getGoogleMapsApiParameters in modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php
Return all module and custom defined parameters.
GoogleMapsProviderBase::getGoogleMapsApiUrl in modules/geolocation_google_maps/src/GoogleMapsProviderBase.php
Return the fully build URL to load Google Maps API.
1 method overrides GoogleMapsProviderBase::getGoogleMapsApiParameters()
GoogleMaps::getGoogleMapsApiParameters in modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php
Return all module and custom defined parameters.

File

modules/geolocation_google_maps/src/GoogleMapsProviderBase.php, line 74

Class

GoogleMapsProviderBase
Class GoogleMapsProviderBase.

Namespace

Drupal\geolocation_google_maps

Code

public function getGoogleMapsApiParameters(array $additional_parameters = []) {
  $config = \Drupal::config('geolocation_google_maps.settings');
  $geolocation_parameters = [
    'key' => KeyProvider::getKeyValue($config
      ->get('google_map_api_key')),
  ];
  $module_parameters = \Drupal::moduleHandler()
    ->invokeAll('geolocation_google_maps_parameters') ?: [];
  $custom_parameters = $config
    ->get('google_map_custom_url_parameters') ?: [];

  // Set the map language to site language if desired and possible.
  if ($config
    ->get('use_current_language') && \Drupal::moduleHandler()
    ->moduleExists('language')) {
    $custom_parameters['language'] = \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getId();
  }
  $parameters = array_replace_recursive($additional_parameters, $custom_parameters, $module_parameters, $geolocation_parameters);
  foreach ($parameters as $key => $value) {
    if (is_string($value) && $value === '') {
      unset($parameters[$key]);
    }
  }
  return $parameters;
}