# Class RouteRequest

java.lang.Object
com.codename1.maps.routing.RouteRequest

public final class RouteRequest extends Object

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);

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RouteRequest(LatLng origin, LatLng destination)`
  Creates a request for the direct journey from `origin` to `destination`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `RouteRequest`
  `addWaypoint(LatLng waypoint)`
  Adds an intermediate point the route must pass through, in visiting order.
  `LatLng`
  `getDestination()`
  Where the journey ends.
  `LatLng`
  `getOrigin()`
  Where the journey starts.
  `TravelMode`
  `getTravelMode()`
  How the traveller moves; `TravelMode.DRIVING` unless changed.
  `List`
  `getWaypoints()`
  The unmodifiable intermediate points (`LatLng`) in visiting order; empty for a direct journey.
  `boolean`
  `isAlternatives()`
  Whether the service may return more than one route.
  `boolean`
  `isSteps()`
  Whether turn-by-turn steps are requested; true unless changed.
  `RouteRequest`
  `setAlternatives(boolean alternatives)`
  Asks the service for alternative routes in addition to the best one.
  `RouteRequest`
  `setSteps(boolean steps)`
  Requests (or suppresses) turn-by-turn `RouteStep`s.
  `RouteRequest`
  `setTravelMode(TravelMode travelMode)`
  Sets how the traveller moves.
  `String`
  `toString()`
  Returns a string representation of the object.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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 `RouteStep`s. 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())
    Overrides:
      `toString` in class `Object`