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.
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:2.1.2")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 search: Search = TomTomSdk.createSearch()With the search instance, a search request with geobias can be done like:
val options = buildTextSearchOptions( query = "TomTom", geoBias = GeoPoint(latitude = 52.379189, longitude = 4.899431), limit = 20, )
search.search( options, object : SearchCallback { override fun onSuccess(result: SearchResponse) { // handle success }
override fun onFailure(failure: SearchFailure) { // handle failure } },) When using the Extended flavor
In the Extended flavor you may also configure search options using SearchOptions API directly. For more details, see the section on flavors .
val searchOptions = SearchOptions( route = routePoints, categoryIds = setOf(CategoryId(StandardCategoryId.GasStation)), maxDetourDuration = 15.minutes,)