Maps SDK for Web

tt.services.categorySearch

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

Parameters need to be passed to the constructor.

The list of all supported category codes are available here.

Response

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

Additionally, the response extends API response by providing toGeoJson() method, which converts category search data into FeatureCollection with Point geometry.

Each point feature represents poi from the original response. Properties of poi are mapped into feature properties

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

Constructor

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

Example
function callbackFn(result) {
  console.log(result);
};

tt.services.categorySearch({
   key: <Your API key>,
   query: 'restaurant'
}).then(callbackFn);
Parameters
Name Description
options
Object
default:None
Options to be passed to the search call, or an array of such options objects to perform a batch request.
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.bestResult
Boolean
default:false

Defines whether the geocode service should return the best result.


It makes the service instances to return only one result, the best match result. This option overwrites both limit and offset parameters. It changes the response from an array to a single result.
options.boundingBox
Maps.LngLatBounds | Number[] | Object[] | String
default:None

Bounding box area in one of the supported formats.


The bounding box is a limited area within the search results. If it is omitted then the whole world will be taken into consideration. In case the area specified exceeds the world boundaries, the following actions will be taken depending on which side was exceeded:
  • Latitudes: the exceeded values will be replaced with their maximun.
  • Longitudes: The service will split the area into two (or more) valid bounding boxes, will execute a search request for each one, and then merge the responses into a single result.
This option is able to convert a number of popular formats into the bounding box. The supported formats are listed below:
  • Maps.LngLatBounds class instance
  • {minLon: 0, minLat: 0, maxLon: 1, maxLat: 1} A plain object with the keys minLon, minLat, maxLon, maxLat.
  • [0, 0, 1, 1] An array of numbers describing the bounding box following the order: minLon, minLat, maxLon, maxLat.
  • [[0, 0], [1, 1]] A two-dimensional array with two indexes [southWest, northEast], each one with longitude and latitude values.
  • "0,0,1,1" A comma-separated string with numbers in the order: minLon, minLat, maxLon, maxLat.
  • [{lon: 0, lat: 0},{lon: 1, lat: 1}] A one-dimensional array with two objects in the order: southWest, northEast, and each object with a lat and lon key.
  • [{lng: 0, lat: 0},{lng: 1, lat: 1}] A one-dimensional array with two objects in the order: southWest, northEast and each object with a lat and lon key.
  • [Maps.LngLat, Maps.LngLat] A one-dimensional array with two Maps.LngLat instances in the order: southWest and northEast.
options.brandSet
String
default:None

A list of brands divided by commas.


This option specifies brands to use for the search.
Example
// search for TomTom and Foobar facilities
tt.services.fuzzySearch({
  query: 'office',
  brandSet: 'TomTom,Foobar'
}).then(handleResults);
// search for TomTom offices
tt.services.fuzzySearch({
  query: 'office',
  brandSet: 'TomTom'
}).then(handleResults);
options.categorySet
String
default:None

A list of categories codes divided by commas.


This option specifies categories codes to use for the search. Those codes can be retrieved by using poiCategories service.
Example
// search places of category Restaurant
tt.services.fuzzySearch({
  query: 'food',
  categorySet: '7315'
})
.then(handleResults);
// search places of category either Italian or French Restaurant
tt.services.fuzzySearch({
  query: 'food',
  categorySet: '7315025,7315017'
})
.then(handleResults);
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.connectorSet
String
default:None

A list of Electrical Vehicle connector types divided by commas.


This option specifies connector types, which could be used to restrict the result to Points Of Interest of type Electric Vehicle Station supporting specific connector types. For more info about EV connector names, please refer to Supported Connector Types documentation page.
Example
// search for Electric Vehicle Station supporting IEC62196Type1
tt.services.fuzzySearch({
  query: 'station',
  connectorSet: 'IEC62196Type1'
}).then(handleResults);
// search for Electric Vehicle Station supporting IEC62196Type1 or GBT20234Part2
tt.services.fuzzySearch({
  query: 'station',
  connectorSet: 'IEC62196Type1,GBT20234Part2'
}).then(handleResults);
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.extendedPostalCodesFor
String
default:None

A comma-separated list of index types or "None" for no indexes.


Indexes for which extended postal codes should be included in the results. By default, extended postal codes are available for all indexes except geographies because extended postal code lists for geographies can be quite long, so they have to be explicitly requested when needed. Availability is region-dependent. The available indexes are:
  • Addr: Address range interpolation (when there is no PAD)
  • Geo: Geographies
  • PAD: Point Addresses
  • POI: Points of interest
  • Str: Streets
  • XStr: Cross Streets (intersections)
Example
tt.services.structuredGeocode({
  query: 'street name',
  extendedPostalCodesFor: 'POI'
}).then(handleResults);
tt.services.structuredGeocode({
  query: 'street name',
  extendedPostalCodesFor: 'PAD,Addr'
}).then(handleResults);
options.fuelSet
String
default:None

A list of Fuel Types divided by commas.


This option specifies fuel types, which could be used to restrict the result to the Points Of Interest of specific fuels. If fuelSet is specified, the query can remain empty. Only POIs with a proper fuel type will be returned. Value: A comma-separated list of fuel type identifiers (in any order).
  • Item order does not matter.
  • When multiple fuel types are provided, only POIs that belong to (at least) one of the fuel types from the provided list will be returned.
Available values:
  • Petrol
  • LPG
  • Diesel
  • Biodiesel
  • DieselForCommercialVehicles
  • E85
  • LNG
  • CNG
  • Hydrogen
  • AdBlue
Example
// search Points Of Interest of the ¨Diesel¨ fuel type
tt.services.fuzzySearch({
  query: 'Gas stations',
  fuelSet: 'Diesel'
}).then(handleResults);
// search Points Of Interest of either the ¨Petrol¨ or ¨LPG¨ fuel type
tt.services.fuzzySearch({
  query: 'Gas stations',
  fuelSet: 'Petrol,LPG'
}).then(handleResults);
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:null

Language code that decides in which language the 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.mapcodes
String
default:null

Enables the return of a comma-separted mapcodes list. It can also filter the response to only show selected mapcode types. See Mapcodes in the response. Values: One or more of:

  • Local
  • International
  • Alternative

A mapcode represents a specific location, to within a few meters. Every location on Earth can be represented by a mapcode. Mapcodes are designed to be short, easy to recognize, remember, and communicate. Visit the Mapcode project website for more information. Usage examples:


Example
tt.services.fuzzySearch({
  query: 'Some street',
  mapcodes: 'Local'
}).then(handleResults);
tt.services.fuzzySearch({
  query: 'Some street',
  mapcodes: 'Local,Alternative,International'
}).then(handleResults);
options.maxPowerKW
Number
default:None

A number representing a maximum power rate in kilowatts.


An optional parameter which can be used to restrict the result to the availability for connectors with a specific maximum value of power in kilowatts.
options.minPowerKW
Number
default:None

A number representing a minimum power rate in kilowatts.


An optional parameter which can be used to restrict the result to the availability for connectors with a specific minimum value of power in kilowatts.
options.offset
Number
default:None

A positive integer value.


Use this option if you want to apply an offset to the results returned by the Search API service. It makes use of the ofs parameter which allows paginated results when used with the limit option. The maximum value is 1900.
options.openingHours
String
default:None

The only available option is 'nextSevenDays'.


This option shows the opening hours for the next week, starting with the current day in the local time of the POI.
Example
// search for cinemas inculding their opening hours.
tt.services.fuzzySearch({
  query: 'cinema',
  openingHours: 'nextSevenDays'
}).then(handleResults);
options.protocol
"http" | "https"
default:"https"

The protocol type to be used in the calls.


Represents the type of protocol used to perform a service call.
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.relatedPois
String
default:None

The only available options are off, child, parent, all.


This option is used to provide the possibility to return related Points Of Interest. Points Of Interest can be related to each other when one is physically part of another. For example, an airport terminal can physically belong to an airport. This relationship is expressed as a parent/child relationship: the airport terminal is a child of the airport. Usage:
  • If the value child or parent is given, a related POIs with a specified relation type will be returned in the Response.
  • If the value all is given, then both child and parent relations are returned.
Example
// search for airport terminals inculding their related Points Of Interest.
tt.services.fuzzySearch({
  query: 'airport terminal',
  relatedPois: 'all'
}).then(handleResults);
options.timeZone
String
default:None

The only available option is iana.


This option is used to indicate the mode in which the timeZone object should be returned. The only available option is iana - mode that shows the IANA ID which allows the user to determine the current time zone for the POI.
Example
// search for cinemas including their opening hours and IANA ID.
tt.services.fuzzySearch({
  query: 'cinema',
  openingHours: 'nextSevenDays',
  timeZone: 'iana'
}).then(handleResults);
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.
options.typeahead
Boolean
default:false

Enables or disables the option.


If this option is enabled, the query will be interpreted as a partial input and the search will enter predictive mode.
options.view
String
default:None

Geopolitical view.


Can be one of "Unified", "AR", "IN", "PK", "IL, "MA", "RU", "TR" and "CN". Legend:
  • Unified - International view
  • AR - Argentina
  • IN - India
  • PK - Pakistan
  • IL - Israel
  • MA - Morocco
  • RU - Russia
  • TR - Turkey
  • CN - China