I am using OpenLayers 3.9.0. I Want to add and remove dragZoom and dragBox interactions in OpenLayers 3 map dynamically.
<button id='box'>dragBox</button>
var dragBox = new ol.interaction.DragBox({
condition: ol.events.condition.always,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: [0, 0, 255, 1]
})
})
});
In jQuery for button click event:
$('#box').click(function(){
map.addInteraction(dragBox);
})
When this event triggered using button the cursor and the box are not at same position.
So why does this is happen, and how can we overcome this?