2013-11-21 33 views
1

我有一個Office 365 SharePoint網站,我嘗試使用Bing Maps ajax控件(http://msdn.microsoft.com/en-us/library/gg427610.aspx)顯示包含地理位置數據的列表中的數據。我的地圖正確加載並顯示正確的位置,但實際的圖釘不顯示。我試過默認和自定義圖釘圖標無濟於事。當我在'vanilla'html頁面上使用類似的JavaScript時,圖釘顯示得很好,所以我認爲必須與SharePoint JavaScript或css發生某種衝突。Bing Map圖釘不顯示在Office365 SharePoint頁面上

這裏的碼相關的塊:

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

} 

任何見解讚賞。 謝謝。

回答

0

仔細檢查緯度和經度值。確保它們實際上有一個值,並且它是一個數字而不是一個字符串。如果它是一個字符串,請使用parseFloat將其轉換爲數字。以字符串形式存儲的數字是導致無法顯示圖釘的常見原因,因爲Location類最終無效。

0

Incase任何人都會遇到這個問題,進入您的互聯網設置,降低保護級別並進入「自定義級別」,找到「啓用混合內容」並啓用該解決方案已成爲兩臺機器的解決方案。