Specialized search
Search along a route
Use this search to find POIs along a specific route with the fuzzy search algorithm. The search is constrained by a time limit for detours from the route. The route must consist of at least 2 points. You can use the Routing module to create a route.
See the instructions in the planning a route. To create the request you need to create SearchOptions
. The query
, route
, and maxDetourTime
(in seconds, with a maximum of 3600) parameters are required. You can also specify more detailed options for the underlying Fuzzy Search. More information about Along Route Search is in the Search API Along Route Search documentation.
1let query = "ATM"2let alongRouteSearchOptions = SearchOptions(3 query: query,4 route: route,5 maxDetourDuration: .tt.seconds(600),6 limit: 107)
Parameter completion: The completion closure is called after the response to the request has been processed. If no errors occurred, SearchResponse
contains an array of categories and subcategories together with their translations and synonyms.
1onlineSearch.search(options: alongRouteSearchOptions) { result in2 switch result {3 case let .success(alongRouteResponse):4 // handle success5 break6 case let .failure(error):7 // handle error8 break9 }10}
Geometry search
The geometry search allows you to perform a free-form search inside one or more defined geographic areas (geometries). By default, POIs are returned as a result. For other result types, the idxSet parameter should be used.
There are two types of geometries that are supported:
PolygonGeometry
- an array of coordinates of vertices.1let vertices: [CLLocationCoordinate2D] = [2 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),3 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),4 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),5 CLLocationCoordinate2D(latitude: 52.377956, longitude: 4.897070),6]7let polygon = PolygonGeometry(vertices: vertices)CircleGeometry
- center coordinates and a radius in meters..
Provide the geometries and query to initialize the SearchOptions
by defining the searchAreas
parameter.. You can also define optional parameters such as the number of results to return, language, and various constraints on what is searched for. More information about optional parameters and the geometry search can be found in the Search API Geometry Search documentation.
let options = SearchOptions(query: "Pizza", searchAreas: polygon)
If the search was successful, the response is presented as a SearchResponse
object. Otherwise, error is returned.
1let onlineSearch = OnlineSearch(apiKey: "REPLACE_WITH_YOUR_API_KEY")2onlineSearch.search(options: options) { result in3 switch result {4 case let .success(geometrySearchResponse):5 // handle success6 break7 case let .failure(error):8 // handle error9 break10 }11}
Geometry data search
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.
.
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}