Я использую карту Bing для рисования маршрутов грузовиков.Но directionsError никогда не запускается, даже если не существует маршрута для двух местоположений.
Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
directionsManager.setRequestOptions({
routeMode: Microsoft.Maps.Directions.RouteMode.truck
});
//Create waypoints to route between.
var waypointA = new Microsoft.Maps.Directions.Waypoint({ address: pickup_address });
directionsManager.addWaypoint(waypointA);
var waypointB = new Microsoft.Maps.Directions.Waypoint({ address: destination_address });
directionsManager.addWaypoint(waypointB);
//Add event handlers to directions manager.
Microsoft.Maps.Events.addHandler(directionsManager, 'directionsError', directionsError);
Microsoft.Maps.Events.addHandler(directionsManager, 'directionsUpdated', directionsUpdated);
//Calculate directions.
directionsManager.calculateDirections();
});
function directionsUpdated(e) {
console.log(e);
}
//---------------- Direction Error --------------//
function directionsError(e) {
alert('Error: ' + e.message + '\r\nResponse Code: ' + e.responseCode)
}