Skip to content

Computes the duration of the fastest route between all pairs of supplied coordinates. Returns durations or distances or both between the coordinate pairs.

Note that the distances are not the shortest distance between two coordinates, but rather the distances of the fastest routes. Durations are in seconds and distances are in meters. The length of sources and destinations can be smaller or equal to number of input locations.

Endpoint

https://maps.track-asia.com/distance-matrix/v1/{PROFILE}/{COORDINATES}

Parameters

Key Values Description Example
PROFILE car, moto or walk Mode of transportation moto
COORDINATES {longitude},{latitude};{longitude},{latitude} String of coordinates format 101.1234,10.1234;101.5678,10.5678
sources {index};{index}[;{index} ...] or all (default) Use location with given index as source 0;2
destinations {index};{index}[;{index} ...] or all (default) Use location with given index as destination 1;3;4
annotations duration (default), distance, or duration,distance Return the requested table or tables in response distance,duration
fallback_speed double > 0 If no route found between a source/destination pair, calculate the as-the-crow-flies distance, then use this speed to estimate duration 0.5
key String (required) API key public_key

Example code

  • Returns a 2x2 duration matrix
https://maps.track-asia.com/distance-matrix/v1/car/106.1234,10.1234;106.5678,10.5678?key=public_key
  • Returns a 3x3 distance matrix
https://maps.track-asia.com/distance-matrix/v1/moto/106.1234,10.1234;106.5678,10.5678;106.5778,10.5998?key=public_key
  • Returns a 1x3 duration matrix
https://maps.track-asia.com/distance-matrix/v1/car/106.1234,10.1234;106.5678,10.5678;106.5778,10.5998?sources=1&key=public_key
  • Returns a 2x3 duration matrix
https://maps.track-asia.com/distance-matrix/v1/car/106.1234,10.1234;106.5678,10.5678;106.5778,10.5998?sources=1;2&destinations=0;1;2&key=public_key
  • Returns a 3x2 duration and distance matrix
https://maps.track-asia.com/distance-matrix/v1/car/106.1234,10.1234;106.5678,10.5678;106.5778,10.5998?sources=0;1;2&destinations=1;2&annotations=distance,duration&key=public_key
curl -G 'https://maps.track-asia.com/distance-matrix/v1/car/106.1234,10.1234;106.5678,10.5678;106.5778,10.5998?sources=1&key=public_key'
const response = await fetch("https://maps.track-asia.com/distance-matrix/v1/car/106.1234,10.1234;106.5678,10.5678;106.5778,10.5998?sources=1;2&destinations=0;1;2&key=public_key")
const data = await response.json()
console.log(data)

Response

JSON Response

The response is a JSON object with the following structure:

  • code: Status of the request (e.g., "Ok").
  • sources: An array of source waypoint objects, each with:
    • location: [longitude, latitude] of the source point.
    • name: Name of the source location (if available).
  • destinations: An array of destination waypoint objects, each with:
    • location: [longitude, latitude] of the destination point.
    • name: Name of the destination location (if available).
  • distances: A 2D array of numbers, where distances[i][j] is the distance from source i to destination j (in meters), if requested.
  • durations: A 2D array of numbers, where durations[i][j] is the travel time from source i to destination j (in seconds), if requested.

Next steps