changeset 706:d47fa556a3e8

client: improve draw behaviour * Start drawing new polygons, if one has been ended or if the drawmode is re-enabled. This way we only get one features in the vectorSource.
author Bernhard Reiter <bernhard@intevation.de>
date Fri, 21 Sep 2018 10:53:14 +0200
parents 6aa09d12157f
children fdd88e95bae7 35fd15711e9e
files client/src/map/Maplayer.vue
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/map/Maplayer.vue	Fri Sep 21 10:25:02 2018 +0200
+++ b/client/src/map/Maplayer.vue	Fri Sep 21 10:53:14 2018 +0200
@@ -64,21 +64,27 @@
       this.interaction = null;
     },
     createInteraction() {
+      var that = this;
+      this.vectorSource.clear();  // start empty
       var draw = new Draw({
         source: this.vectorSource,
         type: this.drawMode
       });
+      draw.on("drawstart", function(event) {
+        console.log(event);
+        that.vectorSource.clear();  // remove old features when draw starts
+      });
       draw.on("drawend", this.drawEnd);
       return draw;
     },
+    drawEnd(event) {
+      console.log(event);
+    },
     activateInteraction() {
       const interaction = this.createInteraction(this.drawMode);
       this.interaction = interaction;
       this.openLayersMap.addInteraction(interaction);
     },
-    drawEnd(event) {
-      console.log(event);
-    },
     buildVectorLoader(featureRequestOptions, endpoint, vectorSource) {
       // build a function to be used for VectorSource.setLoader()
       // make use of WFS().writeGetFeature to build the request