【问题标题】:Mouse rightclick on Openlayer 3鼠标右键单击 Openlayer 3
【发布时间】:2017-01-05 05:00:13
【问题描述】:

是否可以在 Openlayer3 上获取鼠标右键事件?如果是这样,我怎样才能获得右键单击位置的纬度和经度。

我已经通过关注获得了右键事件

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

});

如何获取右击点的经纬度?

【问题讨论】:

标签: mouseevent coordinates openlayers-3 ol3-google-maps


【解决方案1】:

使用map.getEventCoordinate 方法获取您的坐标。也可以使用 evt.preventDefault() 去掉原生的右键菜单。

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

})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 1970-01-01
    • 1970-01-01
    • 2012-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多