8

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

9

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.