POI details and categories
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 .
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.
let amsterdamCenter = CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070)let options = SearchOptions( query: "Restaurant", geoBias: amsterdamCenter, resultTypes: [.poi])
onlineSearch.search(options: options) { [weak self] result in switch result { case let .success(poiSearchResponse): guard let result = poiSearchResponse.results.first, let resultID = result.searchResultID.id, let poiID = try? POIID(id: resultID, source: result.searchResultID.source) else { return }
let poiDetailsOptions = POIDetailsOptions( poiID: poiID, locale: Locale(identifier: "en_GB") )
self?.onlineSearch.requestPOIDetails(options: poiDetailsOptions) { result in switch result { case let .success(poiDetailsResponse): // handle success break case let .failure(error): // handle error break } }
case let .failure(error): // handle error break }}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:
let onlineSearch = OnlineSearchFactory.create(apiKey: "YOUR_TOMTOM_API_KEY")onlineSearch.requestPOICategories(options: options) { result in switch result { case let .success(poiCategoriesResponse): // handle success break case let .failure(error): // handle error break }}As a result you will get a: POICategoryResponse that contains an array of POICategory s.