VERSION 0.2.2822

The Search module provides a set of tools to add a search experience to your application. With it, you can build an interface for users to perform single-line fuzzy searches for addresses and points of interest (POIs) using the TomTom Search APIs.

Project set up

To use the Search module, you need to configure its credentials and add the framework as a dependency:

  1. Get your TomTom API key from the Developer Portal. Instructions to request and use the TomTom API key can be found in the TomTom API key user guide.
  2. Configure the project as described in the project setup guide.
  3. Add the Search cocoapod dependency in the podfile of your application and do a pod install.
1SDK_VERSION = '0.2.728' // please always use the latest version
3target 'YourAppTarget' do
4 use_frameworks!
5 pod 'TomTomSDKSearch', SDK_VERSION

After setting up your pods, open your project and use the OnlineSearch object .This object is the entry point to using TomTom’s Search framework.

Making search calls

OnlineSearch can be tailored to return many different kinds of results, such as POIs, results along a route, or specific geometries. You can also use it to improve the search experience with tools such as autocomplete, POI category search, and additional data about POIs. Read more about the various search options here search API explorer.

All of these search options are built on a basic fuzzy search. At the beginning, OnlineSearch should be initialized as a class span property.

let onlineSearch = OnlineSearch(apiKey: "REPLACE_WITH_YOUR_API_KEY")

Here is a sample fuzzy search request:

1let query = SearchQuery(
2 "TomTom",
3 geoBias: CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),
4 limit: 5
6onlineSearch.search(query: query) { result in
7 switch result {
8 case let .success(fuzzySearchResponse):
9 // handle success
10 break
11 case let .failure(error):
12 // handle error
13 break
14 }