Skip to content

Help users find what they're looking for without requiring them to fully specify their search term.

Endpoint

https://maps.track-asia.com/api/v2/place/autocomplete/{outputFormat}

outputFormat

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

Parameters

Parameter Values Description Example
input String (required) The input string that you want to autocomplete. This input string could be a partial address, a place name, or any other string that you want to find a match for Toa nha BW
key String (required) API key public_key
bounds {latitude},{longitude};{latitude},{longitude} The bounding box of the viewport within which to bias geocode results more prominently. This parameter will only influence, not fully restrict, results from the geocoder 21.6463420,104.8429379;21.7503187,104.9330227
size Number The maximum number of results to return from the search. 5
location {latitude},{longitude} The latitude and longitude values specifying the location for which you wish to obtain the closest, human-readable address. 10.7952219,106.7217912

Example Code

https://maps.track-asia.com/api/v2/place/autocomplete/json?input=Toa nha BW&bounds=21.6463420,104.8429379;21.7503187,104.9330227&size=2&key=public_key
https://maps.track-asia.com/api/v2/place/autocomplete/xml?input=Toa nha BW&bounds=21.6463420,104.8429379;21.7503187,104.9330227&key=public_key
curl -G "https://maps.track-asia.com/api/v2/place/autocomplete/xml" \
--data-urlencode "input=Toa nha BW" \
--data-urlencode "bounds=21.6463420,104.8429379;21.7503187,104.9330227" \
--data-urlencode "location=10.7952219,106.7217912" \
--data-urlencode "size=5" \
--data-urlencode "key=public_key"
const response = await fetch("https://maps.track-asia.com/api/v2/place/autocomplete/json?input=Toa nha BW&bounds=21.6463420,104.8429379;21.7503187,104.9330227&size=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:

  • status: Status string (e.g., "OK").
  • predictions: An array of prediction objects. Each prediction contains:
    • place_id: Unique identifier for the place.
    • reference: Reference for the place (may be the same as place_id).
    • name: Name of the place.
    • sublabel: Additional address or context for the place.
    • description: Full description of the place.
    • matched_substrings: Array of objects indicating which substrings of the input matched.
    • structured_formatting: Object with main_text, main_text_matched_substrings, and secondary_text for display formatting.
    • terms: Array of objects with offset and value for each term in the result.
    • geometry: Object with location (lat/lng), location_type, and viewport (northeast/southwest bounds).
    • plus_code: Object with compound_code and global_code.
    • types: Array of place types.
XML Response

The XML response has a similar structure, with elements corresponding to the JSON fields above. Notable differences:

  • XML results are wrapped in a root <AutocompletionResponse> element.
  • Arrays in JSON (like predictions, terms) become repeated elements in XML (like <prediction>, <term>).
  • Blank elements are indicated by empty arrays in JSON, but by the absence of such elements in XML.

Status

Status Description
OK indicating the API request was successful.
ZERO_RESULTS indicating that the search was successful but returned no results. This may occur if the search was passed a bounds in a remote location.

Error

When the geocoder returns a status code other than OK, there may be an additional error_message field within the Geocoding response object. This field contains more detailed information about the reasons behind the given status code.

Next steps