interface DirectionsRequest {
    params: {
        alternatives?: boolean;
        arrival_time?: number | Date;
        avoid?: TravelRestriction[];
        departure_time?: number | Date | "now";
        destination: LatLng;
        language?: Language;
        mode?: TravelMode;
        optimize?: boolean;
        origin: LatLng;
        region?: string;
        traffic_model?: TrafficModel;
        transit_mode?: TransitMode[];
        transit_routing_preference?: TransitRoutingPreference;
        units?: UnitSystem;
        waypoints?: LatLng[];
    } & RequestParams;
}

Hierarchy

  • Partial<AxiosRequestConfig>
    • DirectionsRequest

Properties

Properties

params: {
    alternatives?: boolean;
    arrival_time?: number | Date;
    avoid?: TravelRestriction[];
    departure_time?: number | Date | "now";
    destination: LatLng;
    language?: Language;
    mode?: TravelMode;
    optimize?: boolean;
    origin: LatLng;
    region?: string;
    traffic_model?: TrafficModel;
    transit_mode?: TransitMode[];
    transit_routing_preference?: TransitRoutingPreference;
    units?: UnitSystem;
    waypoints?: LatLng[];
} & RequestParams

Type declaration

  • Optionalalternatives?: boolean

    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.

  • Optionalarrival_time?: number | Date

    Specifies the desired time of arrival for transit directions, in seconds since midnight, January 1, 1970 UTC. You can specify either departure_time or arrival_time, but not both. Note that arrival_time must be specified as an integer.

  • Optionalavoid?: TravelRestriction[]

    Indicates that the calculated route(s) should avoid the indicated features.

  • Optionaldeparture_time?: number | Date | "now"

    Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second).

    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: You can specify the departure_time to receive a route and trip duration (response field: duration_in_traffic) that take traffic conditions into account. This option is only available if the request contains a valid API key, or a valid Google Maps APIs Premium Plan client ID and signature. The departure_time must be set to the current time or some time in the future. It cannot be in the past.
  • destination: LatLng

    The address, textual latitude/longitude value, or place ID to which you wish to calculate directions. The options for the destination parameter are the same as for the origin parameter, described above

  • Optionallanguage?: Language

    The language in which to return results.

    • If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header, or the native language of the domain from which the request is sent.
    • The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
    • If a name is not available in the preferred language, the API uses the closest match.
    • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.
  • Optionalmode?: TravelMode

    Specifies the mode of transport to use when calculating directions

    TravelMode.driving
    
  • Optionaloptimize?: boolean

    Wherever to optimize the provided route by rearranging the waypoints in a more efficient order.

  • origin: LatLng

    The address, textual latitude/longitude value, or place ID from which you wish to calculate directions.

    • If you pass an address, the Directions service geocodes the string and converts it to a latitude/longitude coordinate to calculate directions. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.

      origin=24+Sussex+Drive+Ottawa+ON

    • If you pass coordinates, they are used unchanged to calculate directions. Ensure that no space exists between the latitude and longitude values.

      origin=41.43206,-81.38992

    • Place IDs must be prefixed with place_id:. The place ID may only be specified if the request includes an API key or a Google Maps APIs Premium Plan client ID. You can retrieve place IDs from the Geocoding API and the Places SDK (including Place Autocomplete). For an example using place IDs from Place Autocomplete, see Place Autocomplete and Directions.

      origin=place_id:ChIJ3S-JXmauEmsRUcIaWtf4MzE

  • Optionalregion?: string

    Specifies the region code, specified as a ccTLD ("top-level domain") two-character value.

  • Optionaltraffic_model?: TrafficModel

    Specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the duration_in_traffic field in the response, which contains the predicted time in traffic based on historical averages. The traffic_model parameter may only be specified for driving directions where the request includes a departure_time, and only if the request includes an API key or a Google Maps APIs Premium Plan client ID.

    The default value of best_guess will give the most useful predictions for the vast majority of use cases. It is possible the best_guess travel time prediction may be shorter than optimistic, or alternatively, longer than pessimistic, due to the way the best_guess prediction model integrates live traffic information.

    TrafficModel.best_guess
    
  • Optionaltransit_mode?: TransitMode[]

    Specifies one or more preferred modes of transit. This parameter may only be specified for transit directions, and only if the request includes an API key or a Google Maps APIs Premium Plan client ID.

  • Optionaltransit_routing_preference?: TransitRoutingPreference

    Specifies preferences for transit routes. Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API. This parameter may only be specified for transit directions, and only if the request includes an API key or a Google Maps APIs Premium Plan client ID.

  • Optionalunits?: UnitSystem

    Specifies the unit system to use when displaying results.

  • Optionalwaypoints?: LatLng[]

    Specifies an array of waypoints. Waypoints alter a route by routing it through the specified location(s). A waypoint is specified as a latitude/longitude coordinate, an encoded polyline, a place ID, or an address which will be geocoded. Encoded polylines must be prefixed with enc: and followed by a colon (:). Place IDs must be prefixed with place_id:. The place ID may only be specified if the request includes an API key or a Google Maps APIs Premium Plan client ID. Waypoints are only supported for driving, walking and bicycling directions.