This document describes how you can manage waypoint preferences for your app
by using two features:

- Side of the road routing preferences
- Stopover

## Set side of the road routing preference

![](https://developers.google.com/static/maps/documentation/navigation/ios-sdk/images/side_of_road.png)

By default, the Navigation SDK for iOS finds the quickest route to a
waypoint, however this doesn't guarantee that the user will arrive on the
desired side of the road, for example, the side of the road that a rideshare
driver's customer is waiting on. The **Side of the Road Routing Preference**
feature lets you ensure that the vehicle arrives on the correct side of the
road.

### How it works

You set the preference for arriving on a particular side of the road when you
create the waypoint for that stop. You can specify the preference in one of two
ways.

### Prefer the same side of the road

You provide the geographic coordinates of the waypoint, and then set a flag
[`preferSameSideOfRoad`](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSNavigationWaypoint.md.txt#prefersamesideofroad)
that indicates that you prefer to arrive on the same side of the road as the
waypoint---snapped to the nearest sidewalk.

```objective-c
(nullable instancetype)initWithLocation:(CLLocationCoordinate2D)location
                                  title:(NSString *)title
                   preferSameSideOfRoad:(BOOL)preferSameSideOfRoad;
```

> [!IMPORTANT]
> **Key Point:** In some situations, when the waypoint is snapped to the side of the nearest road, the nearest road might not be the right one. For example, it might be a road around the corner from a waiting rideshare customer. You can prevent this from occurring by using `preferredSegmentHeading` instead of `preferSameSideOfRoad` (see the next section for details).

### Set an arrival heading

You provide the geographic coordinates of the waypoint, and then provide an
arrival heading
[`preferredSegmentHeading`](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSNavigationWaypoint.md.txt#-initwithlocation:title:preferredsegmentheading:)
that matches the direction of traffic flow on the same side of the road as the
destination.

```objective-c
(nullable instancetype)initWithLocation:(CLLocationCoordinate2D)location
                                  title:(NSString *)title
                preferredSegmentHeading:(int32_t)preferredSegmentHeading;
```

The Navigation SDK chooses the road segment closest to the
waypoint---that has a lane direction that aligns (within +/- 55 degrees) with the
side of the road that the waypoint is on.

## Set stopover preference

In certain places, it's not possible for users to stop safely (for example,
elevated areas, ferries, underground locations, and other areas of limited
access). The **Stopover** feature relocates the waypoint to a nearby place if
its location is not suitable for a user to make a stop. When you set
`vehicleStopover` to `YES`, the waypoint is automatically relocated when
the route is calculated, if an alternate location is available.

### How it works

You set the preference for a stopover when creating the waypoint for that stop.
To do this, set the preference for a stopover on a
`GMSNavigationMutableWaypoint` as shown in the following example:

### Swift


```swift
let location = CLLocationCoordinate2D(latitude: 47.67, longitude: -122.20)
let waypoint = GMSNavigationMutableWaypoint(location: location, title: "waypoint from location")!
waypoint.vehicleStopover = true
mapView.navigator?.setDestinations([waypoint], routingOptions: routingOptions, callback: {...})
```

<br />

### Objective-C


```objective-c
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(47.67, -122.20);
GMSNavigationMutableWaypoint *waypoint =
    [[GMSNavigationMutableWaypoint alloc] initWithLocation:location
                                                     title:@"waypoint from location"];
waypoint.vehicleStopover = YES;
[_mapView.navigator setDestinations:@[waypoint1]
                     routingOptions:routingOptions
                           callback:^(GMSRouteStatus routeStatus){...}];
```

<br />