Route calculations (including rerouting) return the route that takes the
least amount of time to navigate as the *default best route*. But
you can change the routing strategy so that the shorter of the route
alternatives is returned instead.

The term *shorter* means the route that is the shortest among optimal route
based on our default cost model. The shorter route might not be the *absolute*
shortest route, since that option might be a poor alternative. For example, if
the absolute shortest route is 10 km and takes 50 minutes to navigate and
another route is 15 km, but only takes 20 minutes to navigate, the second choice
is optimal, because spending 30 mins to reduce five km isn't a good trade-off.

Once you set the routing strategy for a trip, it won't change until the trip
completes. To change the routing strategy for an existing trip, you must clear
the destinations and reset them again with the new routing strategy.

> [!NOTE]
> **Note:** The feature mentioned above is intended for Rideshare providers that operate in regulated markets (such as Europe), who are often required by law to price their services based on the same principles as traditional taxis---which charge based primarily on the distance traveled.

## Getting route details

To determine which route strategy is the optimal choice for a given waypoint,
call `getRouteInfoForDestination()` to get route details for both the default
best route and the absolute shorter route. Details include the duration and the
distance to a destination waypoint.

These details come from
[`GMSNavigationRouteInfo`](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSNavigationRouteInfo.md.txt)
in the callback.

### Example

The following code example demonstrates how to get route details for each of the
two routing strategies.

<br />

### Swift

<br />

```swift
let routingOptions = GMSNavigationRoutingOptions()
navigator?.getRouteInfoForDestination(destination,
                                      routingOptions: routingOptions) { routeInfo in
  ...
}
```

<br />

### Objective-C

<br />

```objective-c
GMSNavigationRoutingOptions *routingOptions =
    [[GMSNavigationRoutingOptions alloc] init];
[navigator getRouteInfoForDestination:destination
                   withRoutingOptions:routingOptions
                             callback:^(GMSNavigationRouteInfo *routeInfo){...}];
```

<br />

<br />

## Setting the routing strategy

You can configure the routing strategy by using `GMSNavigationRoutingOptions`,
and setting the `routingStrategy` when calling `setDestinations()`.

`routingStrategy` takes one of the following enumeration values:

| Enumeration Value | Description |
|---|---|
| GMSNavigationRoutingStrategyDefaultBest | Ranks routes by the Navigation SDK default cost model. This is the default routing strategy. |
| GMSNavigationRoutingStrategyShorter | Ranks routes by distance. The highest ranking route is the shortest of those returned. |

> [!WARNING]
> **Warning:** This feature is incompatible with the [Hiding Alternate Route](https://developers.google.com/maps/documentation/navigation/ios-sdk/controls.md.txt#hiding_alternate_routes) feature. Using these two features at the same time will produce unexpected results.

### Example

The following code example demonstrates how to set the shorter route routing
strategy.

<br />

### Swift

<br />

```swift
let routingOptions = GMSNavigationRoutingOptions(routingStrategy: .shorter)
navigator?.setDestinations(destinations,
                           routingOptions: routingOptions) { routeStatus in
  ...
}
```

<br />

### Objective-C

<br />

```objective-c
GMSNavigationRoutingOptions *routingOptions = [[GMSNavigationRoutingOptions alloc] initWithRoutingStrategy:GMSNavigationRoutingStrategyShorter];
[navigator setDestinations:destinations
            routingOptions:routingOptions
                  callback:^(GMSRouteStatus routeStatus){...}];

```

<br />

<br />

## Routes that include ferries

By default, the Navigation SDK for iOS excludes routes that include ferries. If you prefer to
include ferry options as part of your routes, you can adjust this routing
preference to expose the trip to ferry segments by setting `avoidsFerries` to
`false`.

### Example

<br />

### Swift

<br />

```swift
self.mapView.navigator?.avoidsFerries = false
```

<br />

### Objective-C

<br />

```objective-c
self.mapView.navigator.avoidsFerries = NO
```

<br />

<br />

## The route callout format

Under the shorter route routing strategy, callouts along the route display
distance details. But you can use the ETA callouts instead.

### Configuring the route callout format

You can change the route callout format by setting `routeCalloutFormat` in
`GMSMapView`. `routeCalloutFormat` takes one of the following enumeration
values:

| Enumeration Value | Description |
|---|---|
| GMSNavigationRouteCalloutFormatDefault | Displays time remaining when using the default best route routing strategy. Displays distance remaining when using the shorter route routing strategy |
| GMSNavigationRouteCalloutFormatTime | Displays time remaining. |
| GMSNavigationRouteCalloutFormatDistance | DDisplays distance remaining. |

#### Example

The following code example demonstrates how to configure the route callout
format.

<br />

### Swift

<br />

```swift
self.mapView.routeCalloutFormat = .time
```

<br />

### Objective-C

<br />

```objective-c
_mapView.routeCalloutFormat = GMSNavigationRouteCalloutFormatTime;
```

<br />

<br />