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 - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -