I am using CLGeocoder and reverseGeocodeLocation to get my CLPlacemark. How come the name mostly comes back as an address and areasOfInterest come back as nil? For example... the areasOfInterest appear for really major things like apple HQ and airports, things of that sort but stores such as Walmart, Publix blah blah are nil. Should I be searching another way? Am I expecting more information than is available with this method? I mean, Apple has these points of interest on their maps, is there another way I should be trying to get this information?
Here are a few location lat longs that I've tried in my area that aren't bringing back the store names. These came from google and when put into apple maps, it beings you right on top of the correct location but it doesn't associate either... This makes me think I should be doing something different to being back the name of the store. Other info like a description or category would be nice as well.
Note: I am only wanting the information, I am not trying to place it on a map or anything.
Walmart: 35.0944° N, 85.3319° W
Aquarium: 35.0558° N, 85.3111° W
Publix: 35.0651° N, 85.3083° W
Small bit of my code. All works just wanted to give you an adea of what im bringing back and how.
CLGeocoder().reverseGeocodeLocation(manager.location!, completionHandler: {(placemarks, error)->Void in
if placemarks != nil
{
if error == nil && placemarks!.count >= 1 {
let thePlacemarks = placemarks![0] as CLPlacemark
print(placemarks)
print(thePlacemarks.areasOfInterest?.description)
print(thePlacemarks.administrativeArea?.description)
print(thePlacemarks.areasOfInterest?.description)
print(thePlacemarks.country?.description)
print(thePlacemarks.inlandWater?.description)
print(thePlacemarks.isoCountryCode?.description)
print(thePlacemarks.locality?.description)
print(thePlacemarks.location?.description)
print(thePlacemarks.name?.description)
print(thePlacemarks.ocean?.description)
print(thePlacemarks.subAdministrativeArea?.description)
print()
}
}
})
Any help would be great!
Thanks!
So... Not necessarily ideal but by using mapkit I was able to do a MKLocalSearch to get what I wanted. This only works because I have an array in my code of the specific locations I am interested in. See me code below.
Then somewhere in your ViewController
Here is a little function I found to get the distance between two coordinates.