Maps SDK for Web

tt.services.nearbySearch

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

Parameters need to be be passed to the constructor. The method go performs the actual call.

Constructor

tt.services.nearbySearch([options])

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

tt.services.nearbySearch({
  key: <Your API key>,
  center: [0,0],
  radius: 1000
})
.go()
.then(callbackFn);

The SDK provides a Promise polyfill for browsers (IE<9) without native ECMAScript 6 support.

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.
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.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.fuzzySearch({
  query: 'office',
  brandSet: 'TomTom,Foobar'
})
.go()
.then(handleResults);
// search for TomTom offices
tt.fuzzySearch({
  query: 'office',
  brandSet: 'TomTom'
})
.go()
.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. For more info about category codes, please refer to POI Categories documentation .
Example
// search places of category Restaurant
tt.fuzzySearch({
  query: 'food',
  categorySet: '7315'
})
.go()
.then(handleResults);
// search places of category either Italian or French Restaurant
tt.fuzzySearch({
  query: 'food',
  categorySet: '7315025,7315017'
})
.go()
.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.fuzzySearch({
  query: 'station',
  connectorSet: 'IEC62196Type1'
})
.go()
.then(handleResults);
// search for Electric Vehicle Station supporting IEC62196Type1 or GBT20234Part2
tt.fuzzySearch({
  query: 'station',
  connectorSet: 'IEC62196Type1,GBT20234Part2'
})
.go()
.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

Represent the indexes for extended postal codes.


Represent the indexes for which extended postal codes should be included in the results. The available indexes codes are:
  • Addr: Address ranges
  • Geo: Geographies
  • PAD: Point Addresses
  • POI: Points of Interest
  • Str: Streets
  • XStr: Cross Streets (intersections)
The value should be a comma-separated list of index types (in any order) or just the string "None" for no indexes.
Example
tomtom.geometrySearch({
  query: 'pizza',
  extendedPostalCodesFor: 'PAD,Addr,POI'
})
.go()
.then(handleResults);

The extended postal code will be returned as an extendedPostalCode property of an address.

options.key
String
default:None

A valid API Key for the requested service.


A valid API 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 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.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.fuzzySearch({
  query: 'cinema',
  openingHours: 'nextSevenDays'
})
.go()
.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.radius
Number
default:10000

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.view
String
default:None

The new value to be set.


Sets or returns the view option value to be used in the calls. Can be one of "Unified", "AR", "IN", "PK", "IL, "MA", "RU" and "TR". Legend: Unified - International view AR - Argentina IN - India PK - Pakistan IL - Israel MA - Morocco RU - Russia TR - Turkey

Methods

go( ): Promise

Executes a predefined asynchronous task using the current configuration.

Returns