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']
}
You have two ways to make a batch request to the service.
- Pass an array of objects, which represents options for each call. In this situation we will decide for you which endpoint to call and we will handle the data retrieval for you.
- If you want to explicitly decide which batch mode you want to use, pass an object which will contain the '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:
//Option 1:
tt.services.<service name>([{
key: <Your API key>,
...
}, {
key: <Your API key>,
...
} //... more objects
])
.go()
.then(callback);
//Option 2, explicitly specifying batchMode:
tt.services.<service name>({
batchMode: 'sync'
batchItems: [{
key: <Your API key>,
...
}, {
key: <Your API key>,
...
} //... 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: '51.759,19.449'
})
.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. |
Format
Boolean default:None |
of newlines in the formatted address. Format of newlines in the formatted address. If true, the address will contain newlines. Otherwise, newlines will be converted to spaces. |
options.entityType
String | String[] default:None |
A comma-separated string. One or more of: - Country - CountrySubdivision - CountrySecondarySubdivision - CountryTertiarySubdivision - Municipality - MunicipalitySubdivision - Neighbourhood - PostalCodeArea This parameter specifies the level of filtering performed on geographies. Providing the parameter narrows the search for the specified geography entity types. The resulting response will contain the geography ID as well as the entity type matched. This ID is a token that can be used to get the geometry of that geography. The following parameters are ignored when entityType is set: heading, number, returnRoadUse, returnSpeedLimit, roadUse, and returnMatchType. |
options.heading
Number default:None |
The directional heading of the vehicle in degrees for travel along a
segment of roadway.
Makes it possible to get the address information of the road, keeping in mind the direction. |
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. |
number
String default:None |
Street number as a string. Sets or gets the value of the option number .
If a street number is sent in along with the request, the response may
include the side of the street (Left/Right), and also an offset position for that street number.
|
options.position
String | Number[] | String[] | Object default:None |
Longitude and latitude data in one of the supported formats. This option's value should have the location to be reverse geocoded. This option is able to convert a number of popular formats into a geographic coordinate. The supported formats are listed below:
|
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: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.
|
Type
Boolean default:None |
of match. Includes information on the type of match the geocoder achieved in the response. |
returnRoadUse
Boolean default:None |
Enable or disable the feature. Sets or gets the value of the option returnRoadUse .
Requires including a road use array for reversegeocodes at street level.
|
returnSpeedLimit
Boolean default:None |
Enable or disable the feature. Sets or gets the value of the option returnSpeedLimit .
Allows, if possible, the receiving of speed limit information at the given location.
|
roadUse
String[] | String default:None |
An array of strings, or just one string with comma-separated values. Sets or gets the value of the option roadUse .
Use this option if you want to restrict the result to one, or a group of the following road uses:
|
newValue
String default:None |
The street's number. Sets or returns the value of the streetNumber option.
Represents the street's number for the structured address.
|
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, and "MA".
Legend:
Unified - International view
AR - Argentina
IN - India
PK - Pakistan
IL - Israel
MA - Morocco
|
Methods
go( ): Promise
Executes a predefined asynchronous task using the current configuration.
Returns