Additional Data
Geometry data request
Geometry data search is used to obtain geometries to represent the outline of a city, county, or land area. It supports batch requests for up to 20 identifiers per call. To build the Geometry Data search request, use the GeometryDataQuery
. The only required parameter is a list of identifiers you want to get geometry for. To get these identifiers, first get the DataSources
of the selected SearchResult
s of a Fuzzy Search. Then use its GeometryDataSources
property to get the geometry ID.
Not every
SearchResult
has this information.
let geometryIDs = searchResponse.results.compactMap { $0.searchResultID.geometryDataSourceID }let options = GeometryDataOptions(geometryIDs: geometryIDs, geometryZoom: 15)
You can provide an optional zoom level parameter, which defines the precision of the returned geometries. For more information about the additional data search, go to the Search API Additional Data Search documentation.
The call returns an GeometryDataResponse
object, or an Error
if the request did not succeed.
1let onlineSearch = OnlineSearch(apiKey: "REPLACE_WITH_YOUR_API_KEY")2onlineSearch.requestGeometryData(options: options) { result in3 switch result {4 case let .success(additionalDataResponse):5 // handle success6 break7 case let .failure(error):8 // handle error9 break10 }11}
POI details request
Use POI details API to obtain information about a point of interest.
To perform a call, you need to obtain a unique POI identifier and then use it to create a POIDetailsOptions
.
To obtain a unique POI identifier you could use fuzzy search with resultTypes
set to poi
.
You can request POI details in different languages. See the list of supported languages.
Specify the desired response language when creating a POIDetailsOptions
using a locale
parameter.
If no language is specified, categories will be returned in English.
1let amsterdamCenter = CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070)2let poiOptions = SearchOptions(3 query: "Restaurant",4 geoBias: amsterdamCenter,5 resultTypes: [.poi]6)7onlineSearch.search(options: poiOptions) { [weak onlineSearch] result in8 switch result {9 case let .success(poiSearchResponse):10 guard let result = poiSearchResponse.results.first,11 let resultID = result.searchResultID.id,12 let poiID = try? POIID(id: resultID, source: result.searchResultID.source) else {13 return14 }1516 let options = POIDetailsOptions(17 poiID: poiID,18 locale: Locale(identifier: "en_GB")19 )2021 onlineSearch?.requestPOIDetails(options: options) { result in22 switch result {23 case let .success(poiDetailsResponse):24 // handle success25 break26 case let .failure(error):27 // handle error28 break29 }30 }3132 case let .failure(error):33 // handle error34 break35 }36}
As a result, you will get a POIDetailsResponse
that contains POIDetails
with updated poi
property.
More detailed information about this service can be found in the Search API Place by ID documentation.
POI Categories request
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 a POICategoryOptions
where you can specify the desired response language.
If no language is specified, categories will be returned in system language and in English if system language is not supported.
let options = POICategoryOptions(locale: Locale(identifier: "en_GB"))
As you created the query, you can:
1let onlineSearch = OnlineSearch(apiKey: "REPLACE_WITH_YOUR_API_KEY")2onlineSearch.requestPOICategories(options: options) { result in3 switch result {4 case let .success(poiCategoriesResponse):5 // handle success6 break7 case let .failure(error):8 // handle error9 break10 }11}
As a result you will get a: POICategoryResponse
that contains an array of POICategory
.