The Routes API is currently in Preview (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the Google Maps Platform Service Specific Terms. For more information, see the launch stage descriptions.

Use location modifiers

Locations may include modifiers to change how routes are calculated.

Using the heading property

To define a waypoint, you specify the geographic Location (REST) or Location (gRPC) as a latitude and longitude pair.

Location also lets you specify the direction you want the vehicle to head when it arrives at each waypoint. You can use this feature to ensures that the vehicle arrives on the same side of the road as the consumer waiting to be picked up. When you don't specify a heading, the vehicle can arrive on the wrong side of the road.

Heading values are whole numbers that align with the compass directions, and therefore range from zero to 359. For example, a value of 0 indicates a heading direction of due North.

The following example demonstrates how to set a heading for a waypoint.

{
  "origin":{
    "location":{
      "latLng":{
        "latitude": 37.419734,
        "longitude": -122.0827784
      },
      "heading": 127
    }
  },
  ...

Using the side of the road property

You represent a location by creating a Waypoint (REST) or Waypoint (gRPC) object. A location defined by a latitude and longitude pair can correspond to a specific side of a road. However, to support route optimization, a route can still set a stopover to be on the opposite side of the road from the specified location.

Waypoints support the sideOfRoad property, which indicates that the waypoint location has a preference for the vehicle to stop at the same side of road as specified by the location.

Specify that the route uses the preferred side of the road by setting the Waypoint sideOfRoad property to true. The route then passes through the location so that the vehicle can stop at the side of road that the location is biased towards.

The following example shows how to set sideOfRoad for a waypoint.

{
  "origin":{
    "location":{
      "latLng":{
        "latitude": 37.419734,
        "longitude": -122.0827784
      }
    },
    "sideOfRoad": true
  },
  ...