Using openlayers (latest – 4), I have a drawing interaction that draws a circle –
let drawCircle = new ol.interaction.Draw({source: source, type: "Circle"});
map.addInteraction(drawCircle);
Both left mouse and right mouse click have the same behavior with this interaction- they start and stop the drawing of the circle.
I also have a context menu, so I do not want the right click to do anything with the interaction, just the left click.
How do I make this happen?
Best Answer
You can use
condition
option forol.interaction.Draw
.when condition meets, drawing will be started.
In your case, drawing should be start with leftclick(which means button code
1
)So, simply add this code into
ol.interaction.Draw
's option.https://codepen.io/anon/pen/PRmJYb