public function Leaflet::alterRenderArray in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 modules/geolocation_leaflet/src/Plugin/geolocation/MapProvider/Leaflet.php \Drupal\geolocation_leaflet\Plugin\geolocation\MapProvider\Leaflet::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_leaflet/ src/ Plugin/ geolocation/ MapProvider/ Leaflet.php, line 119
Class
- Leaflet
- Provides Leaflet.
Namespace
Drupal\geolocation_leaflet\Plugin\geolocation\MapProviderCode
public function alterRenderArray(array $render_array, array $map_settings, array $context = []) {
$map_settings = $this
->getSettings($map_settings);
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'library' => [
'geolocation_leaflet/geolocation.leaflet',
],
'drupalSettings' => [
'geolocation' => [
'maps' => [
$render_array['#id'] => [
'settings' => [
'leaflet_settings' => $map_settings,
],
],
],
],
],
]);
$render_array = parent::alterRenderArray($render_array, $map_settings, $context);
return $render_array;
}