You are here

public function ControlGoogleElementBase::alterMap in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/ControlGoogleElementBase.php \Drupal\geolocation_google_maps\Plugin\geolocation\MapFeature\ControlGoogleElementBase::alterMap()

Alter render array.

Parameters

array $render_array: Render array.

array $feature_settings: The current feature settings.

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

Return value

array Render array.

Overrides MapFeatureBase::alterMap

2 calls to ControlGoogleElementBase::alterMap()
ControlGoogleMapType::alterMap in modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/ControlGoogleMapType.php
Alter render array.
ControlGoogleZoom::alterMap in modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/ControlGoogleZoom.php
Alter render array.
2 methods override ControlGoogleElementBase::alterMap()
ControlGoogleMapType::alterMap in modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/ControlGoogleMapType.php
Alter render array.
ControlGoogleZoom::alterMap in modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/ControlGoogleZoom.php
Alter render array.

File

modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/ControlGoogleElementBase.php, line 50

Class

ControlGoogleElementBase
Class ControlMapFeatureBase.

Namespace

Drupal\geolocation_google_maps\Plugin\geolocation\MapFeature

Code

public function alterMap(array $render_array, array $feature_settings, array $context = []) {
  $render_array = parent::alterMap($render_array, $feature_settings, $context);
  $render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
    'library' => [
      'geolocation_google_maps/mapfeature.' . $this
        ->getPluginId(),
    ],
    'drupalSettings' => [
      'geolocation' => [
        'maps' => [
          $render_array['#id'] => [
            $this
              ->getPluginId() => [
              'enable' => TRUE,
              'position' => $feature_settings['position'],
              'behavior' => $feature_settings['behavior'],
            ],
          ],
        ],
      ],
    ],
  ]);
  return $render_array;
}