0

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.

Dan Flict
  • 117
  • 8

0 Answers0