Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@tomtom-international/web-sdk-plugin-searchbox
Advanced tools
Plugin that provides SearchBox functionality to your map
This plugin provides a search box functionality to your map (@tomtom-international/web-sdk-maps).
As the user starts typing, search results appear in the list below the input field. Results list combines autocomplete and fuzzy search results.
The user keystrokes result in requests to Fuzzy Search and Autocomplete services. A number of calls made to the service can be optimized thanks to the options: idleTimePress and minNumberOfCharacters.
For more details on how to use the configuration options, please refer to the documentation: https://developer.tomtom.com/maps-sdk-web-js/documentation#ttPlugins.SearchBox
Please note that from version 3.0.0 this plugin only works with @tomtom-international/web-sdk-maps@6.*.*, if you are using @tomtom-international/web-sdk-maps@5.*.* please use version 2.*.*
Just do:
npm i @tomtom-international/web-sdk-plugin-searchbox
You must also include the search box stylesheet in your project. It's located here:
node_modules/@tomtom-international/web-sdk-plugin-searchbox/dist/SearchBox.css
There are two ways to include search box into your page.
import tt from '@tomtom-international/web-sdk-maps';
import { services } from '@tomtom-international/web-sdk-services';
import SearchBox from '@tomtom-international/web-sdk-plugin-searchbox';
const ttSearchBox = new SearchBox(services, options);
map.addControl(ttSearchBox, 'top-left');
Note, that you need to pass the Tomtom services instance to the search box constructor. The second parameter are the options. They allow you to customize how search box behaves. Options (except searchOptions.key
) are not mandatory, we provide default ones.
Example options:
{
idleTimePress: 100,
minNumberOfCharacters: 0,
searchOptions: {
key: '<your-tomtom-search-key>'
language: 'en-GB'
},
autocompleteOptions: {
key: '<your-tomtom-search-key>'
language: 'en-GB'
},
noResultsMessage: 'No results found.'
}
import { services } from '@tomtom-international/web-sdk-services';
import SearchBox from '@tomtom-international/web-sdk-plugin-searchbox';
const ttSearchBox = new SearchBox(services, options);
const searchBoxHTML = ttSearchBox.getSearchBoxHTML();
//Attach searchboxHTML to your page
Search box emits 7 different events:
If you want to subscribe for the event:
ttSearchBox.on('tomtom.searchbox.resultsfound', function(data) {
console.log(data);
});
If you have initialized the search box and you want to change options later, you can do the following:
ttSearchBox.getOptions() //if you need old options, you can also retrieve them
ttSearchBox.updateOptions(newOptions)
ttSearchBox.query()
This query method triggers the search with updated options. This is necessary if you want to update results for the user with new options.
FAQs
Plugin that provides SearchBox functionality to your map
The npm package @tomtom-international/web-sdk-plugin-searchbox receives a total of 59 weekly downloads. As such, @tomtom-international/web-sdk-plugin-searchbox popularity was classified as not popular.
We found that @tomtom-international/web-sdk-plugin-searchbox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.