Get name of closest business using Swift's CoreLocation

631 views Asked by At

I want to get the name of a business given its latitude and longitude. There are other APIs that do this like Google Places, but I'd rather not have additional dependencies in my app if I can help it. Is there any way to do this via CoreLocation in Swift? I know you can get an address "name" from a latitude and longitude using this:

let geocoder = CLGeocoder()
geocoder.reverseGeocodeLocation(location) { (placemarks, error) in
    placemarks?.first?.name
}

But this only gives me the street number, not the actual name of the business like "Costco" or whatever it's really called.

1

There are 1 answers

0
Marcos Reboucas On

You can use Areas of Interest information from CLPlacemark, as in documentation:

Examples of an area of interest are the name of a military base, large national park, or an attraction such as the Eiffel Tower, Disneyland, or Golden Gate Park

Check it here: https://developer.apple.com/reference/corelocation/clplacemark/1423673-areasofinterest

And here for all info available: https://developer.apple.com/reference/corelocation/clplacemark