public class DistanceMatrixApiRequest
extends java.lang.Object
PendingResult.Callback<T>
Constructor and Description |
---|
DistanceMatrixApiRequest(GeoApiContext context) |
Modifier and Type | Method and Description |
---|---|
DistanceMatrixApiRequest |
arrivalTime(org.joda.time.ReadableInstant arrivalTime)
Specifies the desired time of arrival for transit requests.
|
DistanceMatrixApiRequest |
avoid(DirectionsApi.RouteRestriction restriction)
Introduces restrictions to the route.
|
T |
await()
Performs the request synchronously.
|
T |
awaitIgnoreError()
Performs the request synchronously, ignoring exceptions while performing the request and errors
returned by the server.
|
void |
cancel()
Attempts to cancel the request.
|
A |
channel(java.lang.String channel)
A channel to pass with the request.
|
A |
custom(java.lang.String parameter,
java.lang.String value)
Custom parameter.
|
DistanceMatrixApiRequest |
departureTime(org.joda.time.ReadableInstant departureTime)
Specifies the desired time of departure.
|
DistanceMatrixApiRequest |
destinations(LatLng... points)
One or more latitude/longitude values to which to calculate distance and time.
|
DistanceMatrixApiRequest |
destinations(java.lang.String... destinations)
One or more addresses to which to calculate distance and time.
|
A |
language(java.lang.String language)
The language in which to return results.
|
DistanceMatrixApiRequest |
mode(TravelMode mode)
Specifies the mode of transport to use when calculating directions.
|
DistanceMatrixApiRequest |
origins(LatLng... points)
One or more latitude/longitude values from which to calculate distance and time.
|
DistanceMatrixApiRequest |
origins(java.lang.String... origins)
One or more addresses from which to calculate distance and time.
|
protected A |
param(java.lang.String key,
java.lang.String val) |
protected A |
param(java.lang.String key,
com.google.maps.internal.StringJoin.UrlValue val) |
protected java.util.Map<java.lang.String,java.lang.String> |
params() |
void |
setCallback(PendingResult.Callback<T> callback)
|
DistanceMatrixApiRequest |
trafficModel(TrafficModel trafficModel)
Specifies the assumptions to use when calculating time in traffic.
|
DistanceMatrixApiRequest |
transitModes(TransitMode... transitModes)
Specifies one or more preferred modes of transit.
|
DistanceMatrixApiRequest |
transitRoutingPreference(TransitRoutingPreference pref)
Specifies preferences for transit requests.
|
DistanceMatrixApiRequest |
units(Unit unit)
Specifies the unit system to use when expressing distance as text.
|
protected void |
validateRequest() |
public DistanceMatrixApiRequest(GeoApiContext context)
protected void validateRequest()
public DistanceMatrixApiRequest origins(java.lang.String... origins)
origins
- Strings to geocode and use as an origin point (e.g. "New York, NY")DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest origins(LatLng... points)
points
- The origin points.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest destinations(java.lang.String... destinations)
destinations
- Strings to geocode and use as a destination point (e.g. "Jersey City, NJ")DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest destinations(LatLng... points)
points
- The destination points.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest mode(TravelMode mode)
Note that Distance Matrix requests only support TravelMode.DRIVING
, TravelMode.WALKING
and TravelMode.BICYCLING
.
mode
- One of the travel modes supported by the Distance Matrix API.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest avoid(DirectionsApi.RouteRestriction restriction)
restriction
- One of DirectionsApi.RouteRestriction.TOLLS
, DirectionsApi.RouteRestriction.FERRIES
or
DirectionsApi.RouteRestriction.HIGHWAYS
.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest units(Unit unit)
unit
- One of Unit.METRIC
or Unit.IMPERIAL
.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest departureTime(org.joda.time.ReadableInstant departureTime)
The departure time may be specified in two cases:
Setting the parameter to null will remove it from the API request.
departureTime
- The time of departure.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest trafficModel(TrafficModel trafficModel)
trafficModel
- The traffic model to use in estimating time in traffic.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest arrivalTime(org.joda.time.ReadableInstant arrivalTime)
arrivalTime
- The preferred arrival time.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest transitModes(TransitMode... transitModes)
transitModes
- The preferred transit modes.DistanceMatrixApiRequest
for call chaining.public DistanceMatrixApiRequest transitRoutingPreference(TransitRoutingPreference pref)
pref
- The transit routing preference for this distance matrix.DistanceMatrixApiRequest
for call chaining.public final void setCallback(PendingResult.Callback<T> callback)
PendingResult
onResult
or onFailure
after the request has been
completed.setCallback
in interface PendingResult<T>
callback
- The callback to call on completion.public final T await() throws ApiException, java.lang.InterruptedException, java.io.IOException
PendingResult
await
in interface PendingResult<T>
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.public final T awaitIgnoreError()
PendingResult
awaitIgnoreError
in interface PendingResult<T>
public final void cancel()
PendingResult
cancel
in interface PendingResult<T>
protected A param(java.lang.String key, java.lang.String val)
protected A param(java.lang.String key, com.google.maps.internal.StringJoin.UrlValue val)
protected java.util.Map<java.lang.String,java.lang.String> params()
public final A language(java.lang.String language)
language
- The language code, e.g. "en-AU" or "es".public A channel(java.lang.String channel)
channel
- String to pass with the request for analytics.public A custom(java.lang.String parameter, java.lang.String value)
parameter
- The name of the custom parameter.value
- The value of the custom parameter.