Bing Maps v8 - heatMap.setLocation 不是函数

Bing Maps v8 - heatMap.setLocation is not a function

我正在尝试使用 HeatMapLayer Class 的新 Bing Maps v8。文档描述了一个 setLocation 方法,如下 link:

https://msdn.microsoft.com/en-us/library/mt712811.aspx

我基于 Bing Maps Interactive SDK (http://www.bing.com/api/maps/sdk/mapcontrol/isdk#defaultHeatMap+JS) 创建了一个示例。

但是当我运行我的脚本时出现错误:

错误: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);
});

文档中似乎有错字,应该是 setLocations。大多数开发人员在创建热图时只是将位置数组传递给构造函数,这可能是没有及早注意到这一点的原因。或者他们在开发时使用具有正确函数名称的 TypeScript 定义。

我已更新文档以修复此拼写错误。 MSDN 站点更新可能需要 15 分钟。感谢报告。