Path from Route

The Path from Route function provides an easy method for searching along the corridor defined by a route. The function provides the times/distances needed to reach a set of Locations from an existing route.


Service Documentation

Service URL:

/directions/v2/pathfromroute


Parameters

Name Description
sessionId The sessionId associated with the base route upon which you want to base your search.
points A list of lat/lng pairs which define the points to which you want to calculate the time/distance from the base route.

The format of the points argument should match the shapeFormat parameter of the route options (default = "raw").

See the shapeFormat and Encoded Shape Points documentation for more details.
maxDistance
OR
maxTime
The maximum distance or time you are willing to travel off the base route to reach a location. If maxDistance is supplied, the units are assumed to match those of the unit option (default: Miles), and a route type of "shortest" will be applied. If maxTime is supplied, the units are assumed to be seconds, and a route type of "fastest" will be applied.

Note: You must supply either maxDistance OR maxTime, but not both!

Response

The response from a Path from Route call consists of three arrays:

  1. times: An array of integer values, corresponding to the time (in seconds) needed to reach each point from the base route. This array will be the same length as the number of locations passed to this call in the points input parameter. If the value for a location is 0, the location is close enough to the route to be considered "on" the route. If the value is -1, the location can not be reached within the input time/distance constraint.
  2. distances: An array of floating point values, corresponding to the distance (in miles or kilometers, as defined by the unit parameter of the request options) to each point from the base route. This array will be the same length as the number of locations passed to this call in the points input parameter. If the value for a location is 0, the location is close enough to the route to be considered "on" the route. If the value is -1, the location can not be reached within the input time/distance constraint.
  3. exitPoints: An array of lat/lng pairs, corresponding to the exit points where a route would diverge from the base route to reach each location. The length of this array will be exactly double the number of locations passed to this call in the points input parameter. If a location is not reachable, it will have a lat/lng of 0/0.
  4. info: An Info Block object, as documented in the base Directions Service documentation.

If none of the locations supplied in the points input parameter are reachable within the given time/distance contraint, the times, disatances, and exitPoints arrays will be empty. In this case, consult the info return object for a more detailed explanation of the return.


Sample

The following sample shows the Path from Route function in action. The sample happens in several steps.

  1. A generic route is requested between two locations.
  2. A random set of locations is generated near the straight-line path between the two locations from step (1).
  3. The Path from Route function is called to remove locations which are unreachable from the original route. Locations which are reachable from the original route are updated to display the time/distance required to reach the point. Also, the location of the exitPoint for each point is displayed, and a link is provided to get driving directions from the exitPoint to the location.

Step 1

From:
To:

Step 2

Max Distance:       Units:
Max Time (mins.):
Shape Format:
Input Format:

 

Sample URL:

  © MapQuest, Inc. All rights reserved.    Privacy Policy | Terms of Use