2017-07-24 182 views
0

我發現了一個官方文章,顯示如何將聚類層添加到Map,但該示例需要輸入TestDataGenerator函數。我不知道如何傳遞我的信息,以便地圖將根據我的數據生成圖釘。Bing地圖插圖 - 如何使用Bing Maps V8交互式SDK在Bing地圖上添加自定義數據(座標)的集羣圖層?

Bing Map Official Article on "Add clustering layer to map"

<div id='printoutPanel'></div> 
     <div id='myMap' style='width: 100vw; height: 100vh;'></div> 
     <script type='text/javascript'> 
      function loadMapScenario() { 
       var map = new Microsoft.Maps.Map(document.getElementById('myMap'), { 
        credentials: 'Your Bing Maps Key', 
        center: new Microsoft.Maps.Location(39.393486, -98.100769), 
        zoom: 3 
       }); 
       Microsoft.Maps.loadModule('Microsoft.Maps.Clustering', function() { 
        // Creating sample Pushpin data within map view 
        var pushpins = Microsoft.Maps.TestDataGenerator.getPushpins(1000, map.getBounds()); 
        var clusterLayer = new Microsoft.Maps.ClusterLayer(pushpins, { gridSize: 100 }); 
        map.layers.insert(clusterLayer); 
       }); 
      } 
     </script> 
     <script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=loadMapScenario' async defer></script> 

請訪問上面的鏈接,如果任何事情都是未明確的。

回答

0

測試數據生成器返回一個圖釘陣列。簡單地循環訪問自定義數據並創建一個圖釘陣列,然後將其傳遞到集羣層。

+0

感謝您的回覆。你可以給我簡單的代碼,我可以把什麼樣的數據放入圖釘陣列。我想用經度和經度生成圖釘。 –

+0

這裏有大量的樣本和文檔:https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#addDefaultPushpin+JS – rbrundritt