Maps SDK for Web
tt.plugins.SearchBox
This plugin provides a search box functionality to your map. Underneath it uses the TomTom Fuzzy Search service. For more information about Fuzzy Search please refer to the documentation: Search API - Fuzzy Search.
Constructor
tt.plugins.SearchBox(services, [options])
Example
{
idleTimePress: 200,
minNumberOfCharacters: 3,
searchOptions: {
language: 'en-GB'
},
units: 'metric',
filter: function(result[, resultIndex[, results]]) {
return true;
},
noResultsMessage: 'No results found.'
}
Parameters
Name | Description |
---|---|
services
Services default:None |
The services object, which you need to import beforehand. |
options
Object default:None |
The Options object. |
options.placeholder
String default:None |
Specifies text that appears within the search box when it's empty. |
options.idleTimePress
Number default:200 |
The Search service call delay (in ms) after the last typed character. |
options.minNumberOfCharacters
Number default:3 |
The minimum number of characters to trigger the search call. |
options.units
String default:'metric' |
Either 'metric' or 'imperial'. Search results will show the distance from the center of the map; this sets which units should be used. |
options.searchOptions
Object default:None |
All custom options for the Search service. For all parameters please refer to Search API - Fuzzy Search |
options.filter
Function default:None |
Only results that pass the test implemented in this method will be shown on the results list. |
options.noResultsMessage
String default:'No results found.' |
The message shown when a given query search service returned no results or they were filtered out. |
Methods
getOptions( ): Object
Returns the options object.
Returns
this.options
getSearchBoxHTML( ): HTMLElement
Returns the plugin container.
Returns
container
onAdd(map): HTMLElement
Binds map with plugin instance.
Parameters
Name | Description |
---|---|
map
Maps.Map default:None |
Returns
container
onRemove( ): Void
Removes plugin from the map.
Returns
query( ): Void
Triggers search and fills the results list
Returns
updateOptions(options): Void
Events
All the class events are keys of the Events static member.
To learn more about how to listen events please refer to the Evented class.