Hi,
I have a controller where the user can search for map locations or points of interest by typing inside a search box.
To retrieve the list of results I set the queryFragment parameter of a MKLocalSearchCompleter with the search content. This correctly gives me back a list of MKLocalSearchCompletion of locations and points of interest.
When a user tap on one of this locations, I need to load the coordinates. In order to do that I do a MKLocalSearch passing the selected MKLocalSearchCompletion, like so:
let item = items[indexPath.row]
let request = MKLocalSearch.Request(completion: item)
let search = MKLocalSearch(request: request)
search.start { (response, error) in
//Do stuff with the result.
//For some specific items I receive an MKErrorDomain 4 error.
}
This works most of the time, but for some specific items the MKLocalSearch call return the error:
Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8}
This error correspond to "placemarkNotFound", ie MapKit is not able to find a placemark for the specific MKLocalSearchCompletion. I just don't understant why this should be the case. The MKLocalSearchCompletion is returned by MapKit. If it is returned by MapKit then a corresponding placemark should exist, right? Why then is MapKit unable to perform a local search on it?
The problem now is that I present the user with a list of completions returned by MapKit but tapping some of them nothing happens because I cannot determine their respective coordinates.
Why is the search failing sometime? I miss something?
Thank you