Move logic for disabling zoom when WKT is present to farm_ui_map.
This commit is contained in:
parent
83e6d3abfb
commit
2e4d0bef1d
|
@ -41,10 +41,6 @@ class MapRenderEventSubscriber implements EventSubscriberInterface {
|
|||
// Add the WKT behavior if the render element has WKT.
|
||||
if (!empty($event->element['#map_settings']['wkt'])) {
|
||||
$event->addBehavior('wkt');
|
||||
|
||||
// Prevent zooming to the "All locations" layer if WKT is provided.
|
||||
$settings[$event->getMapTargetId()]['asset_type_layers']['all_locations']['zoom'] = FALSE;
|
||||
$event->addSettings($settings);
|
||||
}
|
||||
|
||||
// Add the wkt and geofield behavior to the geofield_widget map.
|
||||
|
|
|
@ -53,8 +53,10 @@ class MapRenderEventSubscriber implements EventSubscriberInterface {
|
|||
// Get the map ID.
|
||||
$map_id = $event->getmapType()->id();
|
||||
|
||||
// Add "all locations" layers to default and geofield maps.
|
||||
// Add behaviors/settings to default and geofield maps.
|
||||
if (in_array($map_id, ['default', 'geofield', 'geofield_widget'])) {
|
||||
|
||||
// Add "All locations" layers.
|
||||
$event->addBehavior('asset_type_layers');
|
||||
$settings[$event->getMapTargetId()]['asset_type_layers']['all_locations'] = [
|
||||
'label' => $this->t('All locations'),
|
||||
|
@ -65,6 +67,12 @@ class MapRenderEventSubscriber implements EventSubscriberInterface {
|
|||
'zoom' => TRUE,
|
||||
];
|
||||
$event->addSettings($settings);
|
||||
|
||||
// Prevent zooming to the "All locations" layer if WKT is provided.
|
||||
if (!empty($event->element['#map_settings']['wkt'])) {
|
||||
$settings[$event->getMapTargetId()]['asset_type_layers']['all_locations']['zoom'] = FALSE;
|
||||
$event->addSettings($settings);
|
||||
}
|
||||
}
|
||||
|
||||
// Add asset layers to dashboard map.
|
||||
|
|
Loading…
Reference in New Issue