Returns the primary route between requested origin and destination for the requested travel mode.
HTTP request
POST https://mapstools.googleapis.com/v1:computeRoutes
The URL uses gRPC Transcoding syntax.
Request body
The request body contains data with the following structure:
| JSON representation |
|---|
{ "origin": { object ( |
| Fields | |
|---|---|
origin |
Required. Origin waypoint. |
destination |
Required. Destination waypoint. |
travelMode |
Optional. Specifies the mode of transportation. |
intermediateWaypoints[] |
Optional. Intermediate stops between the origin and destination to pass through in order. Up to 25 intermediate waypoints are supported. Specifying more than 10 intermediate waypoints will incur higher cost and higher latency. Intermediate waypoints are not supported when |
routingPreference |
Optional. Determines how traffic data is used to compute the route. |
locationBias |
Optional. A location to bias the search results toward, for example to disambiguate waypoint text queries. |
includePolyline |
Optional. Whether to include the encoded polyline in the response routes. Defaults to |
computeAlternativeRoutes |
Optional. Whether to compute alternative routes in addition to the recommended route. Defaults to false, in which case only the recommended route is returned. When set to true, up to all available routes are returned, though alternatives may not be available for every request. |
Specifies when to depart from the origin or arrive at the final waypoint. Defaults to departing at the current time if not specified. For TRANSIT, the time must be at most 7 days in the past and at most 100 days in the future. For other travel modes, the time must not be in the past and must be at most 365 days in the future. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: |
|
departureTime |
Optional. Indicates that the route should be computed based on departure time. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
arrivalTime |
Optional. Indicates that the route should be computed based on arrival time. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
| End of mutually exclusive fields. | |
Response body
If successful, the response body contains an instance of ComputeRoutesResponse.
Authorization scopes
Requires the following OAuth scope:
https://www.googleapis.com/auth/maps-platform.mapstools