我正在使用bing map 绘制卡车路线。但是,即使两个位置都不存在任何路线,也永远不会触发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)
 }

最佳答案

看来这是一个最近修复的错误,因为它不再在Bing Maps的实验性分支上复制。

在此示例中,将RouteMode更新为truck并重新运行,错误消息将显示为“No solution”。
https://www.bing.com/api/maps/mapcontrol/isdk/directionsevent_directionserror?autoRedirect=false
javascript - DirectionsError事件并未在bing map 中触发-LMLPHP

关于javascript - DirectionsError事件并未在bing map 中触发,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54328764/

10-11 23:41