I used rightclick handler with openlayers2 and now I am upgrading my website to openlayers3 and I cannot find this handler in ol3
Asked
Active
Viewed 5,976 times
9
-
1This can help you: https://groups.google.com/forum/#!searchin/ol3-dev/contextmenu/ol3-dev/yCgIcbURw9M/cPPJNCMW2PQJ – acanimal Dec 30 '14 at 21:36
1 Answers
10
Just repeating/summarizing some other answers. You can add your own listener on viewport:
map.getViewport().addEventListener('contextmenu', function (evt) {
evt.preventDefault();
console.info('contextmenu');
});
Or use an extension I've written to address this feature - https://github.com/jonataswalker/ol3-contextmenu - jsFiddle demo.
Jonatas Walker
- 2,214
- 13
- 26