开发者

Gmap3 adding a simple context menu

开发者 https://www.devze.com 2023-03-22 10:05 出处:网络
So I\'m trying to add a pretty simple context menu like the examp开发者_运维技巧le given at: http://gmap3.net/examples/context-menu.html

So I'm trying to add a pretty simple context menu like the examp开发者_运维技巧le 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号