1
我尝试使用HeatMapLayer类的新Bing地图v8。该文档描述了一种setLocation方法,如下链接:必应地图v8 - heatMap.setLocation不是函数
https://msdn.microsoft.com/en-us/library/mt712811.aspx
我创建基于Bing地图互动SDK(http://www.bing.com/api/maps/sdk/mapcontrol/isdk#defaultHeatMap+JS)的例子。
ERROR:
但是当我运行我的脚本发生错误heatMap.setLocation不是函数
有人可以帮助我,好吗?
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.HeatMap', function() {
// Creating sample Pushpin data within map view
var mapDiv = map.getRootElement();
var locations = [];
for (var i = 0; i < 1000; i++) {
locations.push(map.tryPixelToLocation(new Microsoft.Maps.Point(mapDiv.clientWidth * Math.random(), mapDiv.clientHeight * Math.random()), Microsoft.Maps.PixelReference.control));
}
var heatMap = new Microsoft.Maps.HeatMapLayer();
heatMap.setLocation(locations); // error line
map.layers.insert(heatMap);
});