By default, the Navigation SDK for Android finds the quickest route to a waypoint, however this doesn't guarantee that the vehicle will arrive on the side of the road that the consumer is waiting on or that the arrival place is safe for the driver to stop at. This guide describes two feature you can use for these situations:
- Side of the road routing preference
- Stopover feature
Side of the route routing preference
This feature allows you to ensure that the vehicle arrives on the correct side of the road. 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, or provide an arrival heading.
Prefer the same side of the road
You provide the geographic coordinates of the waypoint, and then set a flag
(setPreferSameSideOfRoad
) that indicates that you prefer to arrive on the same
side of the road as the waypoint—snapped to the nearest sidewalk.
Waypoint waypoint =
Waypoint.builder()
.setLatLng(latitude, longitude)
.setTitle("Somewhere in Sydney")
.setPreferSameSideOfRoad(true)
.build()
Set an arrival heading
You provide the geographic coordinates of the waypoint, and then provide an
arrival heading (setPreferredHeading
) that matches the direction of
traffic flow on the same side of the road as the waiting consumer.
Waypoint waypoint =
Waypoint.builder()
.setLatLng(latitude, longitude)
.setTitle("Somewhere in Sydney")
.setPreferredHeading(preferredHeading)
.build()
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 drivers 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 vehicle to make a stop. When you set
setVehicleStopover
to true
, 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, specify the setVehicleStopover
preference as shown in the
following example:
Waypoint waypoint =
Waypoint.builder()
.setLatLng(latitude, longitude)
.setTitle("Somewhere in Sydney")
.setVehicleStopover(true)
.build()