Mouse rightclick on Openlayer 3
Asked Answered
D

1

6

Is is possible to get the mouse right click event on Openlayer3? If so how can i get the latitude and longitude of the right clicked location.

i have got the right click event by following

map.getViewport().addEventListener('contextmenu', function (evt) {

});

How can i get the latitude and longitude of the right clicked point?

Durazzo answered 5/1, 2017 at 5:0 Comment(1)
refer this gis.stackexchange.com/questions/148428/…Labarbera
C
19

Use the map.getEventCoordinate method to get your coords. Also use the evt.preventDefault() to get rid of the native right click menu.

map.getViewport().addEventListener('contextmenu', function (evt) {
evt.preventDefault();
console.log(map.getEventCoordinate(evt));

})
Comportment answered 5/1, 2017 at 7:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.