Quickstart
The Search module provides easy-to-use APIs to add search functionality to your application. It is built on top of TomTom Search APIs and has offline support.
We also have an off-the-shelf UI component named SearchUI
.
Project setup
Configure the project as described in the Project setup guide.
Then add the Search
module dependency in the build.gradle.kts
of your application module and synchronize the project.
implementation("com.tomtom.sdk.search:search-online:1.11.0")
Using the off-the-shelf UI
The SearchUi is a a module consisting of custom Search UI components. It offers a user interface that allows users to enter search keywords and select a result. To incorporate this module into your project, you must include the search-ui
as a gradle dependency. To learn more about its usage, visit the SearchUi Guide.
Using Search module APIs
The Search module is composed of several modules. The search-api
module provides the common API interfaces and types. The search-online
module provides an online implementation of the Search
interface.
Making search API calls
The OnlineSearch
is highly configurable and supports various kinds of searches, for example, searching certain POIs by category, searching inside certain geometries, and searching along a route. It also provides auxiliary APIs such as autocompletion for brands and categories and for point of interest details.
To start using the API, initialize an OnlineSearch
instance:
val searchApi = OnlineSearch.create(context, "YOUR_TOMTOM_API_KEY")
With the onlineSearch
instance, a search request with geobias can be done like:
1val options =2 SearchOptions(3 query = "TomTom",4 geoBias = GeoPoint(latitude = 52.377956, longitude = 4.897070),5 limit = 5,6 )78search.search(9 options,10 object : SearchCallback {11 override fun onSuccess(result: SearchResponse) {12 // handle success13 }1415 override fun onFailure(failure: SearchFailure) {16 // handle failure17 }18 },19)