public function LeafletControlLayer::alterMap in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletControlLayer.php \Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature\LeafletControlLayer::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 ControlCustomElementBase::alterMap
File
- modules/
geolocation_leaflet/ src/ Plugin/ geolocation/ MapFeature/ LeafletControlLayer.php, line 99
Class
- LeafletControlLayer
- Provides Tile Layer control element.
Namespace
Drupal\geolocation_leaflet\Plugin\geolocation\MapFeatureCode
public function alterMap(array $render_array, array $feature_settings, array $context = []) {
$render_array = parent::alterMap($render_array, $feature_settings, $context);
$feature_settings = $this
->getSettings($feature_settings);
$providers = [];
foreach ($feature_settings['tile_layer_providers'] as $list) {
foreach ($list as $variant => $values) {
if ($values['checkbox']) {
$index = str_replace(' ', '.', $variant);
$providers[$index] = $values['label'];
}
}
}
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'drupalSettings' => [
'geolocation' => [
'maps' => [
$render_array['#id'] => [
$this
->getPluginId() => [
'defaultLabel' => $feature_settings['default_label'],
'tileLayerProviders' => $providers,
'tileLayerOptions' => $feature_settings['tile_providers_options'],
],
],
],
],
],
]);
return $render_array;
}