我目前正在开发一个 bing 地图应用程序,当用户单击图钉时,我似乎无法显示信息框。我一直在关注SDK,它应该几乎完全一样。这是我所拥有的:
// ***********************************
// Function creates a single pin
// and returns a reference to the pin
function createMapPin(latLong, sName) {
var pinImg = "imagespins/Good.png";
var pin = new Microsoft.Maps.Pushpin(latLong, {
icon: pinImg,
anchor: new Microsoft.Maps.Point(8, 8),
draggable: true,
width: 48,
height: 48
});
pin.title = sName;
pinInfobox = new Microsoft.Maps.Infobox(pin.getLocation(),
{ title: 'My Pushpin',
description: 'This pushpin is located at (0,0).',
visible: false,
offset: new Microsoft.Maps.Point(0, 15)
});
// Add handlers for the pushpin events
Microsoft.Maps.Events.addHandler(pin, 'click', displayInfobox);
// Hide the infobox when the map is moved.
Microsoft.Maps.Events.addHandler(map, 'viewchange', hideInfobox);
map.entities.push(pin);
map.entities.push(pinInfobox);
return pin;
}
function displayInfobox(e) {
pinInfobox.setOptions({ visible: true });
}
function hideInfobox(e) {
pinInfobox.setOptions({ visible: false });
}
引脚成功创建并添加到地图中,当用户单击引脚时,它确实进入了 dispayInfoBox 方法,但消息框似乎没有出现。
任何建议都非常感谢。谢谢!