public function ControlDirections::alterMap in Geolocation Field 8.3
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 ControlGoogleElementBase::alterMap
File
- modules/
geolocation_google_maps/ src/ Plugin/ geolocation/ MapFeature/ ControlDirections.php, line 238
Class
- ControlDirections
- Provides Directions Service.
Namespace
Drupal\geolocation_google_maps\Plugin\geolocation\MapFeatureCode
public function alterMap(array $render_array, array $feature_settings, array $context = []) {
$render_array = parent::alterMap($render_array, $feature_settings, $context);
$render_array['#controls']['directions'] = $this
->getDirectionsControlForm($feature_settings, $context);
switch ($feature_settings['directions_container']) {
case 'above':
if (empty($render_array['#prefix'])) {
$render_array['#prefix'] = '';
}
$render_array['#prefix'] .= '<div class="geolocation-google-maps-directions-container"></div>';
break;
case 'below':
if (empty($render_array['#suffix'])) {
$render_array['#suffix'] = '';
}
$render_array['#suffix'] .= '<div class="geolocation-google-maps-directions-container"></div>';
break;
}
$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,
'settings' => $feature_settings,
],
],
],
],
],
]);
return $render_array;
}