Bing Maps V7上下文菜单 [英] Bing Maps V7 Context Menu

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

问题描述

我使用Bing Maps Ajax V7.我想右键单击以获取一个信息框并在其中显示我的链接.

I use Bing Maps Ajax V7. I want on right click to get an infobox and show my links inside.

function GetMap(){
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:""}); 
attachrightclick = Microsoft.Maps.Events.addHandler(map, 'rightclick',showPopupMenu); 
}

function showPopupMenu(e){

var latlong = new Microsoft.Maps.Location(e.getY(),e.getX());

var defaultInfobox = new Microsoft.Maps.Infobox(latlong, {title: '<div>My Pushpin<div>', visible: true} ); 
map.entities.push(defaultInfobox);
}

已添加信息框,但不幸的是,我无法点击指向...我在其他latlon上添加...

Infobox added but unfortunately have no sense with to point I clicks... I adds on other latlon...

让任何人有一个主意:

1)如何在我右键单击的位置加载信息窗口. 2)禁用浏览器的默认右键单击,仅显示信息框,而不显示右键菜单

1)How to make info window load on position where I right click. 2)Disable default right click of browser so only shows info box and not and right click menu

非常感谢.

推荐答案

问题编号1:

var pushpin= new Microsoft.Maps.Pushpin(map.getCenter(), null); 
pushpinClick= Microsoft.Maps.Events.addHandler(pushpin, 'rightclick', displayEventInfo);  
map.entities.push(pushpin); 

function displayEventInfo(e){
    var pushpin = e.target;
    var infoboxOptions = {width :200, height :100, showCloseButton: true, zIndex: 0, offset:new Microsoft.Maps.Point(10,0), showPointer: true}; 
    var defaultInfobox = new Microsoft.Maps.Infobox(pushpin.getLocation(), infoboxOptions );    
    map.entities.push(defaultInfobox);
    defaultInfobox.setHtmlContent('html content goes here!'); 
}

问题2:

<body oncontextmenu="return false">
...
</body>

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

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