directionsError事件未在bing地图中触发

时间:2019-01-23 13:48:07

标签: javascript bing-maps

我正在使用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)
 }

1 个答案:

答案 0 :(得分:0)

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

在此示例中,将RouteMode更新为truck并重新运行,错误消息将显示为“ No solution”。 https://www.bing.com/api/maps/mapcontrol/isdk/directionsevent_directionserror?autoRedirect=false enter image description here