2017-07-24 179 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