Class Route
A road-following journey returned by a RouteService: the geometry that
traces the actual roads, how long it is, how long it takes, and the legs
and turn-by-turn steps that make it up.
Drawing it is one call -- unlike handing raw endpoints to a
Polyline, which would just join them with a straight line:
map.addPolyline(route.toPolyline());
map.fitBounds(route.getBounds(), 40);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe smallestMapBoundscontaining the whole route, ornullwhen the route has no geometry.doubleThe total length of the route in meters.doubleThe total estimated travel time in seconds.getLegs()The unmodifiableRouteLegs, one per pair of consecutive stops.The unmodifiable road geometry asLatLngvertices, dense enough to trace the shape of the roads travelled.A short human readable description, typically the major roads used.Builds aPolylinetracing this route, ready to hand toMapSurface.addPolyline(Polyline).toString()Returns a string representation of the object.
-
Constructor Details
-
Route
Creates a route. Called by
RouteServiceimplementations.Parameters
-
-
Method Details
-
getPoints
-
getLegs
-
getDistanceMeters
public double getDistanceMeters()The total length of the route in meters. -
getDurationSeconds
public double getDurationSeconds()The total estimated travel time in seconds. -
getSummary
A short human readable description, typically the major roads used. -
getBounds
The smallest
MapBoundscontaining the whole route, ornullwhen the route has no geometry. Pass it toMapSurface.fitBounds(MapBounds, int)to frame the journey.Antimeridian caveat:
MapBoundsis an axis-aligned box whose longitudes always run west to east, so it cannot describe a span that wraps past 180 degrees. A route crossing the antimeridian -- Fiji to Samoa, say -- therefore reports a box that runs the long way round the globe, and framing it zooms out to most of the world instead of the Pacific. This is a limitation of the bounds type rather than of routing, and it affects anything built fromMapBounds.fromCoordinates(List); frame such a route from its own points instead of from these bounds. -
toPolyline
Builds aPolylinetracing this route, ready to hand toMapSurface.addPolyline(Polyline). Each call returns a fresh polyline, so styling one does not affect another. -
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())
-