【问题标题】:How to override right click contextmenu on openlayers map?如何覆盖openlayers地图上的右键单击上下文菜单?
【发布时间】:2011-11-13 16:43:41
【问题描述】:

我是 OpenLayers 的初学者。我正在尝试覆盖地图上的右键单击上下文菜单。有可能吗?怎么做?如果有人有示例或示例,请告诉我。

感谢您的帮助。

【问题讨论】:

    标签: javascript google-maps map openlayers


    【解决方案1】:

    您可以尝试查看此页面:Spatial Notes: Capturing right-click events in OpenLayers(不是我的博客)。 我刚刚测试了提供的代码,它似乎工作。尝试将代码复制粘贴到您页面的初始化函数中;

    function initialize() {
       copy the code here
    }
    
    <body onload="initialize()">
    etc...
    

    然后从点位置获取坐标,您可以查看:How to display mouse position as tooltip in OpenLayers? 并使用 getLonLatFromPixel 函数。

    var position = map.getLonLatFromViewPortPx(e.xy);
    

    【讨论】:

      【解决方案2】:

      是的,但与 OpenLayers 无关。

      window.oncontextmenu = function( event ){
        alert('you clicked');  
      };
      

      【讨论】:

        猜你喜欢
        • 2012-04-19
        • 2016-02-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-15
        • 2017-04-22
        • 1970-01-01
        相关资源
        最近更新 更多