getDistanceMatrix

fun getDistanceMatrix(origins: List<LatLng>, destinations: List<LatLng>, mode: TransitMode? = null, language: String? = null, units: UnitSystem? = null, elements: Elements? = null, method: Method? = null): DistanceMatrixResponse

Distance Matrix Get distances and durations for a matrix of origins and destinations, based on the recommended route between start and end points for a specified travel mode.

Return

DistanceMatrixResponse

Parameters

origins

The starting point for calculating travel distance. You can supply one or more locations separated by the pipe character (|), in the form of latitude/longitude coordinates. They are used unchanged to calculate distance. Ensure that no space exists between the latitude and longitude values. In order to reduce URL size, encoded polylines are also supported using `enc:encoded-polyline:`

destinations

One or more locations to use as the finishing point for calculating travel distance. The options for the destinations parameter are the same as for the origins parameter, described above. In order to reduce URL size, encoded polylines are also supported using `enc:encoded-polyline:`

mode

Specifies the mode of transport to use when calculating distance (optional)

language

The language code, indicating in which language the results should be returned, if possible. If language is not supplied, the Distance API service will use the navigator language or “en”. (optional)

units

Specifies the unit system parameter to use when expressing distance as text. Two different units supported: * `metric` (default) returns distances in kilometers and meters * `imperial` returns distances in miles and feet (optional)

elements

Specifies element values that will be part of the API response (distance and/or duration). if not specified default is `distance` (optional)

method

Specifies the method to compute the route between the start point and the end point: - `time`: fastest route (default) - `distance`: shortest route (optional)

Throws

If the request is not correctly configured

Rethrows the OkHttp execute method exception

If the API returns an informational or redirection response

ClientException

If the API returns a client error response

ServerException

If the API returns a server error response