🔍Autocomplete Overview
Autocomplete is used to provide real-time suggestions for locations as the user types in a query.
Compass currently provides an interface for interacting with a geocoding service, such as Mapbox. The autocomplete feature provides real-time suggestions to the user as they type an address or location into a search field.
The library is structured around several key components:
AutocompleteService
: This is an interface that represents a service providing autocomplete suggestions. It has asearch(query: String)
function, which searches for autocomplete suggestions based on the provided query.AutocompleteResult
: This is a sealed class that represents the result of an autocomplete operation. It can either be aSuccess
with a list of data or anError
with a specific error message.Autocomplete
: This is a function that creates a new instance ofAutocompleteService
that uses a HTTP service to provide autocomplete suggestions.
The current implementations of the AutocompleteService
use the Geocoding artifacts from Compass and perform a forward geocode operation. That means that the results may not be the highest of quality.
Quick start
In this quick example the AutoComplete.mobile()()
function is a convenience function for creating a AutoComplete<Place>
object. Each of the autocomplete-*
artifacts provide one.
Last updated