The routing service can be used to find the best route to get from one location to another or to visit several locations. The best route can be the fastest route for a given time of day considering the traffic conditions applicable during that time. If you have more than two stops to visit, the routing service can determine the best order in which to visit the locations (the traveling salesman problem).
Features and capabilities:
Required parameters:
stops
- Specify two or more semicolon-delimited locations(Lat/Lng) between which the route is to be found. Max: 25.Optional parameters:
avoid_highways
- The route should avoid highways.avoid_tolls
- The route should avoid toll roads.avoid_ferries
- The route should avoid ferries.avoid_highways
- The route should avoid highways.geometry_format
- The format of the returned route geometry: latlng, lnglat or geojson.optimize
- Instructs the API to reorder stops to find the optimized route. The route first stop and last stop order is not changed, their position is considered fixed.Required parameters:
origin
- The location from which you wish to calculate directions.destination
- The location to which you wish to calculate directions.Optional parameters:
avoid_highways
- The route should avoid highways.avoid_tolls
- The route should avoid toll roads.avoid_ferries
- The route should avoid ferries.avoid_highways
- The route should avoid highways.geometry_format
- The format of the returned route geometry: latlng, lnglat or geojson.waypoints
- Specifies an array of intermediate locations to include along the route between the origin and destination points as pass through locations. Max: 23.start_time
- Time when travel is expected to start. This time is used to take into account traffic conditions (for paid plans only). You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC or you can use “now” to specify the current time.The main difference between FindDrivingRoute and FindDrivingPath is that FindDrivingRoute is optimized for a route with multiple stops and can optimize the route (reorder stops) with parameter optimize=true. FindDrivingPath does not change the order of visiting points, but is optimized for a route between two points. Also FindDrivingPath can take traffic conditions into account (for paid plans only).
The service returns a optimal route with detailed information:
A Route contains the following fields:
distance
contains the length of route (meters).duration
contains the time of route (seconds).geometry
contains the geometry of route. By default, geometry contains a single coordinates
object, which is a two-dimensional array of points (Latitude/Longitude).bounds
contains the bounds of geometry.legs
contains an array which contains information about a leg of the route, between two locations within the route. A route with no intermediate waypoints will contain exactly one leg within the legs array. Each leg consists of a series of steps.A Leg contains the following fields:
distance
contains the length of leg (meters).duration
contains the time of leg (seconds).start_point_index
contains the index of point (within geometry.coordinates
array) at which the leg starts.start_point
contains the coordinate of point (within geometry.coordinates
array) at which the leg starts.end_point_index
contains the index of point (within geometry.coordinates
array) at which the leg ends.end_point
contains the coordinate of point (within geometry.coordinates
array) at which the leg ends.bounds
contains the bounds of leg geometry.steps
contains an array which contains information about a step of the leg.A Step contains the following fields:
distance
contains the length of step (meters).duration
contains the time of step (seconds).start_point_index
contains the index of point (within geometry.coordinates
array) at which the step starts.start_point
contains the coordinate of point (within geometry.coordinates
array) at which the step starts.end_point_index
contains the index of point (within geometry.coordinates
array) at which the step ends.end_point
contains the coordinate of point (within geometry.coordinates
array) at which the step ends.bounds
contains the bounds of step geometry.maneuver
contains the action to take for the step (“turn left”, “turn right”, etc.).Please note that for FindDrivingPath, the route does not contain the field legs
but directly contains the field steps
.
{
"route":{
"distance":10148
"duration":2629
"bounds":{
"south":40.618996
"west":-74.025801
"north":40.645331
"east":-73.98078
}
"geometry":{
"coordinates":
[
0:[
0:40.629103
1:-74.025801
]
1:[
0:40.629409
1:-74.025679
]
2:[
0:40.630117
1:-74.025375
]
...
]
}
"legs":[
0:{
"distance":3919
"duration":834
"start_point_index":0
"start_point":{
"lat":40.629103
"lng":-74.025801
}
"end_point_index":112
"end_point":{
"lat":40.630157
"lng":-73.993608
}
"bounds":{...}
"steps":[
0:{
"distance":199
"duration":40
"start_point_index":0
"start_point":{...}
"end_point_index":5
"end_point":{...}
"bounds":{...}
}
1:{
"distance":2137
"duration":396
"start_point_index":5
"start_point":{...}
"end_point_index":70
"end_point":{...}
"bounds":{...}
"maneuver":"turn right"
}
2:{...}
]
}
1:{...}
2:{...}
]
}
}
{
"route":{
"distance":5401
"duration":1099
"bounds":{
"south":40.614813
"west":-74.025801
"north":40.630814
"east":-73.98078
}
"geometry":{
"coordinates":
[
0:[
0:40.629103
1:-74.025801
]
1:[
0:40.629409
1:-74.025679
]
2:[
0:40.630117
1:-74.025375
]
...
]
}
"steps":[
0:{
"distance":199
"duration":40
"start_point_index":0
"start_point":{
"lat":40.629103
"lng":-74.025801
}
"end_point_index":5
"end_point":{
"lat":40.630804
"lng":-74.025081
}
"bounds":{...}
}
1:{
"distance":2879
"duration":524
"start_point_index":5
"start_point":{...}
"end_point_index":78
"end_point":{...}
"bounds":{...}
"maneuver":"turn right"
}
2:{...}
3:{...}
]
}
}