CLGeocoder's geocodeAddressString always return an array with only one CLPlacemark object

CLGeocoder's geocodeAddressString function always return an array with only one CLPlacemark object, independently of the string passed as a parameter.

I'm using it like this:

let placesArray = try await CLGeocoder().geocodeAddressString(addressString)

CLGeocoder's documentation is clear:

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

But that never happens. Even when passing something like "San" which should obvioulsy return an array with many CLPlacemark possibilities.

I've seen this same question asked in multiple places (like here, here, here, and here) but I can't find an answer.

Is this a bug? Am I doing something wrong? How can I obtain multiple possible locations from CLGeocoder?

EDIT: MKLocalSearch

I tried the same thing using MKLocalSearch:

let searchRequest = MKLocalSearch.Request()
searchRequest.naturalLanguageQuery = addressString

let search = MKLocalSearch(request: searchRequest)
let responses = try await search.start()

Same problem, the returned MKLocalSearch.Response's mapItems array always contains only one object. Very strange.

I tested and effectively always get a single location.

I suspect that returning multiple locations is an exception, when there is really an ambiguity that cannot be resolved.

How does CLGeocoder tries to resolve and when does it fail is another question.

  • seems to search around a found location (the first ?), in a certain radius
  • then if there is another location with same address, it could report a second location.

But that's just a guess after observing on a few examples what I get.

If this is critical to you, you could burn a DTS ticket. Good luck.

CLGeocoder's geocodeAddressString always return an array with only one CLPlacemark object
 
 
Q