Set a stop along a route

  • Use the vehicleStopover property to designate a waypoint as a stopover for pickups or drop-offs, ensuring the route avoids unsuitable roads like highways or tunnels.

  • Requests utilizing the vehicleStopover property incur higher billing rates compared to standard route requests.

  • Setting vehicleStopover to true guarantees the route starts or ends on a road suitable for pickups and drop-offs, avoiding issues with waypoints located near tunnels or highways.

  • The vehicleStopover property is crucial for optimizing routes for vehicles that require specific pickup and drop-off locations.

European Economic Area (EEA) developers

You can set a stop along a route, such as for a pickup or drop-off, in one of two ways:

  • Add an intermediate waypoint: This is the default option. Add an intermediate waypoint between the origin and destination in the intermediates array. The routing engine snaps the waypoint to the nearest navigable road and divides the route into RouteLeg segments connected by that stop.
  • Specify a vehicleStopover: If you want the routing engine to perform additional analysis to avoid road segments unsuitable for stopping—such as highways, tunnels, or overpasses—set vehicleStopover: true on a waypoint.

Add an intermediate waypoint

To set a stop along a route, add an intermediate waypoint to the intermediates array in your request.

Adding an intermediate waypoint has the following effects:

  • The route divides into RouteLeg segments: Each segment connects one stop to the next.
  • The coordinate snaps to a road: The routing engine snaps your latitude and longitude coordinate, which might be on a rooftop or in a yard, to the nearest navigable road segment.

For many surface streets, snapping to the nearest road provides a practical stop location. However, snapping doesn't determine whether that road segment is appropriate for pulling over, such as when the nearest road is a highway or a tunnel.

Example: Add an intermediate waypoint

The following example demonstrates how to set a stop along a route by adding an intermediate waypoint in a computeRoutes POST request:

curl -X POST -d '{
  "origin":{
    "location":{
      "latLng":{
        "latitude": 37.419734,
        "longitude": -122.0827784
      }
    }
  },
  "destination":{
    "location":{
      "latLng":{
        "latitude": 37.417670,
        "longitude": -122.079595
      }
    }
  },
  "intermediates": [
    {
      "location":{
        "latLng":{
          "latitude": 37.419734,
          "longitude": -122.0807784
        }
      }
    }
  ],
  "travelMode": "DRIVE"
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY' \
-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.legs' \
'https://routes.googleapis.com/directions/v2:computeRoutes'

For more information about intermediate waypoints and route legs, see Set intermediate waypoints.

Specify a vehicleStopover for pickup and drop-off suitability

While a standard intermediate waypoint snaps to the nearest road, that road isn't always suitable for a vehicle stop. When you want the routing engine to perform additional analysis to evaluate road suitability for pickup or drop-off, set vehicleStopover: true on the waypoint.

When you set vehicleStopover: true, the routing engine evaluates candidate road segments and attempts to avoid roads that are unsuitable for stopping, such as freeways, tunnels, and overpasses.

For example, consider a location where a surface road passes directly over a highway inside a tunnel: * Standard intermediate waypoint: Snaps to the highway or tunnel underneath if it's geometrically closer to your coordinate. * Vehicle stopover: Performs additional analysis to bypass the highway and tunnel, snapping the stop to a surface road suitable for pulling over.

Example: Specify vehicleStopover on a waypoint

The following example demonstrates how to set vehicleStopover: true on an intermediate waypoint in a complete POST request:

curl -X POST -d '{
  "origin":{
    "location":{
      "latLng":{
        "latitude": 37.419734,
        "longitude": -122.0827784
      }
    }
  },
  "destination":{
    "location":{
      "latLng":{
        "latitude": 37.417670,
        "longitude": -122.079595
      }
    }
  },
  "intermediates": [
    {
      "location":{
        "latLng":{
          "latitude": 37.419734,
          "longitude": -122.0807784
        }
      },
      "vehicleStopover": true
    }
  ],
  "travelMode": "DRIVE"
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY' \
-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.legs' \
'https://routes.googleapis.com/directions/v2:computeRoutes'

For more information about waypoint types and options, see Waypoint types and options.