类 DirectionsApiRequest

java.lang.Object
ai.nextbillion.maps.DirectionsApiRequest
所有已实现的接口:
PendingResult<DirectionsResult>

public class DirectionsApiRequest
extends java.lang.Object
Request for the Directions API.
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • validateRequest

      protected void validateRequest()
    • originPlaceId

      public DirectionsApiRequest originPlaceId​(java.lang.String originPlaceId)
      The Place ID value from which you wish to calculate directions.
      参数:
      originPlaceId - The starting location Place ID for the Directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • destinationPlaceId

      public DirectionsApiRequest destinationPlaceId​(java.lang.String destinationPlaceId)
      The Place ID value from which you wish to calculate directions.
      参数:
      destinationPlaceId - The ending location Place ID for the Directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • origin

      public DirectionsApiRequest origin​(LatLng origin)
      The origin, as a latitude/longitude location.
      参数:
      origin - The starting location for the Directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • destination

      public DirectionsApiRequest destination​(LatLng destination)
      The destination, as a latitude/longitude location.
      参数:
      destination - The ending location for the Directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • mode

      public DirectionsApiRequest mode​(TravelMode mode)
      Specifies the mode of transport to use when calculating directions. The mode defaults to driving if left unspecified. If you set the mode to TRANSIT you must also specify either a departureTime or an arrivalTime.
      参数:
      mode - The travel mode to request directions for.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • avoid

      public DirectionsApiRequest avoid​(DirectionsApi.RouteRestriction... restrictions)
      Indicates that the calculated route(s) should avoid the indicated features.
      参数:
      restrictions - one or more of DirectionsApi.RouteRestriction.TOLLS, DirectionsApi.RouteRestriction.HIGHWAYS, DirectionsApi.RouteRestriction.FERRIES
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • units

      public DirectionsApiRequest units​(Unit units)
      Specifies the unit system to use when displaying results.
      参数:
      units - The preferred units for displaying distances.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • region

      public DirectionsApiRequest region​(java.lang.String region)
      参数:
      region - The region code, specified as a ccTLD ("top-level domain") two-character value.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • arrivalTime

      public DirectionsApiRequest arrivalTime​(java.time.Instant time)
      Set the arrival time for a Transit directions request.
      参数:
      time - The arrival time to calculate directions for.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • departureTime

      public DirectionsApiRequest departureTime​(java.time.Instant time)
      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.
      参数:
      time - The departure time to calculate directions for.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • departureTimeNow

      public DirectionsApiRequest 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 this DirectionsApiRequest for call chaining.
    • waypoints

      public DirectionsApiRequest waypoints​(DirectionsApiRequest.Waypoint... 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.

      参数:
      waypoints - The waypoints to add to this directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • waypoints

      public DirectionsApiRequest waypoints​(java.lang.String... waypoints)
      Specifies the list of waypoints as String addresses. If any of the Strings are Place IDs, you must prefix them with place_id:.

      See prefixPlaceId(String).

      See waypoints(Waypoint...).

      参数:
      waypoints - The waypoints to add to this directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • waypointsFromPlaceIds

      public DirectionsApiRequest waypointsFromPlaceIds​(java.lang.String... waypoints)
      Specifies the list of waypoints as Plade ID Strings, prefixing them as required by the API.

      See prefixPlaceId(String).

      See waypoints(Waypoint...).

      参数:
      waypoints - The waypoints to add to this directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • waypoints

      public DirectionsApiRequest waypoints​(LatLng... waypoints)
      The list of waypoints as latitude/longitude locations.

      See waypoints(Waypoint...).

      参数:
      waypoints - The waypoints to add to this directions request.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • optimizeWaypoints

      public DirectionsApiRequest optimizeWaypoints​(boolean optimize)
      Allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order.
      参数:
      optimize - Whether to optimize waypoints.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • alternatives

      public DirectionsApiRequest alternatives​(boolean alternateRoutes)
      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.
      参数:
      alternateRoutes - whether to return alternate routes.
      返回:
      Returns this DirectionsApiRequest for call chaining.
    • steps

      public DirectionsApiRequest steps​(boolean steps)
    • session

      public DirectionsApiRequest session​(java.lang.String session)
    • context

      public DirectionsApiRequest context​(java.lang.String context)
    • transitMode

      public DirectionsApiRequest transitMode​(TransitMode... transitModes)
    • transitRoutingPreference

      public DirectionsApiRequest transitRoutingPreference​(TransitRoutingPreference pref)
    • trafficModel

      public DirectionsApiRequest trafficModel​(TrafficModel trafficModel)
    • prefixPlaceId

      public java.lang.String prefixPlaceId​(java.lang.String placeId)
    • setCallback

      public final void setCallback​(PendingResult.Callback<T> callback)
      从接口复制的说明: PendingResult
      Performs the request asynchronously, calling onResult or onFailure after the request has been completed.
      指定者:
      setCallback 在接口中 PendingResult<T>
      参数:
      callback - The callback to call on completion.
    • await

      public final T await() throws ApiException, java.lang.InterruptedException, java.io.IOException
      从接口复制的说明: PendingResult
      Performs 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()
      从接口复制的说明: PendingResult
      Performs 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()
      从接口复制的说明: PendingResult
      Attempts 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

      protected A param​(java.lang.String key, StringJoin.UrlValue val)
    • paramAddToList

      protected A paramAddToList​(java.lang.String key, java.lang.String val)
    • paramAddToList

      protected A paramAddToList​(java.lang.String key, StringJoin.UrlValue val)
    • 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.