2016-12-01 39 views
0

我正在尝试使用DirectionsManager类的Bing Maps v8。该文档描述了dragDropCompleted事件,如下链接:Bing Maps v8 - DirectionsManager - dragDropCompleted事件错误

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

我已经创建了一个基于Bing地图互动SDK的例子:

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

但是当我运行我的脚本发生错误:

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

'加' 210

有人可以帮我吗?

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(); 
}); 

回答