Table of Contents

Class DirectionsRequest

Namespace
GoogleMapsApi.Entities.Directions.Request
Assembly
GoogleMapsApi.dll

Request for the Google Directions API, which computes a route between an origin and a destination for a chosen travel mode, with optional waypoints and routing preferences.

Legacy as of 2025-03-01 — feature-frozen and closed to new Google Cloud projects (existing projects keep working; no shutdown date announced). For new integrations prefer the Routes API via Routes.

public class DirectionsRequest : SignableRequest
Inheritance
DirectionsRequest
Inherited Members

Properties

Alternatives

alternatives (optional), 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.

public bool Alternatives { get; set; }

Property Value

bool

ArrivalTime

The time of arrival. Required when TravelMode = Transit

public DateTime ArrivalTime { get; set; }

Property Value

DateTime

Avoid

avoid (optional) indicates that the calculated route(s) should avoid the indicated features. Currently, this parameter supports the following two arguments: tolls indicates that the calculated route should avoid toll roads/bridges. highways indicates that the calculated route should avoid highways. (For more information see Route Restrictions below.)

public AvoidWay Avoid { get; set; }

Property Value

AvoidWay

BaseUrl

Base URL (without scheme) for the Google Maps Web Service endpoint this request targets. Derived requests append their service-specific path.

protected override string BaseUrl { get; }

Property Value

string

DepartureTime

The time of departure. Required when TravelMode = Transit

public DateTime DepartureTime { get; set; }

Property Value

DateTime

Destination

destination (required) — The address or textual latitude/longitude value from which you wish to calculate directions. If you pass an address as a string, the Directions service will geocode the string and convert it to a latitude/longitude coordinate to calculate directions. If you pass coordinates, ensure that no space exists between the latitude and longitude values.

public string Destination { get; set; }

Property Value

string

Language

language (optional) — The language in which to return results. See the supported list of domain languages. Note that we often update supported languages so this list may not be exhaustive. If language is not supplied, the Directions service will attempt to use the native language of the browser wherever possible. You may also explicitly bias the results by using localized domains of http://map.google.com. See Region Biasing for more information.

public string? Language { get; set; }

Property Value

string

OptimizeWaypoints

optimize the provided route by rearranging the waypoints in a more efficient order. (This optimization is an application of the Travelling Salesman Problem.) http://en.wikipedia.org/wiki/Travelling_salesman_problem

public bool OptimizeWaypoints { get; set; }

Property Value

bool

Origin

origin (Required) - The address or textual latitude/longitude value from which you wish to calculate directions. If you pass an address as a string, the Directions service will geocode the string and convert it to a latitude/longitude coordinate to calculate directions. If you pass coordinates, ensure that no space exists between the latitude and longitude values.

public string Origin { get; set; }

Property Value

string

Region

This parameter takes a region code, specified as a IANA language region subtag (http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry). In most cases, these tags map directly to familiar ccTLD ("top-level domain") two-character values such as "uk" in "co.uk" for example. In some cases, the region tag also supports ISO-3166-1 codes, which sometimes differ from ccTLD values ("GB" for "Great Britain" for example).

public string? Region { get; set; }

Property Value

string

TravelMode

(optional, defaults to driving) — specifies what mode of transport to use when calculating directions. Valid values are specified in Travel Modes.

public TravelMode TravelMode { get; set; }

Property Value

TravelMode

Waypoints

waypoints (optional) specifies an array 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. (For more information on waypoints, see Using Waypoints in Routes below.)

public string[]? Waypoints { get; set; }

Property Value

string[]

Methods

GetQueryStringParameters()

Builds the list of query-string parameters that will be sent with the request. Derived classes override to contribute their service-specific parameters.

protected override QueryStringParametersList GetQueryStringParameters()

Returns

QueryStringParametersList

The parameters to include in the request URL.