I'm trying to make an address search using the MKLocalSearchCompleter
. I've provided it with a region(Australia) but the provided region is completely ignored, I still get results from around the world.
...
private var searchCompleter = MKLocalSearchCompleter()
....
init {
searchCompleter.region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: -25.2744, longitude: 133.7751), span: MKCoordinateSpan(latitudeDelta: 40, longitudeDelta: 40)) // Australia
searchCompleter.resultTypes = [.address]
searchCompleter.delegate = self
searchCompleter.queryFragment = "Wycombe Road"
}
extension MapSearchCompleter: MKLocalSearchCompleterDelegate {
func completerDidUpdateResults(_ completer: MKLocalSearchCompleter) {
print("+++ \(completer.results)")
}
}
If I try to print the region in the delegate method completerDidUpdateResults
, I get the region back.
+++ MKCoordinateRegion(center: __C.CLLocationCoordinate2D(latitude: -25.2744, longitude: 133.7751), span: __C.MKCoordinateSpan(latitudeDelta: 40.0, longitudeDelta: 40.0))
Any idea how to make it work? Not sure what I'm doing wrong here.
I can just filter out addresses manually, but I don't think that the right way to do it.