Any ideas why I might be getting the below error when starting an MKLocalSearch? I've looked everywhere and can't seem to find any information on this.
The error being printed is (from the guard let): Failed searching for businesses: Error Domain=MKErrorDomain Code=2 "(null)" UserInfo={MKErrorGEOError=-7}
let searchSpan = MKCoordinateSpan(latitudeDelta: 0.000018011, longitudeDelta: 0.000018011)
let searchRegion = MKCoordinateRegion(center: location, span: searchSpan)
let searchRequest = MKLocalSearch.Request()
searchRequest.region = searchRegion
searchRequest.resultTypes = .pointOfInterest
searchRequest.naturalLanguageQuery = "bar"
let search = MKLocalSearch(request: searchRequest)
search.start { response, error in
guard let mapItems = response?.mapItems else {
print("Failed searching for businesses: ", error!)
return
}
I want to say the error I was getting was a server error due to an overload of MKLocalSearch requests. Reason being, I was getting multiple coordinates back when I would call .startUpdatingLocation() from my LocationManager which would trigger multiple search requests (because I had it setup this way). I can't find anywhere online how to avoid getting multiple coordinates back even AFTER calling .stopUpdatingLocation() so I decided to add a debouncer on the request so only one could be sent at a time. This seems to have fixed my issue.