I'm trying to get the business name from a CLLocation
. I am able to get the exact street address by reverse geocoding the CLLocation
, but am unable to get the name of the business, as the name
property on CLPlacemark
is just the address.
I have tried:
- Accessing the
name
property onCLPlacemark
: returns street address - Accessing the
areasOfInterest
property onCLPlacemark
: returns nil - Using
MKLocalSearchCompleter
with the query set to the street address returns street address - Using
MKLocalSearch
with the query set to the street address returns nothing
What's strange is that the Apple Maps app allows you to search for the street address and the business name will come up for most locations (and use the address as a fallback, as seen here), but I cannot replicate this feature with the exposed API's. Is what I'm wanting simply not possible with MapKit?
CLGeocoder().reverseGeocodeLocation(location, completionHandler: { (placemarks, error ) in
guard let placemarks = placemarks else {
fatalError("Error: failed to reverse geocode location. \(error?.localizedDescription ?? "")")
}
for placemark in placemarks {
print(placemark.name)
}
// Do something to get the *true* placemark name.
})