Gmap3添加一个简单的上下文菜单 [英] Gmap3 adding a simple context menu

查看:97
本文介绍了Gmap3添加一个简单的上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想添加一个非常简单的上下文菜单,如下例所示:

http://gmap3.net/examples/context-menu.html



然而,这例子非常复杂,并不是一个很好的学习起点。



我只是想创建一个上下文菜单,其中包含2或3个出站链接(包括latlng on右键点击)。任何人都可以给我一个更简单的例子来工作吗?



谢谢 解决方案

在这个例子中,您需要更改以下代码:

  // MENU:ITEM 1 
menu .add('Direction to here','itemB',
function(){
menu.close();
addMarker(false);
});


现在,要添加您自己的维度菜单项,请尝试像这样

  menu.add('OutboundLink1','CSS_class_for_this_link',
function(){
var lat = $ map.gmap3('getLatlng')。lat();
var lon = $ map.gmap3('getLatlng')。lon();
window.open('someurl? lat ='+ lat +'& lon ='+ lon,'window name','window settings');
menu.close();
});


请注意,您必须提供自己的CSS样式为上下文菜单。


So I'm trying to add a pretty simple context menu like the example given at:

http://gmap3.net/examples/context-menu.html

However, this example is pretty complex and not a great starting point to learn from.

I simply want to create a context menu that has 2 or 3 outbound links (that include the latlng on right click). Can anyone give me a simpler example to work from?

Thanks

解决方案

In the example, you will need to change the following code:

 // MENU : ITEM 1
  menu.add('Direction to here', 'itemB', 
    function(){
      menu.close();
      addMarker(false);
    });

etc.

Now, to add your own contect menu items, try something like this

  menu.add('OutboundLink1', 'CSS_class_for_this_link', 
    function(){
        var lat=$map.gmap3('getLatlng').lat();
        var lon=$map.gmap3('getLatlng').lon();
        window.open('someurl?lat='+lat+'&lon='+lon, 'window name', 'window settings');
        menu.close();
    });

etc.

Note that you will have to provide your own CSS styling for the context menu.

这篇关于Gmap3添加一个简单的上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆