Fix duplicate measure behavior on editable maps.

This commit is contained in:
Michael Stenta 2020-02-03 11:23:26 -05:00
parent 3984b8d8dd
commit 6d8d070198
1 changed files with 4 additions and 3 deletions

View File

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