Waypoint.Builder

public static final class Waypoint.Builder extends Object

A Builder class to construct instances of Waypoint.

Public Method Summary

Waypoint
build()
Creates and returns a new instance of Waypoint using the attributes from the Builder object.
Waypoint.Builder
setLatLng(double latitude, double longitude)
Sets a latitude/longitude pair to create the LatLng position used to build new Waypoint instances.
Waypoint.Builder
setPlaceIdString(String placeIdString)
Sets the ID of a place used to build new Waypoint instances.
Waypoint.Builder
setPreferSameSideOfRoad(boolean preferSameSideOfRoad)
Sets whether it is preferred to route the driver to the same side of the road.
Waypoint.Builder
setPreferredHeading(int preferredHeading)
Sets an angle used to express the direction of traffic on the side of the road that the vehicle should arrive on.
Waypoint.Builder
setTitle(String title)
Sets the text to display in the notification tray for the waypoint.
Waypoint.Builder
setVehicleStopover(boolean vehicleStopover)
Enables the automatic relocation of the waypoint to a nearby place if its location is not suitable for a vehicle to make a stop.

Inherited Method Summary

Public Methods

public Waypoint build ()

Creates and returns a new instance of Waypoint using the attributes from the Builder object.

Returns
  • a new Waypoint instance.
Throws
IllegalStateException if neither a lat/lng position nor a placeIdString have been set.

public Waypoint.Builder setLatLng (double latitude, double longitude)

Sets a latitude/longitude pair to create the LatLng position used to build new Waypoint instances. It cannot be used together with a placeIdString.

Parameters
latitude the latitude at which to place the waypoint. This will be clamped to between -90 degrees and +90 degrees inclusive.
longitude the longitude at which to place the waypoint. This will be normalized to be within -180 degrees inclusive and +180 degrees exclusive.
Returns
  • the object upon which the method was called, with the updated lat/lng position.
Throws
IllegalArgumentException if a placeIdString has already been set.

public Waypoint.Builder setPlaceIdString (String placeIdString)

Sets the ID of a place used to build new Waypoint instances. It cannot be used together with a lat/lng position.

Parameters
placeIdString the ID of the place.
Returns
  • the object upon which the method was called, with the updated placeIdString.
Throws
IllegalArgumentException if a lat/lng position has already been set.
Waypoint.UnsupportedPlaceIdException if given an unsupported place ID.

public Waypoint.Builder setPreferSameSideOfRoad (boolean preferSameSideOfRoad)

Sets whether it is preferred to route the driver to the same side of the road. The route will arrive on the preferred side of the road unless there is a significant delay caused by a road closure or slow-moving traffic.

If setPreferredHeading(int) is called after this function, the value set here will not have any effect.

If this function is called after setPreferredHeading(int), then it will reset the preferredHeading.

Parameters
preferSameSideOfRoad the new value for the side of the road preference.
Returns
  • the object upon which the method was called, with the updated preferSameSideOfRoad.

public Waypoint.Builder setPreferredHeading (int preferredHeading)

Sets an angle used to express the direction of traffic on the side of the road that the vehicle should arrive on. Consequently, it is not useful for one-way streets.

If setPreferSameSideOfRoad(boolean) is called after this function, then the preferredHeading will be resetted.

If this function is called after setPreferSameSideOfRoad(boolean), then the preferSameSideOfRoad value set using that function will be ignored.

Parameters
preferredHeading the new preferred segment heading angle in degrees [0, 360], where 0 means North.
Returns
  • the object upon which the method was called, with the updated preferredHeading.
Throws
Waypoint.InvalidSegmentHeadingException if given an invalid segment heading.

public Waypoint.Builder setTitle (String title)

Sets the text to display in the notification tray for the waypoint.

Parameters
title a string representing the desired title.
Returns
  • the object upon which the method was called, with the updated title.

public Waypoint.Builder setVehicleStopover (boolean vehicleStopover)

Enables the automatic relocation of the waypoint to a nearby place if its location is not suitable for a vehicle to make a stop. Elevated areas, ferries, underground locations and areas of limited access will be relocated to a nearby safe location.

Note: In certain cases, particularly in metro areas, waypoints cannot be set within tunnels, even if vehicleStopover is set to false.

Parameters
vehicleStopover the new value for the vehicleStopover preference.
Returns
  • the object upon which the method was called, with the updated vehicleStopover.