Gmap3 adding a simple context menu

拜拜、爱过 提交于 2020-01-06 08:28:06

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/6810614/gmap3-adding-a-simple-context-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!