Export (0) Print
Expand All

RouteResponseCode Enumeration

Bing

Contains response codes for a route calculation request.

Constants

Response Code Name Description

0

success

The route was successfully calculated.

1

unknownError

An unknown error has occurred.

2

cannotFindNearbyRoad

A nearby road cannot be found for one or more of the route waypoints.

3

tooFar

The distance between two route waypoints, or the total length of the route exceeds the limit of the route mode. Modify the waypoint locations so that they are closer together.

4

noSolution

A route cannot be calculated for the specified waypoints. For example, this code is returned when a route between “Seattle, WA” and “Honolulu, HI” is requested.

5

dataSourceNotFound

There is no route data for the specified waypoints.

7

noAvailableTransitTrip

There are no transit options available for the specified time.

8

transitStopsTooClose

The transit stops are so close that walking is always a better option.

9

walkingBestAlternative

The transit stops are so close that walking is a better option.

10

outOfTransitBounds

There is no transit data available for the route or for one or more of the specified waypoints, or the waypoints are in different transit areas that do not overlap.

11

timeout

The directions calculation request has timed out.

12

waypointDisambiguation

One or more waypoints need to be disambiguated. This error does not occur if the autoDisplayDisambiguation directions render option is set to true.

13

hasEmptyWaypoint

One or more waypoints do not have an address or location specified.

14

exceedMaxWaypointLimit

The maximum number of waypoints, which is 25, has been exceeded.

15

atleastTwoWaypointRequired

At least two waypoints are required to calculate a route.

16

firstOrLastStoppointIsVia

The first or last waypoint is a via point, which is not allowed.

17

searchServiceFailed

The search service failed to return results.

18

invalidCredentials

The credentials passed to the Directions module are invalid.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">
         
         var map = null;
         var directionsManager = null;

         function GetMap()
         {
            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Bing Maps Key"});
            Microsoft.Maps.loadModule('Microsoft.Maps.Directions', { callback: directionsModuleLoaded });

         }



         function directionsModuleLoaded()
         {
            // Initialize the DirectionsManager
            directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);

            // Create start and end waypoints
            var waypoint1 = new Microsoft.Maps.Directions.Waypoint({address:"Seattle, WA"}); 
            var waypoint2 = new Microsoft.Maps.Directions.Waypoint({ address: "Redmond, WA"});
            var waypoint3 = new Microsoft.Maps.Directions.Waypoint({ address: "Bellevue, WA", isViapoint: true } );

            directionsManager.addWaypoint(waypoint1);
            directionsManager.addWaypoint(waypoint2);
            directionsManager.addWaypoint(waypoint3);

            // Set the id of the div to use to display the directions
            directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('itineraryDiv') });

            // Specify a handler for when an error occurs
            Microsoft.Maps.Events.addHandler(directionsManager, 'directionsError', displayError);

            // Calculate directions, which displays a route on the map
            directionsManager.calculateDirections();

         } 

         function displayError(e)
         {
            // Display the error message
            alert(e.message);

            // If the error is a viapoint error, display an error
            if (e.responseCode == Microsoft.Maps.Directions.RouteResponseCode.firstOrLastStoppointIsVia )
            {
               alert("Please remove the 'isViapoint' option from your first or last stop point.");
            }
         }

      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
      <div id='itineraryDiv' style="position:relative; width:400px;"></div>
   </body>
</html>
Show:
© 2014 Microsoft