By
TrueWay Team |
Updated a year ago |
Mapping

Popularity

Latency

Service Level

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:

- Global road network coverage.
- Find the best route between two or more locations.
- Optimize routes.
- Use both historical traffic conditions and live traffic.
- Can avoid toll roads, highways or ferries.
- Return distance and duration information.
- Return route geometry.
- Return multi-part directions using a series of stops.
- Return turn-by-turn information.

*Required parameters:*

- Specify two or more semicolon-delimited locations(Lat/Lng) between which the route is to be found. Max: 25.`stops`

*Optional parameters:*

- The route should avoid highways.`avoid_highways`

- The route should avoid toll roads.`avoid_tolls`

- The route should avoid ferries.`avoid_ferries`

- The route should avoid highways.`avoid_highways`

- The format of the returned route geometry: latlng, lnglat or geojson.`geometry_format`

- 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.`optimize`

*Required parameters:*

- The location from which you wish to calculate directions.`origin`

- The location to which you wish to calculate directions.`destination`

*Optional parameters:*

- The route should avoid highways.`avoid_highways`

- The route should avoid toll roads.`avoid_tolls`

- The route should avoid ferries.`avoid_ferries`

- The route should avoid highways.`avoid_highways`

- The format of the returned route geometry: latlng, lnglat or geojson.`geometry_format`

- Specifies an array of intermediate locations to include along the route between the origin and destination points as pass through locations. Max: 23.`waypoints`

- 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.`start_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:

- distance (length of route)
- duration (time of route)
- route geometry
- bounds of route geometry
- turn-by-turn directions

A **Route** contains the following fields:

contains the length of route (meters).`distance`

contains the time of route (seconds).`duration`

contains the geometry of route. By default, geometry contains a single`geometry`

object, which is a two-dimensional array of points (Latitude/Longitude).`coordinates`

contains the bounds of geometry.`bounds`

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.`legs`

A **Leg** contains the following fields:

contains the length of leg (meters).`distance`

contains the time of leg (seconds).`duration`

contains the index of point (within`start_point_index`

array) at which the leg starts.`geometry.coordinates`

contains the coordinate of point (within`start_point`

array) at which the leg starts.`geometry.coordinates`

contains the index of point (within`end_point_index`

array) at which the leg ends.`geometry.coordinates`

contains the coordinate of point (within`end_point`

array) at which the leg ends.`geometry.coordinates`

contains the bounds of leg geometry.`bounds`

contains an array which contains information about a step of the leg.`steps`

A **Step** contains the following fields:

contains the length of step (meters).`distance`

contains the time of step (seconds).`duration`

contains the index of point (within`start_point_index`

array) at which the step starts.`geometry.coordinates`

contains the coordinate of point (within`start_point`

array) at which the step starts.`geometry.coordinates`

contains the index of point (within`end_point_index`

array) at which the step ends.`geometry.coordinates`

contains the coordinate of point (within`end_point`

array) at which the step ends.`geometry.coordinates`

contains the bounds of step geometry.`bounds`

contains the action to take for the step (“turn left”, “turn right”, etc.).`maneuver`

*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:{...}
]
}
}
```