You are here

public function GoogleMaps::alterRenderArray in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php \Drupal\geolocation_google_maps\Plugin\geolocation\MapProvider\GoogleMaps::alterRenderArray()

Alter render array.

Parameters

array $render_array: Render array.

array $map_settings: The current map settings.

array $context: Context like field formatter, field widget or view.

Return value

array Render attachments.

Overrides MapProviderBase::alterRenderArray

File

modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php, line 193

Class

GoogleMaps
Provides Google Maps.

Namespace

Drupal\geolocation_google_maps\Plugin\geolocation\MapProvider

Code

public function alterRenderArray(array $render_array, array $map_settings, array $context = []) {
  $render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
    'library' => [
      'geolocation_google_maps/google',
    ],
    'drupalSettings' => [
      'geolocation' => [
        'maps' => [
          $render_array['#id'] => [
            'settings' => [
              'google_map_settings' => $map_settings,
            ],
          ],
        ],
      ],
    ],
  ]);
  return parent::alterRenderArray($render_array, $map_settings, $context);
}