If #edit is TRUE on a map element, enable the edit behavior.

This commit is contained in:
Michael Stenta 2020-01-30 13:38:20 -05:00
parent cd800b73f4
commit 8baceff31f
2 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,9 @@ function farm_map_farm_map_view($name, $element) {
$settings = array(
'zoom' => TRUE,
);
if (!empty($element['#edit'])) {
$settings['edit'] = TRUE;
}
farm_map_add_behavior('wkt', $settings);
}
}

View File

@ -17,6 +17,15 @@
var layer = instance.addLayer(type, opts);
}
// If edit is true, enable drawing controls.
if (Drupal.settings.farm_map.behaviors.wkt.edit) {
if (layer !== undefined) {
instance.addBehavior('edit', { layer: layer });
} else {
instance.addBehavior('edit');
}
}
// 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) {