You are here

public function ControlElementBase::alterMap in Geolocation Field 8.3

Same name in this branch
  1. 8.3 modules/geolocation_yandex/src/Plugin/geolocation/MapFeature/ControlElementBase.php \Drupal\geolocation_yandex\Plugin\geolocation\MapFeature\ControlElementBase::alterMap()
  2. 8.3 modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/ControlElementBase.php \Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature\ControlElementBase::alterMap()
Same name and namespace in other branches
  1. 8.2 modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/ControlElementBase.php \Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature\ControlElementBase::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

3 calls to ControlElementBase::alterMap()
ControlCustomElementBase::alterMap in modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/ControlCustomElementBase.php
Alter render array.
LeafletControlAttribution::alterMap in modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletControlAttribution.php
Alter render array.
LeafletControlScale::alterMap in modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletControlScale.php
Alter render array.
3 methods override ControlElementBase::alterMap()
ControlCustomElementBase::alterMap in modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/ControlCustomElementBase.php
Alter render array.
LeafletControlAttribution::alterMap in modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletControlAttribution.php
Alter render array.
LeafletControlScale::alterMap in modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletControlScale.php
Alter render array.

File

modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/ControlElementBase.php, line 57

Class

ControlElementBase
Class ControlMapFeatureBase.

Namespace

Drupal\geolocation_leaflet\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_leaflet/mapfeature.' . $this
        ->getPluginId(),
    ],
    'drupalSettings' => [
      'geolocation' => [
        'maps' => [
          $render_array['#id'] => [
            $this
              ->getPluginId() => [
              'enable' => TRUE,
              'position' => empty($feature_settings['position']) ? '' : $feature_settings['position'],
            ],
          ],
        ],
      ],
    ],
  ]);
  return $render_array;
}