I am using openlayers 3.20.0. And below link will show you the small example.
click-here. (In the example see the console for logs)
I have a map object as
this.map = new ol.Map({
layers : [ somelayer ],
target : 'map',
view : new ol.View({
center : [ -11000000, 4600000 ],
zoom : 4
})
});
Here I have attached 'singleclick' and 'dblclick' on map.
And also I have draw interaction on map, as below
this.draw = new ol.interaction.Draw({
features : features,
type : "Point"
});
which is emits 'drawstart' and 'drawend' event.
But when we are drawing a point it will emit 'singleclick' event on map also. How can we prevent this from not emitting the 'singleclick' while drawing.
I know we can remove the 'singleclick' event listener while drawing, but I don't want to remove listener and add again.
Is there any other way of suppressing this event.
event.stopPropagation();
use this.singleclick
is or not active. But I think you're looking forevent.preventDefault()
.event.stopPropagation()
also. But It will fire drawstart then drawend and finally singleclick events.