**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).

> [!NOTE]
> **Note:** Alternative routes are not supported by the Compute Route Matrix feature of the Routes API.

By default, the Routes API returns the *default* route, which is typically
the fastest route from the origin to the destination. When you request
*alternative* routes, the API returns up to three routes along with the default
route. Your customers can then choose a route that best fits their requirements.

## Considerations when requesting alternative routes

To request alternative routes, be aware of the following considerations:

- The response contains a maximum of three alternative routes. However,
  sometimes no alternative routes are available so the response only contains
  the default route.

- Because of the additional processing required to calculate alternative
  routes, requesting alternative routes might increase the response time of
  the API.

## Example alternative routes request

Set `computeAlternativeRoutes` to `true` to request alternative routes. The
following example shows how to request alternative routes in a
[computeRoutes](https://developers.google.com/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes.md.txt)
method (REST) request.

```json
curl -X POST -d '{
  "origin":{
    "location":{
      "latLng":{
        "latitude":42.340173523716736,
        "longitude":-71.05997968330408
      }
    }
  },
  "destination":{
    "location":{
      "latLng":{
        "latitude":42.075698891472804,
        "longitude": -72.59806562080408
      }
    }
  },
  "travelMode": "DRIVE",
  "routingPreference":"TRAFFIC_AWARE",
  "computeAlternativeRoutes": true
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY' \
-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.routeLabels' \
'https://routes.googleapis.com/directions/v2:computeRoutes'
```

In this example, you specify a field mask so that the response contains only the
`duration`, `distanceMeters,` and `routeLabels` properties for each route. Your
customer can then use that information to choose which route to take. For more
information, see [Choose what information to return](https://developers.google.com/maps/documentation/routes/choose_fields.md.txt).

## Example alternative routes response

In the response, use the `routeLabels` array property to identify reach
route:

- For the default route, the `routeLabels` property contains
  `DEFAULT_ROUTE`.

- For any alternate routes, the `routeLabels` property contains
  `DEFAULT_ROUTE_ALTERNATE`.

> [!NOTE]
> **Note:** You can also request an eco-friendly route by setting the `requestedReferenceRoutes` property to `FUEL_EFFICIENT` in the request. For the eco-friendly route, the `routeLabels` property contains `FUEL_EFFICIENT`. For more on eco-friendly routing, see [Get eco-friendly routes](https://developers.google.com/maps/documentation/routes/eco-routes.md.txt).

In this example, the response contains the default route and two alternative
routes. Notice that the values of the `duration` and `distanceMeters` properties
are different for each route:

```json
{
  "routes": [
    {
      "distanceMeters": 150322,
      "duration": "5309s",
      "routeLabels": [
        "DEFAULT_ROUTE"
      ]
    },
    {
      "distanceMeters": 157614,
      "duration": "6879s",
      "routeLabels": [
        "DEFAULT_ROUTE_ALTERNATE"
      ]
    },
    {
      "distanceMeters": 189311,
      "duration": "7376s",
      "routeLabels": [
        "DEFAULT_ROUTE_ALTERNATE"
      ]
    }
   ]
}
```

### Include polylines in the response

To make it easier for the user to select the route, add the
[polyline](https://developers.google.com/maps/documentation/routes/traffic_on_polylines.md.txt) for each route to the response. You can then
display each polyline on a map.

To add the polyline, include `routes.polyline` in the field mask:

```json
-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.routeLabels,routes.polyline'
```

The response then contains the polyline for each route:

```json
{
  "routes": [
    {
      "distanceMeters": 150322,
      "duration": "5309s",
      "polyline": {
        "encodedPolyline": "mrlaGtavpLPLBTm...PgA^qC"
      },
      "routeLabels": [
        "DEFAULT_ROUTE"
      ]
    },
    {
      "distanceMeters": 157614,
      "duration": "6879s",
      "polyline": {
        "encodedPolyline": "DmEd`@e@pCo@pCs@z...PgA^qC"
      },
      "routeLabels": [
        "DEFAULT_ROUTE_ALTERNATE"
      ]
    },
    {
      "distanceMeters": 189311,
      "duration": "7376s",
      "polyline": {
        "encodedPolyline": "FVLL|Af@HPAV...PgA^qC"
      },
      "routeLabels": [
        "DEFAULT_ROUTE_ALTERNATE"
      ]
    }
   ]
}
```