<br />

**European Economic Area (EEA) developers**

> [!NOTE]
> If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](https://developers.google.com/maps/comms/eea/faq.md.txt).

<br />

> [!WARNING]
> This product or feature is Experimental (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](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage descriptions](https://developers.google.com/maps/launch-stages.md.txt).

<br />

Compute Routes can return driving routes optimized for a shorter travel distance
when you enable shorter distance routes.

When you request a shorter distance route, the service returns the following:

- The default route, which is a route optimized primarily for ETA.
- A shorter route optimized for minimizing travel distance across the entire trip.

> [!NOTE]
> **Note:** The shorter distance route returned by Compute Routes is optimized for a shorter distance traveled across the trip.

## What it is and why to use it

A shorter distance route prioritizes distance over driving comfort or speed. For
example, it may prefer local roads instead of highways, take dirt roads, or cut
through parking lots. It does not return any maneuvers that Google Maps knows to
be illegal.

## Request a shorter distance route

Your request must meet the following criteria:

- Set `travelMode` to `DRIVE`, `BICYCLE`, or `TWO_WHEELER`.
- Set `requestedReferenceRoutes` to `SHORTER_DISTANCE`.
- Set a response field mask to return the response properties associated with a shorter-distance route:
  - `routes.routeLabels`: Identifies each route as either `DEFAULT_ROUTE`, `SHORTER_DISTANCE`, or `DEFAULT_ROUTE_ALTERNATE`.
  - `routes.routeToken`: A route token that you can pass to the [Navigation
    SDK](https://developers.google.com/maps/documentation/navigation) to retrieve a custom route.
- **Don't include** any `Via` intermediate waypoints.
- **Don't include** the `optimizeWaypointOrder` parameter.
- *Optional* : Set a response field mask to return the following properties associated with both the default and shorter-distance route:
  - `routes.distanceMeters`: Returns the distance of the route.
  - `routes.duration`: Returns the duration of the route.

> [!NOTE]
> **Note:** Any request that doesn't meet these criteria returns an error.

For reference information, see
[ReferenceRoute](https://developers.google.com/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes.md.txt#referenceroute)
and
[RouteLabel](https://developers.google.com/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes.md.txt#routelabel).

## Example request: Shorter distance route

The following code shows a request for a shorter distance route. In this
example, you use the response field mask to return fields associated with both
the default and shorter-distance route with the following field masks:

- `routes.distanceMeters`
- `routes.duration`

```json
curl -X POST -H 'content-type: application/json' -d '{
  "origin": {
    "location": {
      "latLng": {
        "latitude": 41.76904801292959,
        "longitude": -72.67374935684933
      }
    }
  },
  "destination": {
    "location": {
      "latLng": {
        "latitude": 41.823042361105024,
        "longitude": -71.40933143059424
      }
    }
  },
  "travelMode":"DRIVE",
  "routingPreference":"TRAFFIC_AWARE",
  "requestedReferenceRoutes": ["SHORTER_DISTANCE"],
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY \
-H 'X-Goog-FieldMask: routes.distanceMeters,routes.duration,routes.routeLabels,routes.routeToken' \
'https://routes.googleapis.com/directions/v2:computeRoutes'
```

### Example shorter route response

```json
{
  "routes": [
    {
      "distanceMeters": 138943,
      "duration": "5373s",
      "routeToken": "CrsCCs4BMssBGq8BCkECFg9eN0MowaEI3Y4KqMEhzOTe-Qi3947kBsb8koUBkvX0oAKJ_b1S4uPoUvzzAYfXA92t_RXyw98Up6qKAaRaABIsNBjodKMdkMYAPMLMIajCwj-zsIxpgyBxOLYjdBBeKgkO3tFDDrj4YgZB5bMaFQAATME12CCCA9MEF-kO2wL_____DyoLHgAOAHN3DggAQQEyBAUBAQM9VDgqPkV88FI_SNO81oLq4JnjYyIXcklWWFo2cjhDZmltdk9NUDQ3aU1nUU0QBRpPCk0KGAoNCgIIAREAAAAAAIBmQBF56SYxqDm4QBISCAAQAxAGEBMQEhgCQgQaAggFIhsKF3JJVlhaLWFOQnZpbXZPTVA0N2lNZ1FNcAEoASIVAACBmRY1BjeCiUQewJGTrQ3DuHRp",
      "routeLabels": [
        "DEFAULT_ROUTE"
      ]
    },
    {
      "distanceMeters": 112610,
      "duration": "7165s",
      "routeToken": "CqgCCrsBMrgBGpwBCjYCFg1SN0MowaEI3Y4KjfqjF6Ls9BXc-QGiqCOpu7FDtfCXxSG2zLOGI_r4uQGc-we_nQ7MLAASLDQY6HSjHZDGg26EAFrPI5Q3NxvGA4ELazy3sLYqno_9eAFD2KxlCqAGQeWzGg4AAMQDGwyiAqwwKQggJCoLHgBsCQ8Acm0XWWcyAgQGPVQ4Kj5FfPBSP0jikPWC95WdhIwBIhdySVZYWjZHR0RiTzV2T01QOUpiQXlBTRAFGk8KTQoYCg0KAggCEQAAAAAAAFlAEU5iEFh5af1AEhIIABADEAYQExASGAJCBBoCCAUiGwoXcklWWFo3S09Cck81dk9NUDlKYkF5QU1wASgCIhUAAIGZFlj_CmMgGE6KGZcsE-tEywM",
      "routeLabels": [
        "SHORTER_DISTANCE"
      ]
    }
  ]
}
```

## Example request: Shorter distance and fuel efficient route

The following code shows a request for both a shorter distance route and a
fuel-efficient route.

\`

```json
 curl -X POST -d '{
"origin": {  "location": {  "latLng": {  "latitude": 41.76904801292959,
"longitude": -72.67374935684933  }  }  },  "destination": {  "location": {
"latLng": {  "latitude": 41.823042361105024,  "longitude": -71.40933143059424  }
 }  },  "travelMode":"DRIVE",  "routingPreference":"TRAFFIC_AWARE_OPTIMAL",
"requestedReferenceRoutes": ["SHORTER_DISTANCE", "FUEL_EFFICIENT"] }' 

-H 'Content-Type: application/json' 

-H 'X-Goog-Api-Key: YOUR_API_KEY' 

-H 'X-Goog-FieldMask:
routes.distanceMeters,routes.duration,routes.routeLabels,routes.routeToken' 

'https://routes.googleapis.com/directions/v2:computeRoutes'
```

<br />

### Example response: Shorter distance and Fuel-efficient route

In this case, the shorter distance and the most fuel-efficient route are the
same, so that route is returned and the `routeLabel` is included for both types
of route.

```json
{  "routes": [  {  "distanceMeters": 138943,  "duration": "5375s",
"routeToken":
"Cr8CCs4BMssBGq8BCkECFg9eN0MowaEI3Y4KqMEhzOTe-Qi3947kBsb8koUBkvX0oAKJ_b1S4uPoUvzzAYfXA92t_RXyw98Up6qKAaRaABIsNBjodKMdkMYAPMLMIajCwj-zsIxpgyBxOLYjdBBeKgkO3tFDDrj4YgZB5bMaFQAATME12CCCA9MEF-kO2wL_____DyoLHgAOAHN3DggAQQEyBAUBAQM9VDgqPkV88FI_SNO81oLq4JnjYyIXS1laWFo4T19JcWVCM2ZFUDFMbms4UXcQBRpTClEKGAoNCgIIAREAAAAAAIBmQBFOYhBYGTy4QBIWCAAQAxAGEBMQEhgCQgQaAggFSgIIASIbChdLWVpYWjlpV0g2ZUIzZkVQMUxuazhRd3ABKAEiFQAAgZkW4Df4cspNNJZWlMZuUUxLPQ",
 "routeLabels": [  "DEFAULT_ROUTE"  ]  },  {  "distanceMeters": 112610,
"duration": "7156s",  "routeToken":
"CqwCCrsBMrgBGpwBCjYCFg1SN0MowaEI3Y4KjfqjF6Ls9BXc-QGiqCOpu7FDtfCXxSG2zLOGI_r4uQGc-we_nQ7MLAASLDQY6HSjHZDGg26EAFrPI5Q3NxvGA4ELazy3sLYqno_9eAFD2KxlCqAGQeWzGg4AAMQDGwyiAqwwKQggJCoLHgBsCQ8Acm0XWWcyAgQGPVQ4Kj5FfPBSP0jikPWC95WdhIwBIhdLWVpYWi1UNklfT055OVlQczhhcWlRSRAFGlMKUQoYCg0KAggCEQAAAAAAAFlAEU5iEFh5af1AEhYIABADEAYQExASGAJCBBoCCAVKAggBIhsKF0tZWlhaNERXSF9PTnk5WVBzOGFxaVFJcAEoAiIVAACBmRaESp2EJS5nmwiEF8KH15_f",
 "routeLabels": [  "FUEL_EFFICIENT",  "SHORTER_DISTANCE"  ]  }  ] }
```

## Supported regions

Shorter distance routes are supported in all regions.

### Billing

Google Maps Platform does not charge extra for the use of an experimental
feature. You will be charged based on your usage of the API based on other
parameters you set.

[Learn more about billing](https://developers.google.com/maps/documentation/routes/usage-and-billing.md.txt)
for the Routes API.