Bing 地图 v8 - DirectionsManager - dragDropCompleted 事件错误

Bing Maps v8 - DirectionsManager - dragDropCompleted event error

我正在使用 DirectionsManager Class 尝试 Bing Maps v8。文档描述了一个 dragDropCompleted 事件,如下 link:

https://msdn.microsoft.com/pt-br/library/hh312802.aspx

我创建了一个基于 Bing Maps Interactive SDK 的示例:

http://www.bing.com/api/maps/sdk/mapcontrol/isdk#directionsEvent_directionsUpdated+JS

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

错误:无法读取未定义的 属性'add'

有人可以帮我吗?

 var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    credentials: 'Your Bing Maps Key',
    center: new Microsoft.Maps.Location(47.606209, -122.332071),
    zoom: 12
 });

 Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
    var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
    // Set Route Mode to driving
    directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving });

    var waypoint1 = new Microsoft.Maps.Directions.Waypoint({ address: 'Redmond', location: new Microsoft.Maps.Location(47.67683029174805, -122.1099624633789) });
    var waypoint2 = new Microsoft.Maps.Directions.Waypoint({ address: 'Seattle', location: new Microsoft.Maps.Location(47.59977722167969, -122.33458709716797) });
    directionsManager.addWaypoint(waypoint1);
    directionsManager.addWaypoint(waypoint2);

    Microsoft.Maps.Events.addHandler(directionsManager, 'dragDropCompleted', function () {
        console.log('Drag & Drop Complete!');
    })

    directionsManager.calculateDirections();
 });

Bing Maps V8 中没有 dragDropCompleted 事件。您引用的文档适用于较旧的 V7 地图 API。在 V8 中,只需使用 directionsUpdated 事件。这是 DirectionsManager 的 V8 文档:https://msdn.microsoft.com/en-US/library/mt750375.aspx