Maps SDK for Web

tt.services.geometrySearch

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

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

Constructor

tt.services.geometrySearch([options])

Example
const geometryList = [
  {
    type: 'POLYGON',
    vertices: [
      '37.7524152343544,-122.43576049804686',
      '37.70660472542312,-122.43301391601562',
      '37.712059855877314,-122.36434936523438',
      '37.75350561243041,-122.37396240234374'
    ]
  },
  {
    type: 'CIRCLE',
    position: '37.71205,-121.36434',
    radius: 6000
  },
  {
    type: 'CIRCLE',
    position: '37.31205,-121.36434',
    radius: 1000
  }
];

function callbackFn(results) {
  console.log(results);
}

tt.services.geometrySearch({
  key: <Your API key>,
  geometryList: geometryList
})
.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.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.geometryList
Object[]
default:None

A list of geometries.


This is a list of geometries to search in. Currently only two types of geometries are being supported:
  • Polygons: Groups of coordinates (lat, lon) that describe an enclosed area.
  • Circles: Describe a circular area using an unique coordinate and a radius in meters.
Example
// A polygon area
[
  {
    type: 'POLYGON',
    vertices: [
      '37.7524152343544,-122.43576049804686',
      '37.70660472542312,-122.43301391601562',
      '37.712059855877314,-122.36434936523438',
      '37.75350561243041,-122.37396240234374'
    ]
  }
];
// A couple of circle areas
var geometryList = [
  {
    type: 'CIRCLE',
    position: '37.71205,-121.36434',
    radius: 6000 // Unit is in meters
  },
  {
    type: 'CIRCLE',
    position: '37.31205,-121.36434',
    radius: 1000 // Unit is in meters
  }
];
// Mixing polygons and circles areas
var geometryList = [
  {
    type: 'POLYGON',
    vertices: [
      '37.7524152343544,-122.43576049804686',
      '37.70660472542312,-122.43301391601562',
      '37.712059855877314,-122.36434936523438',
      '37.75350561243041,-122.37396240234374'
    ]
  },
  {
    type: 'CIRCLE',
    position: '37.71205,-121.36434',
    radius: 6000 // Unit is in meters
  },
  {
    type: 'CIRCLE',
    position: '37.31205,-121.36434',
    radius: 1000 // Unit is in meters
  }
];
options.idxSet
String
default:None

A list of indexes divided by commas.


This option specifies indexes to use for the search. The predefined 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
// search Points Of Interest only
tomtom.geometrySearch({
  query: 'pizza',
  idxSet: 'POI'
})
.go()
.then(handleResults);
// search addresses only
tomtom.geometrySearch()
tomtom.geometrySearch({
  query: 'pizza',
  idxSet: 'PAD,Addr'
})
.go()
.then(handleResults);
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.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.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.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