MKLocalsearchRequest next to places WITHOUT natural languageQuery string

Is it possible to show neighboring places using MKLocalSearchRequest without supplying naturalLanguageQuery?

I know that a typical route is to use four or four for this. I used both.

+6
source share
2 answers

I tried to achieve this for some time, but the closest I came using a for loop, which runs several queries and adds the results to the main array. INCREDIBLY inefficient, have you had more success?

0
source

You can achieve this for demonstration purposes as follows, but I would not recommend using this approach in a production application, since it is clearly not scalable.

var nearbyPlaces: [MKMapItem] = [] let params: [String] = ["bar", "shop", "restaurant", "cinema"] let request = MKLocalSearchRequest() let span = MKCoordinateSpan(latitudeDelta: CLLocationDegrees(exactly: 1000)!, longitudeDelta: CLLocationDegrees(exactly: 1000)!) let region = MKCoordinateRegion(center: coord, span: span) request.region = region for param in params { request.naturalLanguageQuery = param let places = MKLocalSearch(request: request) places.start { [unowned self] response, error in guard let result = response else { return } self.nearbyPlaces.append(contentsOf: result.mapItems) } } 
0
source

Source: https://habr.com/ru/post/974928/


All Articles