Class RouteRequest
java.lang.Object
com.codename1.maps.routing.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)
.setOriginLabel("Home").setDestinationLabel("Office")
.addWaypoint(daycare, "Daycare")
.setTravelMode(TravelMode.DRIVING)
.setAlternatives(true);
-
Constructor Summary
ConstructorsConstructorDescriptionRouteRequest(LatLng origin, LatLng destination) Creates a request for the direct journey fromorigintodestination. -
Method Summary
Modifier and TypeMethodDescriptionaddWaypoint(LatLng waypoint) Adds an intermediate point the route must pass through, in visiting order.addWaypoint(LatLng waypoint, String label) Adds a stop with a display name forRouting.showRoute(MapSurface, LatLng, LatLng).Where the journey ends.The optional name displayed at the destination.Where the journey starts.The optional name displayed at the journey's start.How the traveller moves;TravelMode.DRIVINGunless changed.Optional display names in the same order asgetWaypoints().The unmodifiable intermediate points (LatLng) in visiting order; empty for a direct journey.booleanWhether the service may return more than one route.booleanWhetherRouting.showRoute(MapSurface, LatLng, LatLng)adds labeled start, stop and destination markers.booleanisSteps()Whether turn-by-turn steps are requested; true unless changed.setAlternatives(boolean alternatives) Asks the service for alternative routes in addition to the best one.setDestinationLabel(String label) Names the destination marker.setOriginLabel(String label) Names the start marker.setShowStopLabels(boolean show) Enables or disables the labeled markers added byRouting.showRoute(MapSurface, LatLng, LatLng).setSteps(boolean steps) Requests (or suppresses) turn-by-turnRouteSteps.setTravelMode(TravelMode travelMode) Sets how the traveller moves.toString()Returns a string representation of the object.
-
Constructor Details
-
RouteRequest
-
-
Method Details
-
getOrigin
Where the journey starts. -
getDestination
Where the journey ends. -
addWaypoint
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
Adds a stop with a display name forRouting.showRoute(MapSurface, LatLng, LatLng). Anullwaypoint is ignored; a blank name uses the numbered default label. -
getWaypoints
The unmodifiable intermediate points (LatLng) in visiting order; empty for a direct journey. Add to it throughaddWaypoint(LatLng), which drops anull; the view being unmodifiable is what stops anything else being slipped in behind it for aRouteServiceto choke on. -
getWaypointLabels
Optional display names in the same order asgetWaypoints(). Entries may benull;Routing.showRoute(MapSurface, LatLng, LatLng)then uses "Stop 1", "Stop 2", etc. -
getOriginLabel
The optional name displayed at the journey's start. -
setOriginLabel
Names the start marker. Blank ornulluses "Start". This is display text only: it does not change the coordinates sent to the service. -
getDestinationLabel
The optional name displayed at the destination. -
setDestinationLabel
Names the destination marker. Blank ornulluses "Destination". -
isShowStopLabels
public boolean isShowStopLabels()WhetherRouting.showRoute(MapSurface, LatLng, LatLng)adds labeled start, stop and destination markers. True by default.Routing.findRoute(LatLng, LatLng, RouteCallback)only returns route data. -
setShowStopLabels
Enables or disables the labeled markers added byRouting.showRoute(MapSurface, LatLng, LatLng). -
getTravelMode
How the traveller moves;TravelMode.DRIVINGunless changed. -
setTravelMode
Sets how the traveller moves. Anullmode restoresTravelMode.DRIVING. -
isAlternatives
public boolean isAlternatives()Whether the service may return more than one route. -
setAlternatives
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
Requests (or suppresses) turn-by-turnRouteSteps. Turn them off when you only need the line on the map -- the response is much smaller. -
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())
-