【问题标题】:Bing Maps Infobox必应地图信息框
【发布时间】:2017-01-30 19:40:39
【问题描述】:

我使用 BingMaps V8 API 创建了多个infoboxes

我在这里面临的问题是当infobox 朝向地图的角落时,infobox 的细节被修剪。

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

代码:

    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);

我尝试使用自动平移,但我不确定它是否可以解决问题。 有人可以帮我解决这个问题吗?

我还尝试了重新定位 ifoboxdinot 的帮助。

我使用以下链接作为参考:

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

【问题讨论】:

    标签: javascript jquery-ui maps bing-maps bing


    【解决方案1】:

    必应地图的信息框类中没有内置的自动平移或重新定位逻辑。最简单的解决方案是在打开信息框时将地图居中放在图钉上,尽管如果使用单击事件而不是鼠标悬停事件打开信息框会更合适。如果信息框位置发生更改,使用鼠标悬停/鼠标退出事件将导致信息框关闭。

    另一种选择是在此处使用自定义信息框模块:http://bingmapsv7modules.codeplex.com/wikipage?title=Custom%20Infobox%20Control 此模块中的信息框根据图钉在地图中的位置重新定位其显示方式。如果图钉位于右上角,则信息框将显示在图钉的左下角。你可以在这里找到这个模块的源代码:http://bingmapsv7modules.codeplex.com/SourceControl/latest#BMv7Plugins/BMv7.CustomInfobox/scripts/V7CustomInfobox.js

    【讨论】:

    • 这不适用于 v8,我似乎也找不到 v8 的解决方法。建议的解决方案适用于 v7。
    • 该模块也适用于 v8。大多数 v7 模块都可以。 V8 向后兼容超过 90%。该模块站点上有一张表格,列出了哪些已针对 v8 进行了测试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-17
    • 1970-01-01
    相关资源
    最近更新 更多