Reputation: 1544
I have a map with a ol.interaction.Select
and I add to it a ol.interaction.Draw
when I want to place some new Object (a Point).
Now as soon as I click to create the Point
, the selectInteraction
fires the select
event. As the drawend
event fires before the select
event, I'm not able to determine, if it was a genuine select
or if it happened because I'm drawing.
I also tried, to activate/deactivate the selectInteraction
with a setTimeout
in the drawend
event, with no luck. As soon as I activate the selectInteraction
, the select
event fires.
Upvotes: 1
Views: 86
Reputation: 3081
Propably, this is happening because the single-click event is taking place 251ms after you clicked. It is a known issue -->check it here. It is build that way so double click can be recognised. Having both interactions active is caussing problems for sure. Someone has to deside. Is it select? or is it draw? or both? so ol3 desides that if you set both of them active that means you want both of them active.
Disable the select interaction on drawstart
and then on drawend
try to enable your select interaction 251ms after the drawend event occurs. like sο:
setTimeout(function(){
selectInteraction.setActive(true)
},300)
;
Though, this is bad programming. But I cannt really find an elegand way to overcome it.
Upvotes: 2