SearchEngine

interface SearchEngine

Used for forward geocoding (looking up a place by name to retrieve its geographic coordinates).

Instantiating

To obtain SearchEngine instance, please, use MapboxSearchSdk.getSearchEngine.

Forward geocoding algorithm

Forward geocoding consists of 2 steps:

  1. Retrieve suggestions (search). For giving query we provide a list of suggestions, which contain only basic information (name of a place/category/query, its description, its type and etc.). Provided suggestions will be passed to SearchSuggestionsCallback.onSuggestions. Note, that such information as coordinates of place is not available at this step. To get this information, proceed to next step;

  2. Get more details for suggestion (select). Depending on suggestion type, different logic might be applied:

    If you want to get coordinates of search suggestion (or more details about suggestion), you should use select method. You will receive more detailed information.

Error handling

If invalid parameters are provided, RuntimeException is thrown immediately. Any other error will be propagated to SearchSuggestionsCallback.onError.

Functions

search
Link copied to clipboard
open fun search(query: String, options: SearchOptions, callback: SearchSuggestionsCallback): SearchRequestTask
The first step of forward geocoding.
abstract fun search(query: String, options: SearchOptions, executor: Executor, callback: SearchSuggestionsCallback): SearchRequestTask
The first step of forward geocoding.
select
Link copied to clipboard
open fun select(suggestion: SearchSuggestion, callback: SearchSelectionCallback): SearchRequestTask
The second step of forward geocoding.
open fun select(suggestions: List<SearchSuggestion>, callback: SearchMultipleSelectionCallback): SearchRequestTask
Function to select multiple suggestions at once.
open fun select(suggestion: SearchSuggestion, options: SelectOptions, callback: SearchSelectionCallback): SearchRequestTask
The second step of forward geocoding.
abstract fun select(suggestions: List<SearchSuggestion>, executor: Executor, callback: SearchMultipleSelectionCallback): SearchRequestTask
Function to select multiple suggestions at once.
abstract fun select(suggestion: SearchSuggestion, options: SelectOptions, executor: Executor, callback: SearchSelectionCallback): SearchRequestTask
The second step of forward geocoding.

Properties

apiType
Link copied to clipboard
abstract val apiType: ApiType
Experimental API, can be changed or removed in the next SDK releases.