类 DistanceMatrixApiRequest
java.lang.Object
ai.nextbillion.maps.DistanceMatrixApiRequest
- 所有已实现的接口:
PendingResult<DistanceMatrix>
public class DistanceMatrixApiRequest
extends java.lang.Object
A request to the Distance Matrix API.
-
嵌套类概要
-
构造器概要
构造器 构造器 说明 DistanceMatrixApiRequest(GeoApiContext context) -
方法概要
修饰符和类型 方法 说明 DistanceMatrixApiRequestarrivalTime(java.time.Instant arrivalTime)Specifies the desired time of arrival for transit requests.DistanceMatrixApiRequestavoid(DirectionsApi.RouteRestriction restriction)Introduces restrictions to the route.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. channel is used by Google Maps API for Work users to be able to track usage across different applications with the same clientID.DistanceMatrixApiRequestcontext(java.lang.String context)Acustom(java.lang.String parameter, java.lang.String value)Custom parameter.DistanceMatrixApiRequestdepartureTime(java.time.Instant departureTime)Specifies the desired time of departure.DistanceMatrixApiRequestdestinations(LatLng... points)One or more latitude/longitude values to which to calculate distance and time.DistanceMatrixApiRequestdestinations(java.lang.String... destinations)One or more addresses to which to calculate distance and time.Alanguage(java.lang.String language)The language in which to return results.DistanceMatrixApiRequestmode(TravelMode mode)Specifies the mode of transport to use when calculating directions.DistanceMatrixApiRequestorigins(LatLng... points)One or more latitude/longitude values from which to calculate distance and time.DistanceMatrixApiRequestorigins(java.lang.String... origins)One or more addresses from which to calculate distance and time.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()voidsetCallback(PendingResult.Callback<T> callback)DistanceMatrixApiRequesttrafficModel(TrafficModel trafficModel)Specifies the assumptions to use when calculating time in traffic.DistanceMatrixApiRequesttransitModes(TransitMode... transitModes)Specifies one or more preferred modes of transit.DistanceMatrixApiRequesttransitRoutingPreference(TransitRoutingPreference pref)Specifies preferences for transit requests.DistanceMatrixApiRequestunits(Unit unit)Specifies the unit system to use when expressing distance as text.protected voidvalidateRequest()
-
构造器详细资料
-
方法详细资料
-
validateRequest
protected void validateRequest() -
origins
One or more addresses from which to calculate distance and time. The service will geocode the strings and convert them to latitude/longitude coordinates to calculate directions.- 参数:
origins- Strings to geocode and use as an origin point (e.g. "New York, NY")- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
origins
One or more latitude/longitude values from which to calculate distance and time.- 参数:
points- The origin points.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
destinations
One or more addresses to which to calculate distance and time. The service will geocode the strings and convert them to latitude/longitude coordinates to calculate directions.- 参数:
destinations- Strings to geocode and use as a destination point (e.g. "Jersey City, NJ")- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
destinations
One or more latitude/longitude values to which to calculate distance and time.- 参数:
points- The destination points.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
mode
Specifies the mode of transport to use when calculating directions.Note that Distance Matrix requests only support
TravelMode.DRIVING,TravelMode.WALKINGandTravelMode.BICYCLING.- 参数:
mode- One of the travel modes supported by the Distance Matrix API.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
avoid
Introduces restrictions to the route. Only one restriction can be specified.- 参数:
restriction- One ofDirectionsApi.RouteRestriction.TOLLS,DirectionsApi.RouteRestriction.FERRIESorDirectionsApi.RouteRestriction.HIGHWAYS.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
units
Specifies the unit system to use when expressing distance as text. Distance Matrix results contain text within distance fields to indicate the distance of the calculated route.- 参数:
unit- One ofUnit.METRICorUnit.IMPERIAL.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining. - 另请参阅:
- Unit systems in the Distance Matrix API
-
departureTime
Specifies the desired time of departure.The departure time may be specified in two cases:
- For requests where the travel mode is transit: You can optionally specify one of departure_time or arrival_time. If neither time is specified, the departure_time defaults to now. (That is, the departure time defaults to the current time.)
- For requests where the travel mode is driving: Google Maps API for Work customers can specify the departure_time to receive trip duration considering current traffic conditions. The departure_time must be set to within a few minutes of the current time.
Setting the parameter to null will remove it from the API request.
- 参数:
departureTime- The time of departure.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
trafficModel
Specifies the assumptions to use when calculating time in traffic. This parameter may only be specified when the travel mode is driving and the request includes a departure_time.- 参数:
trafficModel- The traffic model to use in estimating time in traffic.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
arrivalTime
Specifies the desired time of arrival for transit requests. You can specify either departure_time or arrival_time, but not both.- 参数:
arrivalTime- The preferred arrival time.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
transitModes
Specifies one or more preferred modes of transit. This parameter may only be specified for requests where the mode is transit.- 参数:
transitModes- The preferred transit modes.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
transitRoutingPreference
Specifies preferences for transit requests. Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API.- 参数:
pref- The transit routing preference for this distance matrix.- 返回:
- Returns this
DistanceMatrixApiRequestfor call chaining.
-
context
-
setCallback
从接口复制的说明:PendingResultPerforms the request asynchronously, callingonResultoronFailureafter the request has been completed.- 指定者:
setCallback在接口中PendingResult<T>- 参数:
callback- The callback to call on completion.
-
await
从接口复制的说明:PendingResultPerforms the request synchronously.- 指定者:
await在接口中PendingResult<T>- 返回:
- The result.
- 抛出:
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()从接口复制的说明:PendingResultPerforms the request synchronously, ignoring exceptions while performing the request and errors returned by the server.- 指定者:
awaitIgnoreError在接口中PendingResult<T>- 返回:
- The result, or null if there was any error or exception ignored.
-
cancel
public final void cancel()从接口复制的说明:PendingResultAttempts to cancel the request.- 指定者:
cancel在接口中PendingResult<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.- 参数:
language- The language code, e.g. "en-AU" or "es".- 返回:
- Returns the request for call chaining.
- 另请参阅:
- 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.- 参数:
channel- String to pass with the request for analytics.- 返回:
- Returns the request for call chaining.
-
custom
public A custom(java.lang.String parameter, java.lang.String value)Custom parameter. For advanced usage only.- 参数:
parameter- The name of the custom parameter.value- The value of the custom parameter.- 返回:
- Returns the request for call chaining.
-