Skip to content

Routing from point A to point B.

Endpoint

https://maps.track-asia.com/route/v2/directions/{outputFormat}

outputFormat

outputFormat Description
json (recommended) indicates output in JavaScript Object Notation (JSON)
xml indicates output in XML

Parameters

Parameter Values Description Example
mode driving (default), motorcycling , walking The transportation mode to use driving
origin {latitude},{longitude} (recommended) or address string Textual latitude/longitude value to which you wish to calculate directions, ensure that no space exists between the latitude and longitude values. If you pass an address Directions service will geocode the string and convert to latitude/longitude 10.761,106.68
destination {latitude},{longitude} (recommended) or address string Textual latitude/longitude value to which you wish to calculate directions, ensure that no space exists between the latitude and longitude values. If you pass an address Directions service will geocode the string and convert to latitude/longitude 10.795,106.72
key String (required) API key public_key

Example Code

https://maps.track-asia.com/route/v2/directions/json?origin=10.761,106.68&destination=10.795,106.72&mode=driving&key=public_key
https://maps.track-asia.com/route/v2/directions/xml?origin=10.761,106.68&destination=10.795,106.72&mode=driving&key=public_key
curl -G "https://maps.track-asia.com/route/v2/directions/json" \
--data-urlencode "origin=10.761,106.68" \
--data-urlencode "destination=10.795,106.72" \
--data-urlencode "mode=driving" \
--data-urlencode "key=public_key"
const response = await fetch("https://maps.track-asia.com/route/v2/directions/json?origin=10.761,106.68&destination=10.795,106.72&mode=driving&key=public_key")
const data = await response.json()
console.log(data)

Response

JSON Response

The response is a JSON object with the following structure:

  • routes: An array of route objects. Each route contains:
    • summary: A summary of the route (e.g., main streets).
    • bounds: An object with northeast and southwest coordinates for the route bounds.
    • copyrights: Copyright information.
    • legs: An array of leg objects, each with:
      • distance: Object with text (human-readable) and value (meters).
      • duration: Object with text (human-readable) and value (seconds).
      • start_address, end_address: Addresses for the leg.
      • start_location, end_location: Objects with lat and lng.
      • steps: Array of step objects, each with:
        • distance, duration: As above.
        • start_location, end_location: As above.
        • polyline: Encoded polyline for the step.
        • html_instructions: Step instructions (HTML).
        • travel_mode: Travel mode (e.g., "DRIVING").
        • maneuver: Maneuver type (e.g., "turn-right").
    • overview_polyline: Encoded polyline for the full route.
    • waypoint_order: Array indicating the order of waypoints.
  • status: Status string (e.g., "OK").
  • geocoded_waypoints: Array of geocoded waypoint objects, each with:
    • geocoder_status: Status for the geocoding.
    • place_id: Place identifier.
    • types: Array of place types.
XML Response

The XML response has a similar structure, with elements corresponding to the JSON fields above. However, note the following subtle differences:

  • XML results are wrapped in a root <DirectionsResponse> element.
  • JSON denotes entries with multiple elements by plural arrays (such as steps and legs), while XML denotes these using multiple singular elements (such as <step> and <leg>).
  • JSON denotes waypoint order via the waypoint_order field, while XML denotes these using individual <waypoint_index> elements.
  • Blank elements are indicated through empty arrays in JSON, but by the absence of any such element in XML. A response that generates no results will return an empty routes array in JSON, but no <route> elements in XML, for example.

Polyline tool

Next steps