Quickstart
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:
- 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.
- Configure the project as described in the project setup guide.
- Add the
Search
cocoapod dependency in thepodfile
of your application and do apod install
.
1SDK_VERSION = '0.2.728' // please always use the latest version23target 'YourAppTarget' do4 use_frameworks!5 pod 'TomTomSDKSearch', SDK_VERSION6end
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 options = SearchOptions(2 query: "TomTom",3 geoBias: CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),4 limit: 55)6onlineSearch.search(options: options) { result in7 switch result {8 case let .success(fuzzySearchResponse):9 // handle success10 break11 case let .failure(error):12 // handle error13 break14 }15}