Add the following snippet to the
<head> tag of your site.
To begin with the Localities Service, you need to build a new
AutocompleteService object passing the
key parameter corresponding to your project public key.
const key = 'woos-xxxx'; //your project public key let autocompleteService = new woosmap.localities.AutocompleteService(key);
Here is a code sample to help you use the Localities JS API.
keyup event fired on the dedicated text
getQueryPredictions() is called and results displayed below.
When one of the items of the list is clicked, a
getDetails() is called and the result displayed below.
To understand how to go deeper with the Localities JS API, please check the Localities JS API Reference.
In this example, we use the custom_description parameter and we query the getDetails of a selected locality to get its components.