Is it all possible to show nearby places with MKLocalSearchRequest without supplying a naturalLanguageQuery?
I'm aware that the typical route is to use foursquare or google for this. I've used both.
Is it all possible to show nearby places with MKLocalSearchRequest without supplying a naturalLanguageQuery?
I'm aware that the typical route is to use foursquare or google for this. I've used both.
You can achieve it for demo purposes as follows, but I wouldn't recommend using this approach in a production app as it's obviously 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)
}
}
My strategy is
Pseudo code is here.
Another solution works only for POI.