简体   繁体   中英

Bing Map pushpins not displaying on an Office365 SharePoint page

I have an Office 365 SharePoint site where I am trying to display data from a list that contains geolocation data using the Bing Maps ajax control ( http://msdn.microsoft.com/en-us/library/gg427610.aspx ). My map is loading up correctly and displaying the correct location but the actual pushpins are not displaying. I've tried default and custom pushpin icons to no avail. When I use similar JavaScript on a 'vanilla' html page, the pushpins display just fine so I think there must be some sort of conflict with the SharePoint JavaScript or css.

Here the relevant block of code:

function fillListData(web, list, items) {
    var tile = $("#" + tileId);
    var content = tile.find('.tileContent');
    var mapOptions = {
            credentials: "",
            mapTypeId: Microsoft.Maps.MapTypeId.auto,
            showDashboard: false
            };

    var map = new Microsoft.Maps.Map(content[0], mapOptions);
    var locs = [];

    var e = items.getEnumerator();
    while (e.moveNext()) {

        var listItem = e.get_current();
        var title = listItem.get_item("Title");
        var loc = listItem.get_item("Location");
        var lat = loc.get_latitude();
        var lon = loc.get_longitude();

        var mapLoc = new Microsoft.Maps.Location(lat, lon);

        locs.push(mapLoc);
        //var pin = new Microsoft.Maps.Pushpin(mapLoc, {text: title, visible: true, icon:'../Style Library/Images/flag_red.png'}); 
        //var pin = new Microsoft.Maps.Pushpin(mapLoc, {visible: true, icon:'../Style Library/Images/flag_red.png', width: 50, height: 50}); 
        var pin = new Microsoft.Maps.Pushpin(mapLoc); 
        map.entities.push(pin);
    }

    var bestView = Microsoft.Maps.LocationRect.fromLocations(locs);
    map.setView({bounds:bestView });

}

Any insights are appreciated. Thanks.

Double check the lat and lon values. Make sure they actually have a value and that it is a number and not a string. If it is a string use parseFloat to convert it to a number. Numbers that are stored as a string is a fairly common cause for pushpins not displaying as the Location class ends up being invalid.

如果其他任何人遇到此问题,请进入您的Internet设置,降低保护级别,然后进入“自定义级别”,找到“启用混合内容”,然后启用这已成为此处两台计算机的解决方案。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM