POI details and categories

VERSION 0.54.0

Request POI details

To fetch details on a certain POI, use the Search.requestPOIDetails(options:completion:) API. It takes a POIDetailsOptions struct as input. The only required parameter is an identifier for the POI, which can be obtained in the SearchResultID of a SearchResult.

Only results of the POI type SearchResult are supported by the POI details request API.

You can request POI details in different languages. See the list of supported languages.

Specify the desired response language when creating POIDetailsOptions using a POIDetailsOptions.locale parameter.

If no language is specified, categories are returned in English.

1let amsterdamCenter = CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070)
2let options = SearchOptions(
3 query: "Restaurant",
4 geoBias: amsterdamCenter,
5 resultTypes: [.poi]
8onlineSearch.search(options: options) { [weak self] result in
9 switch result {
10 case let .success(poiSearchResponse):
11 guard let result = poiSearchResponse.results.first,
12 let resultID = result.searchResultID.id,
13 let poiID = try? POIID(id: resultID, source: result.searchResultID.source) else {
14 return
15 }
17 let poiDetailsOptions = POIDetailsOptions(
18 poiID: poiID,
19 locale: Locale(identifier: "en_GB")
20 )
22 self?.onlineSearch.requestPOIDetails(options: poiDetailsOptions) { result in
23 switch result {
24 case let .success(poiDetailsResponse):
25 // handle success
26 break
27 case let .failure(error):
28 // handle error
29 break
30 }
31 }
33 case let .failure(error):
34 // handle error
35 break
36 }

As a result, you will get a POIDetailsResponse that contains POIDetailsResponse.POIDetails with an updated POIDetailsResponse.POIDetails.poi property.

More detailed information about this service can be found in the Search API Place by ID documentation.

Request POI categories

The POI categories request is used to obtain a list of all POI categories and subcategories, together with synonyms. You can request categories in different languages. See the list of supported languages. More detailed information about this service can be found in the Search API POI Categories documentation.

To perform a call, you need to create POICategoryOptions where you can specify the desired response language.

If no language is specified, categories will be returned in the system language and in English if the system language is unsupported.

let options = POICategoryOptions(locale: Locale(identifier: "en_GB"))

As you created the query, you can:

1let onlineSearch = OnlineSearchFactory.create(apiKey: "YOUR_TOMTOM_API_KEY")
2onlineSearch.requestPOICategories(options: options) { result in
3 switch result {
4 case let .success(poiCategoriesResponse):
5 // handle success
6 break
7 case let .failure(error):
8 // handle error
9 break
10 }

As a result you will get a: POICategoryResponse that contains an array of POICategorys.