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)
        .setOriginLabel("Home").setDestinationLabel("Office")
        .addWaypoint(daycare, "Daycare")
        .setTravelMode(TravelMode.DRIVING)
        .setAlternatives(true);
  • 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.
    • addWaypoint

      public RouteRequest addWaypoint(LatLng waypoint, String label)
      Adds a stop with a display name for Routing.showRoute(MapSurface, LatLng, LatLng). A null waypoint is ignored; a blank name uses the numbered default label.
    • 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.
    • getWaypointLabels

      public List getWaypointLabels()
      Optional display names in the same order as getWaypoints(). Entries may be null; Routing.showRoute(MapSurface, LatLng, LatLng) then uses "Stop 1", "Stop 2", etc.
    • getOriginLabel

      public String getOriginLabel()
      The optional name displayed at the journey's start.
    • setOriginLabel

      public RouteRequest setOriginLabel(String label)
      Names the start marker. Blank or null uses "Start". This is display text only: it does not change the coordinates sent to the service.
    • getDestinationLabel

      public String getDestinationLabel()
      The optional name displayed at the destination.
    • setDestinationLabel

      public RouteRequest setDestinationLabel(String label)
      Names the destination marker. Blank or null uses "Destination".
    • isShowStopLabels

      public boolean isShowStopLabels()
      Whether Routing.showRoute(MapSurface, LatLng, LatLng) adds labeled start, stop and destination markers. True by default. Routing.findRoute(LatLng, LatLng, RouteCallback) only returns route data.
    • setShowStopLabels

      public RouteRequest setShowStopLabels(boolean show)
      Enables or disables the labeled markers added by Routing.showRoute(MapSurface, LatLng, LatLng).
    • 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())
      Overrides:
      toString in class Object