Fix zoom to all areas when WKT is empty.

This commit is contained in:
Michael Stenta 2020-02-03 11:35:24 -05:00
parent 6d8d070198
commit dd717a1f5c
2 changed files with 5 additions and 9 deletions

View File

@ -70,8 +70,9 @@ function farm_area_farm_map_view($name, $element) {
farm_map_add_behavior('areas', array('zoom' => TRUE));
}
// Show "all areas" layer in geofield maps.
// Show "all areas" layer in geofield maps, and zoom to them if no WKT is set.
if (in_array($name, array('farm_map_geofield', 'farm_map_geofield_widget'))) {
farm_map_add_behavior('areas_combined', array('zoom' => FALSE));
$zoom = empty($element['#wkt']) || $element['#wkt'] == 'GEOMETRYCOLLECTION EMPTY';
farm_map_add_behavior('areas_combined', array('zoom' => $zoom));
}
}

View File

@ -32,13 +32,8 @@
// If zoom is true and the layer has features, zoom to them.
// Otherwise, zoom to all vectors.
if (Drupal.settings.farm_map.behaviors.wkt.zoom) {
if (layer !== undefined) {
instance.zoomToLayer(layer);
}
else {
instance.zoomToVectors();
}
if (Drupal.settings.farm_map.behaviors.wkt.zoom && layer !== undefined) {
instance.zoomToLayer(layer);
}
}
};