9

I used rightclick handler with openlayers2 and now I am upgrading my website to openlayers3 and I cannot find this handler in ol3

Mariam Malak
  • 603
  • 1
  • 6
  • 17
  • 1
    This can help you: https://groups.google.com/forum/#!searchin/ol3-dev/contextmenu/ol3-dev/yCgIcbURw9M/cPPJNCMW2PQJ – acanimal Dec 30 '14 at 21:36

1 Answers1

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.

See https://stackoverflow.com/a/32246757/4640499.

Jonatas Walker
  • 2,214
  • 13
  • 26