Maps SDK for Web
tt.services.structuredGeocode
Makes a request using the TomTom Search API - Structured Geocode.
Parameters can be passed to the constructor or provided via convenient methods that can be chained until the method go performs the actual call.
The call is asynchronous, therefore the user has two options to receive the response:
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.structuredGeocode([options])
Example
function callbackFn(result) {
console.log(result);
};
tt.services.structuredGeocode({
key: <Your API key>,
countryCode: 'GB'
})
.go();
Parameters
Name | Description |
---|---|
options
Object default:None |
Options to be passed to the structured geocoding call, or an array of such options objects to perform 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.countrySecondarySubdivision
String default:None |
The county's name. Represents the county's name for the structured address. |
options.countrySubdivision
String default:None |
The state or province. Represents the state or province's name for the structured address. |
options.countryTertiarySubdivision
String default:None |
The name of the area. Represents the area's name for the structured address. |
options.crossStreet
String default:None |
The cross street's name. Represents the cross street's name for the structured 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 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.municipality
String default:None |
The municipality's name (city/town). Represents the municipality (city/town) for the structured address. |
options.municipalitySubdivision
String default:None |
The municipality subdivision (sub/super city). Represents the municipality subdivision (sub/super city) for the structured address. |
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.postalCode
String default:None |
The zip or postal code. Represents the zip code or postal code for the structured address. |
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.streetName
String default:None |
The street's name. Represents the street's name for the structured address. |
options.streetNumber
String default:None |
The street's number. Represents the street's number for the structured address. |
Methods
go( ): Promise
Executes a predefined asynchronous task using the current configuration.
Returns