Package ai.nextbillion.maps
Class DirectionsApiRequest
java.lang.Object
ai.nextbillion.maps.DirectionsApiRequest
- All Implemented Interfaces:
PendingResult<DirectionsResult>
public class DirectionsApiRequest
extends java.lang.Object
Request for the Directions API.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDirectionsApiRequest.WaypointNested classes/interfaces inherited from interface ai.nextbillion.maps.PendingResult
PendingResult.Callback<T> -
Field Summary
Fields Modifier and Type Field Description protected booleanoptimizeWaypointsprotected DirectionsApiRequest.Waypoint[]waypoints -
Constructor Summary
Constructors Constructor Description DirectionsApiRequest(GeoApiContext context) -
Method Summary
Modifier and Type Method Description DirectionsApiRequestalternatives(boolean alternateRoutes)If set to true, specifies that the Directions service may provide more than one route alternative in the response.DirectionsApiRequestarrivalTime(java.time.Instant time)Set the arrival time for a Transit directions request.DirectionsApiRequestavoid(DirectionsApi.RouteRestriction... restrictions)Indicates that the calculated route(s) should avoid the indicated features.Tawait()Performs the request synchronously.TawaitIgnoreError()Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.voidcancel()Attempts to cancel the request.Achannel(java.lang.String channel)A channel to pass with the request.Acustom(java.lang.String parameter, java.lang.String value)Custom parameter.DirectionsApiRequestdepartureTime(java.time.Instant time)Set the departure time for a transit or driving directions request.DirectionsApiRequestdepartureTimeNow()Set the departure time for a transit or driving directions request as the current time.DirectionsApiRequestdestination(LatLng destination)The destination, as a latitude/longitude location.DirectionsApiRequestdestinationPlaceId(java.lang.String destinationPlaceId)The Place ID value from which you wish to calculate directions.Alanguage(java.lang.String language)The language in which to return results.DirectionsApiRequestmode(TravelMode mode)Specifies the mode of transport to use when calculating directions.DirectionsApiRequestoptimizeWaypoints(boolean optimize)Allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order.DirectionsApiRequestorigin(LatLng origin)The origin, as a latitude/longitude location.DirectionsApiRequestoriginPlaceId(java.lang.String originPlaceId)The Place ID value from which you wish to calculate directions.protected Aparam(java.lang.String key, int val)protected Aparam(java.lang.String key, StringJoin.UrlValue val)protected Aparam(java.lang.String key, java.lang.String val)protected AparamAddToList(java.lang.String key, StringJoin.UrlValue val)protected AparamAddToList(java.lang.String key, java.lang.String val)protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>params()java.lang.StringprefixPlaceId(java.lang.String placeId)DirectionsApiRequestregion(java.lang.String region)voidsetCallback(PendingResult.Callback<T> callback)DirectionsApiRequeststeps(boolean steps)DirectionsApiRequesttrafficModel(TrafficModel trafficModel)DirectionsApiRequesttransitMode(TransitMode... transitModes)DirectionsApiRequesttransitRoutingPreference(TransitRoutingPreference pref)DirectionsApiRequestunits(Unit units)Specifies the unit system to use when displaying results.protected voidvalidateRequest()DirectionsApiRequestwaypoints(DirectionsApiRequest.Waypoint... waypoints)Specifies a list of waypoints.DirectionsApiRequestwaypoints(LatLng... waypoints)The list of waypoints as latitude/longitude locations.DirectionsApiRequestwaypoints(java.lang.String... waypoints)Specifies the list of waypoints as String addresses.DirectionsApiRequestwaypointsFromPlaceIds(java.lang.String... waypoints)Specifies the list of waypoints as Plade ID Strings, prefixing them as required by the API.
-
Field Details
-
optimizeWaypoints
protected boolean optimizeWaypoints -
waypoints
-
-
Constructor Details
-
Method Details
-
validateRequest
protected void validateRequest() -
originPlaceId
The Place ID value from which you wish to calculate directions.- Parameters:
originPlaceId- The starting location Place ID for the Directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
destinationPlaceId
The Place ID value from which you wish to calculate directions.- Parameters:
destinationPlaceId- The ending location Place ID for the Directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
origin
The origin, as a latitude/longitude location.- Parameters:
origin- The starting location for the Directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
destination
The destination, as a latitude/longitude location.- Parameters:
destination- The ending location for the Directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
mode
Specifies the mode of transport to use when calculating directions. The mode defaults to driving if left unspecified. If you set the mode toTRANSITyou must also specify either adepartureTimeor anarrivalTime.- Parameters:
mode- The travel mode to request directions for.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
avoid
Indicates that the calculated route(s) should avoid the indicated features.- Parameters:
restrictions- one or more ofDirectionsApi.RouteRestriction.TOLLS,DirectionsApi.RouteRestriction.HIGHWAYS,DirectionsApi.RouteRestriction.FERRIES- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
units
Specifies the unit system to use when displaying results.- Parameters:
units- The preferred units for displaying distances.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
region
- Parameters:
region- The region code, specified as a ccTLD ("top-level domain") two-character value.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
arrivalTime
Set the arrival time for a Transit directions request.- Parameters:
time- The arrival time to calculate directions for.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
departureTime
Set the departure time for a transit or driving directions request. If both departure time and traffic model are not provided, then "now" is assumed. If traffic model is supplied, then departure time must be specified. Duration in traffic will only be returned if the departure time is specified.- Parameters:
time- The departure time to calculate directions for.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
departureTimeNow
Set the departure time for a transit or driving directions request as the current time. If traffic model is supplied, then departure time must be specified. Duration in traffic will only be returned if the departure time is specified.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
waypoints
Specifies a list of waypoints. Waypoints alter a route by routing it through the specified location(s). A waypoint is specified as either a latitude/longitude coordinate or as an address which will be geocoded. Waypoints are only supported for driving, walking and bicycling directions.For more information on waypoints, see Using Waypoints in Routes.
- Parameters:
waypoints- The waypoints to add to this directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
waypoints
Specifies the list of waypoints as String addresses. If any of the Strings are Place IDs, you must prefix them withplace_id:.- Parameters:
waypoints- The waypoints to add to this directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
waypointsFromPlaceIds
Specifies the list of waypoints as Plade ID Strings, prefixing them as required by the API.- Parameters:
waypoints- The waypoints to add to this directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
waypoints
The list of waypoints as latitude/longitude locations.- Parameters:
waypoints- The waypoints to add to this directions request.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
optimizeWaypoints
Allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order.- Parameters:
optimize- Whether to optimize waypoints.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
alternatives
If set to true, specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server.- Parameters:
alternateRoutes- whether to return alternate routes.- Returns:
- Returns this
DirectionsApiRequestfor call chaining.
-
steps
-
transitMode
-
transitRoutingPreference
-
trafficModel
-
prefixPlaceId
public java.lang.String prefixPlaceId(java.lang.String placeId) -
setCallback
Description copied from interface:PendingResultPerforms the request asynchronously, callingonResultoronFailureafter the request has been completed.- Specified by:
setCallbackin interfacePendingResult<T>- Parameters:
callback- The callback to call on completion.
-
await
Description copied from interface:PendingResultPerforms the request synchronously.- Specified by:
awaitin interfacePendingResult<T>- Returns:
- The result.
- Throws:
ApiException- Thrown if the API Returned result is an error.java.lang.InterruptedException- Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted.java.io.IOException- Thrown when an I/O exception of some sort has occurred.
-
awaitIgnoreError
public final T awaitIgnoreError()Description copied from interface:PendingResultPerforms the request synchronously, ignoring exceptions while performing the request and errors returned by the server.- Specified by:
awaitIgnoreErrorin interfacePendingResult<T>- Returns:
- The result, or null if there was any error or exception ignored.
-
cancel
public final void cancel()Description copied from interface:PendingResultAttempts to cancel the request.- Specified by:
cancelin interfacePendingResult<T>
-
param
protected A param(java.lang.String key, java.lang.String val) -
param
protected A param(java.lang.String key, int val) -
param
-
paramAddToList
protected A paramAddToList(java.lang.String key, java.lang.String val) -
paramAddToList
-
params
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> params() -
language
public final A language(java.lang.String language)The language in which to return results. Note that we often update supported languages so this list may not be exhaustive.- Parameters:
language- The language code, e.g. "en-AU" or "es".- Returns:
- Returns the request for call chaining.
- See Also:
- List of supported domain languages
-
channel
public A channel(java.lang.String channel)A channel to pass with the request. channel is used by Google Maps API for Work users to be able to track usage across different applications with the same clientID. See Premium Plan Usage Rates and Limits.- Parameters:
channel- String to pass with the request for analytics.- Returns:
- Returns the request for call chaining.
-
custom
public A custom(java.lang.String parameter, java.lang.String value)Custom parameter. For advanced usage only.- Parameters:
parameter- The name of the custom parameter.value- The value of the custom parameter.- Returns:
- Returns the request for call chaining.
-