Whatever address i give to the geocoder ([geocoder geocodeAddressString:completionHandler:), it always puts only one object in the placemarks array.
I there any way to get multiple results (like in Maps app) from which the user can select one?
Whatever address i give to the geocoder ([geocoder geocodeAddressString:completionHandler:), it always puts only one object in the placemarks array.
I there any way to get multiple results (like in Maps app) from which the user can select one?
I've done some sniffing on the packets and it seems that CLGeocoder doesn't connect to Google's geocoding service, but to Apple's. I've also noticed that I get only one placemark from there every time.
If you want something more sophisticated you should use Google's or other geocoding. I use SVGeocoder (https://github.com/samvermette/SVGeocoder), which has a very similar API to CLGeocoder.
Apple's native geocoding service is provided by the MapKit framework. The important object in this framework is
MKLocalSearch
, which can geocode addresses and return multiple results.MKLocalSearch returns back 10 results in
mapItems
of typeMKMapItem
. Each MKMapItem contains aMKPlacemark
object, which is a subclass ofCLPlacemark
.Here's an example using MapKit's
MKLocalSearch
: