javascript - Bing map 信息框

标签 javascript jquery-ui maps bing-maps bing

我使用 BingMaps V8 API 创建了多个信息框

我在这里面临的问题是,当infobox朝向 map 的 Angular 落时,infobox中的详细信息被 trim 。

信息框正在 trim 。我想自动平移:

enter image description here

代码:

    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 也有帮助。

我使用以下链接作为引用:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/cf803dd2-0f56-429e-863b-9f9a6480ff17/bing-maps-v8-api-repositioning-an-infobox?forum=bingmapsajax

最佳答案

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/

相关文章:

javascript - 获取鼠标相对于缩小的 div 的位置

javascript - Highcharts xAxi标题如何左对齐?

JQuery UI 动态选项卡 - 自动选择

java - 如何在JavaFX/ScalaFX中实现可滚动、可缩放的 map ?

javascript - 序列化嵌套模型的 where 条件

javascript - 有没有一种识别单词的好方法,即使它在 javascript 中拼写错误?

javascript - 工具提示显示不同元素的相同消息

javascript - 如何在jQuery中找到所有被删除的元素

javascript - 谷歌地图渲染不正确,无法用已经给出的答案解决这个问题

ios - 无法在 uiimageview swift 中将 map 设置为图像