Reputation: 41
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:
name
property on CLPlacemark
: returns street addressareasOfInterest
property on CLPlacemark
: returns nilMKLocalSearchCompleter
with the query set to the street address returns street addressMKLocalSearch
with the query set to the street address returns nothingWhat'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.
})
Upvotes: 2
Views: 416