Intermediate waypoints are locations in between the origin and destination that you want the route to go through. An intermediate waypoint can be a stop or you can specify it as a location to pass through. For an example of a waypoint for a stop, see Set a stop along a route. For an example of a waypoint to pass-through, see Set a point for a route to pass through.
Use the intermediates
property of the computeRoutes
method to define up to a maximum of 25 intermediate
waypoints.
For each intermediate waypoint in the request, a new leg is added to the route.
Example request
The following example shows how to set an intermediate waypoint. The example uses the
intermediates
property of the computeRoutes
request to define an intermediate waypoint.
const routeRequestWithIntermediates = { origin: 'Mountain View, CA', destination: 'San Francisco, CA', travelMode: 'DRIVING', intermediates: [{location: 'San Mateo, CA'}, {location: 'Half Moon Bay, CA'}], fields: ['path', 'legs'], };