public final class RouteRequest
- Object
- RouteRequest
Describes the journey to route: where it starts, where it ends, anything it must pass through on the way, and how the traveller moves.
The setters return this so a request reads as one expression:
RouteRequest req = new RouteRequest(home, office)
.addWaypoint(daycare)
.setTravelMode(TravelMode.DRIVING)
.setAlternatives(true);
Constructors
public RouteRequest(LatLng origin, LatLng destination) | Creates a request for the direct journey from origin to destination. |
Methods
public LatLng getOrigin() | Where the journey starts. |
public LatLng getDestination() | Where the journey ends. |
public RouteRequest addWaypoint(LatLng waypoint) | Adds an intermediate point the route must pass through, in visiting order. |
public List getWaypoints() | The unmodifiable intermediate points (LatLng) in visiting order; empty for a direct journey. |
public TravelMode getTravelMode() | How the traveller moves; TravelMode.DRIVING unless changed. |
public RouteRequest setTravelMode(TravelMode travelMode) | Sets how the traveller moves. |
public boolean isAlternatives() | Whether the service may return more than one route. |
public RouteRequest setAlternatives(boolean alternatives) | Asks the service for alternative routes in addition to the best one. |
public boolean isSteps() | Whether turn-by-turn steps are requested; true unless changed. |
public RouteRequest setSteps(boolean steps) | Requests (or suppresses) turn-by-turn RouteSteps. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Constructor details
RouteRequest
public RouteRequest(LatLng origin, LatLng destination)Creates a request for the direct journey from
origin to
destination.Method details
getOrigin
public LatLng getOrigin()Where the journey starts.
getDestination
public LatLng getDestination()Where the journey ends.
addWaypoint
public RouteRequest addWaypoint(LatLng waypoint)Adds an intermediate point the route must pass through, in visiting
order. Backends route through waypoints in the order added; none of
them reorder to optimize the trip.
getWaypoints
public List getWaypoints()The unmodifiable intermediate points (
LatLng) in visiting order;
empty for a direct journey. Add to it through addWaypoint(LatLng),
which drops a null; the view being unmodifiable is what stops anything
else being slipped in behind it for a RouteService to choke on.getTravelMode
public TravelMode getTravelMode()How the traveller moves;
TravelMode.DRIVING unless changed.setTravelMode
public RouteRequest setTravelMode(TravelMode travelMode)Sets how the traveller moves. A
null mode restores
TravelMode.DRIVING.isAlternatives
public boolean isAlternatives()Whether the service may return more than one route.
setAlternatives
public RouteRequest setAlternatives(boolean alternatives)Asks the service for alternative routes in addition to the best one.
Backends treat this as a hint – most return a single route when no
meaningfully different alternative exists.
isSteps
public boolean isSteps()Whether turn-by-turn steps are requested; true unless changed.
setSteps
public RouteRequest setSteps(boolean steps)Requests (or suppresses) turn-by-turn
RouteSteps. Turn them off when
you only need the line on the map – the response is much smaller.toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())