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.
精彩评论