Quickstart

VERSION 1.20.0

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.20.0")

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 )
7
8search.search(
9 options,
10 object : SearchCallback {
11 override fun onSuccess(result: SearchResponse) {
12 // handle success
13 }
14
15 override fun onFailure(failure: SearchFailure) {
16 // handle failure
17 }
18 },
19)