Question

The documentation for

- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;

The documentation clearly states:

In the case of forward-geocoding requests, multiple placemark objects may be returned if the provided information yielded multiple possible locations.

states that it returns an array of placemarks. However, even if I search for objects I know for certain have multiple entries (Hollywood, washington, Denmark, main street, ect.) i always only get one entry.

Some people just shrug and say use the google API instead, but i fear for the request limit.

Is there some setting or hack to fix this, or is the CLGeocoder simply broken ?

Was it helpful?

Solution

I would definitely suggest using Google Geocoding API - it is simply superior. I also argue, that you should not fear the usage limit for Google Geocoding APIs requests.

If you are developing mobile application, I suggest implementing client-side geocoding - that means, that every device queries directly Google API. As it is directly stated in Google's own documentation

geocoding limits are per user session, there is no risk that your application will reach a global limit as your userbase grows.

More info in geocoding strategies docs and geocoding docs.

OTHER TIPS

MKLocalSearch is the answer here:

let request = MKLocalSearch.Request()
request.naturalLanguageQuery = "addressToBeSearched"
request.region = MKCoordinateRegion(center: span: )
let localSearch = MKLocalSearch(request: request)

localSearch.start { response, error in
    // returns (MKLocalSearch.Response?, Error?) -> Void
    // which ultimately has an array of MKMapItem from which you can extract a placemark.
}

This returns the nearby and not only, points of interest, places, etc. The only drawback I can think of is that you have to provide the current location in the initializer for MKCoordinateRegion and the span.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top