Maps SDK for Web

tt.services.autocomplete

The Autocomplete API enables you to make a more meaningful Search API call by recognizing entities inside an input query and offering them as query terms.

Makes a search request using the TomTom Search API - Autocomplete.

Response

The response is extended with getTrackingId() method, which returns the Tracking-ID associated with the request.

Please refer to Difference between API responses and this library's responses section.

Constructor

tt.services.autocomplete([options], [additionalOptions])

Parameters
Name Description
options
Object
default:None
additionalOptions
Object
default:None
Additional options to be passed to the service.
additionalOptions.abortSignal
Object
default:None

Signal created with abortController.


Use AbortController to cancel requests in progress.
Example
var abortController = new AbortController();
var options = {};
tt.services.calculateRoute(options, { abortSignal: abortController.signal })
    .then(function(response) { console.log(response) });
    .catch(function(error) {
        if (abortController.signal.aborted === true) {
            console.log('Request aborted.');
        }
    });
abortController.abort();
options.center
Object | Number[] | String[] | String
default:None

Longitude and latitude data in one of the supported formats.


This option represents a geographic coordinate. The supported formats are listed below:
  • Maps.LngLat The Class instance.
  • [0, 0] A one-dimensional array with two indexes for longitude and latitude respectively.
  • ["0", "0"] A one-dimensional array with two indexes for longitude and latitude respectively.
  • "0,1" A string with longitude and latitude divided by a comma.
  • {lng: Function, lat: Function} An object with two functions returning longitude and latitude.
  • {lon: 0, lat: 1} An object with two keys: lat and lon.
  • {lng: 0, lat: 1} An object with two keys: lat and lng.
  • {x: 0, y: 1} An object with two keys: x as longitude and y as latitude.
  • {longitude: 0, latitude: 1} An object with two keys: longitude and latitude.
Note: Supplying the center without a radius will bias search results only to that area.
options.countrySet
String
default:None

Comma separated list of country codes (e.g.: FR,ES)


This option is a list of country codes used to limit the search request to those specific political limits.
options.key
String
default:None

A valid API Key for the requested service.


Key is required to make use of the given service. It can be issued in the Developer Portal.
options.language
String
default:None

Language code that decides in which language the search results should be returned.


The value should correspond to one of the supported IETF language codes. The list is available here. The code is case insensitive.
options.limit
Number
default:10

The maximum number of responses that will be returned.


Represents the maximum number of responses that will be returned per request. The maximum value is 100.
options.query
String
default:None

The query string. This value will be properly encoded during the creation of the request.


This option represents the text that will be searched.
options.radius
Number
default:None

A positive integer value in meters.


This option specifies the search radius in meters using the coordinates given to the center option as origin.
options.resultSet
String
default:None

Restricts the result space based on their segment types.


A result is only included if at least one segment is of any of the indicated types. Value: A comma-separated list that consists of the types of segments. Usage examples:
  • resultSet=category
  • resultSet=brand
  • resultSet=category,brand
options.trackingId
String
default:uuid

Sets value of "Tracking-ID" header.


Specifies an identifier for the request. If not set by the user, UUID is generated for each call.
  • It can be used to trace a call.
  • The value must match the regular expression '^[a-zA-Z0-9-]{1,100}$'.
  • An example of the format that matches this regular expression is UUID: (e.g. 9ac68072-c7a4-11e8-a8d5-f2801f1b9fd1). For details check RFC 4122.
  • If specified, it is replicated in the Tracking-ID Response header.
  • It is only meant to be used for support and does not involve tracking of you or your users in any form.