javascript - Allow only one draw feature in Openlayer3 -


i'm using ol.interaction.draw draw points on map. enable user draw 1 unique point each time he/she clicks on "draw" icon. idea on how that?

here code interaction:

function addinteraction() { draw = new ol.interaction.draw({   source: sourcecomments,   type: "point" });  draw.on('drawend',   function(evt) {     // unset sketch     sketch = null;     var allfeatures = comments.getsource().getfeatures();     var format = new ol.format.geojson();     document.getelementbyid('geometry').value =   json.stringify(format.writefeatures(allfeatures), null, 4);   }, this);  map.addinteraction(draw); } 

thanks!

you possibly remove interaction map on drawend event.

var draw;  function addinteraction() {     draw = new ol.interaction.draw({         source: sourcecomments,         type: "point"     });      draw.on('drawend', function(evt) {         //... unset sketch         map.removeinteraction(draw);     }, this);      map.addinteraction(draw); } 

Comments

Popular posts from this blog

java - Unable to make sub reports with Jasper -

scala - play framework: Modules were resolved with conflicting cross-version suffixes -

Save and close a word document by giving a name in R -