Maps SDK for Web
tt.services.geocode
Allows requests to be made using the TomTom's Search API - Geocode.
Parameters need to be passed to the constructor. The method go performs the actual call.
The SDK provides a Promise polyfill for browsers (IE<9) without native ECMAScript 6 support.
In order to make batch call, pass an object which will contain the 'key' property, 'batchMode' property set to the correct value (sync, async, or redirect) and batchItems, which will contain an array of objects which represent options for each call. For more information, please refer to batch documentation:
tt.services.<service name>({
batchMode: 'sync'
key: <Your API key>,
batchItems: [{
...
}, {
...
} //... more objects
]
})
.go()
.then(callback);
Constructor
tt.services.geocode([options])
Example
function callbackFn(result) {
console.log(result);
};
tt.services.geocode({
key: <Your API Key>,
query: 'Amsterdam, The Netherlands'
})
.go()
.then(callbackFn);
Parameters
Name | Description |
---|---|
options
Object default:None |
Options to be passed to the geocode call, or an array of such option 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.boundingBox
Object | 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:
|
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:
|
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:
"None"
for no indexes.
Example
The extended postal code will be returned as an |
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 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.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.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. |
Methods
go( ): Promise
Executes a predefined asynchronous task using the current configuration.
Returns