我正在使用DirectionsManager类尝试Bing Maps v8。文档描述了dragDropCompleted事件,如下面的链接:
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
但是当我运行脚本时出现错误:
错误:无法读取未定义的属性“添加”
有人可以帮助我吗?
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();
});
答案 0 :(得分:1)
Bing Maps V8中没有dragDropCompleted事件。您引用的文档适用于较旧的V7映射API。在V8中,只需使用directionsUpdated事件即可。以下是DirectionsManager的V8文档:https://msdn.microsoft.com/en-US/library/mt750375.aspx