Reputation: 75
I am trying the Bing Maps v8 using DirectionsManager Class. The docs describes a dragDropCompleted event, as link below:
https://msdn.microsoft.com/pt-br/library/hh312802.aspx
I have created an example based on Bing Maps Interactive SDK:
http://www.bing.com/api/maps/sdk/mapcontrol/isdk#directionsEvent_directionsUpdated+JS
But an error occurs when I run my script:
ERROR: Cannot read property 'add' of undefined
Can someone help me, please?
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();
});
Upvotes: 0
Views: 243
Reputation: 17954
There is no dragDropCompleted event in Bing Maps V8. The documentation you referenced is for the older V7 map API. In V8, just use the directionsUpdated event. Here is the V8 documentation for the DirectionsManager: https://msdn.microsoft.com/en-US/library/mt750375.aspx
Upvotes: 1