Maps SDK for Web
tt.services.reverseGeocode
Reverse geocode service implementation.
It converts geographical coordinates into a textual address representation using the TomTom Search API - Reverse 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.
The final response from the service is a JSON object with the following structure:
{
address: {
buildingNumber: 19,
streetNumber: 19,
landmark: '',
street: 'N 2nd St',
streetName: 'N 2nd St',
streetNameAndNumber: '',
speedLimit: '',
countryCode: 'U',
countrySubdivision: 'CA',
countrySecondarySubdivision: 'Santa Clara',
countryTertiarySubdivision: '',
municipality: 'San Jose',
postalCode: '95113',
municipalitySubdivision: 'San Francisco Bay Area',
freeformAddress: '19 N 2nd St, San Jose, CA, 95113'
},
position: '37.337083, -121.8898',
roadUse: ['LocalStreet']
}
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.reverseGeocode([options])
Example
function callbackFn(response) {
console.log(response);
}
tt.services.reverseGeocode({
key: <Your API key>,
position: '19.449: 51.759'
})
.go()
.then(callbackFn);
Parameters
Name | Description |
---|---|
options
Object default:None |
Options to be passed to the reverseGeocode call, or an array of such options objects to perform a batch request. |
Methods
go( ): Promise
Executes a predefined asynchronous task using the current configuration.
Returns