Skip to content
Advertisement

Openlayers delete element option by mouse rightclick

I would like to enable the delete option after right-clicking on my object. So far, the code I provided doesn’t work, because the browser is checking some devices for me, as you can see below:

enter image description here

My code looks like this:

JavaScript

I would like to have an option to delete the selected object after the right-click. How can I do it?

UPDATE:

I found a quite good option for achieving it:

https://gis.stackexchange.com/questions/148428/how-can-i-select-a-feature-in-openlayers-3-by-right-click-it

which led me to conclusion like this:

JavaScript

based also at the solution here:

https://rawgit.com/jonataswalker/ol-contextmenu/master/examples/contextmenu.js

but so far I do the right click and the console shows the “contextmenu” only for me.

My full JSfiddle is here:

https://jsfiddle.net/1x3nuspj/

What I am doing wrong here?

Thanks & Regards

Advertisement

Answer

Here is an working example

JavaScript
JavaScript

https://jsfiddle.net/dab4Lvnz/5/

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement