我使用 BingMaps V8 API 创建了多个信息框
。
我在这里面临的问题是,当infobox
朝向 map 的 Angular 落时,infobox
中的详细信息被 trim 。
信息框正在 trim 。我想自动平移:
代码:
var ParseLatLogXml = function(xml, address){
if(typeof xml.resourceSets["0"].resources === "undefined" || xml.resourceSets["0"].resources.length === 0)
{
console.log("Lat Long of Address not found: " + address);
return [];
}
return [ xml.resourceSets["0"].resources["0"].geocodePoints["0"].coordinates["0"],
xml.resourceSets["0"].resources["0"].geocodePoints["0"].coordinates["1"] ];
};
var AddStore = function( storeNumb ,storeID, storeName, city, state, addr, phone, zip, distance, lat, long){
var _loc = new Microsoft.Maps.Location(parseFloat(lat), parseFloat(long));
var _pin = new Microsoft.Maps.Pushpin(_loc, {
icon: '-/media/1044109b112b479bb98e4daf6154e817.ashx',
anchor: new Microsoft.Maps.Point(20, 20)
}
);
var adder = addr + '\r\n' + city + '\r\n' + zip + state + "\r\n" + storeName
// Create the infobox for the pushpin
var _infoBox = new Microsoft.Maps.Infobox(_pin.getLocation(),
{ width: 300,
height: 150,
title: storeName,
description: distance + " miles" +'<br>' + addr +'<br>'+ city + " "+ zip +'<br>'+ phone ,
offset: new Microsoft.Maps.Point(10,15),
showCloseButton: false,
visible: false
});
// Add handler for the pushpin click event.
// Microsoft.Maps.Events.addHandler(_pin, 'click', displayInfobox);
Microsoft.Maps.Events.addHandler(_pin, 'mouseover', function () {
_infoBox.setOptions({ autoPan:true, visible: true });
});
Microsoft.Maps.Events.addHandler(_pin, 'mouseout', function () {
_infoBox.setOptions({ autoPan:true, visible: false });
});
map.entities.push(_pin); //[locNum]
_infoBox.setMap(map);
我尝试使用自动平移,但我不确定它是否能起到作用。 有人可以帮我解决这个问题吗?
我还尝试了 ifobox
的重新定位,dinot
也有帮助。
我使用以下链接作为引用:
最佳答案
Bing map 的 Infobox 类中没有内置的自动平移或重新定位逻辑。最简单的解决方案是在打开信息框时将 map 集中在图钉上,尽管如果使用单击事件而不是鼠标悬停事件来打开信息框,这会更适合。如果信息框位置发生更改,使用鼠标悬停/鼠标悬停事件将导致信息框关闭。
另一个选项是在此处使用自定义信息框模块:http://bingmapsv7modules.codeplex.com/wikipage?title=Custom%20Infobox%20Control此模块中的信息框根据图钉在 map 中的位置重新定位其显示方式。如果图钉位于右上角,则信息框会显示在图钉的左下角。您可以在这里找到该模块的源代码:http://bingmapsv7modules.codeplex.com/SourceControl/latest#BMv7Plugins/BMv7.CustomInfobox/scripts/V7CustomInfobox.js
关于javascript - Bing map 信息框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41944123/