UsageNote: this is meant to be a quick reference; check out the source code for the most up to date technical documentation.
For the most basic use, you just need to include the snippet, and provide an element with id
geocode-city-autocomplete. Ideally, it's a container like a `div`.
You can inspect the source of the index page to check out some custom usage, but here's a copy/paste for your quick reference:
All of the below options are optional, and passed as attributes of the element you identify as
- Your api key. If not provided, the user's browser will be used for rate limiting.
- The number of suggestions to show, defaults to 5.
nameattribute for the text input.
classattribute for the text input.
All of the below are custom events emitted in the element you use the snippet on. You can use
addEventListener to listen for them, and any data
included is sent through the
event.detail property (read more about custom events on MDN.)
- When a city is selected from the dropdown. Includes the full
- An array of cities, if any results are found.
- When no results are found, no data is sent.
- In the event of a client or server error; the error message is sent.
TODO. In the meantime, check out the source: all markup
that the snippet generates has the