mapkitlocation-servicesmkreversegeocoder

Is it possible to get a list of places near a Lat/Long using MapKit?


I'm trying to build a simple location search that returns a list of places near the user. So for example, using current location, or a given Latitude and Longitude I want to list out all place names, businesses, towns, etc. within a certain radius. Is this possible using MapKit? I know it's easy to do using Facebook graph API.

The best I can find is to do CLGeocoder().reverseGeocodeLocation but that just returns the nearest address. I even tried using

CLLocation(
    coordinate:CLLocationCoordinate2D, 
    altitude:CLLocationDistance, 
    horizontalAccuracy:CLLocationAccuracy, 
    verticalAccuracy:CLLocationAccuracy, 
    timestamp:Date
)

and setting the accuracy to 1,000 meters, but that didn't increase the number of results either. So, my assumption is that with MapKit, you can not get a list of place results around a given point. Is that true?

For good measure, here is the code I'm calling.

        let latitude = CLLocationDegrees(40.692001)
        let longitude = CLLocationDegrees(-73.983386)
        let location = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
        let altitude = CLLocationDistance(1000.0)
        let accuracy = CLLocationAccuracy(1000.0)
        let locationArea = CLLocation(coordinate: location, altitude: altitude, horizontalAccuracy: accuracy, verticalAccuracy: accuracy, timestamp: Date())
        let geocoder = CLGeocoder()
        geocoder.reverseGeocodeLocation(locationArea) { (placemarks, error) in
            if error == nil {
                print(placemarks!.count)
                for place in placemarks! {
                    print(place)
                }
            } else {
                print(error!)
            }
        }

Solution

  • Unless the API has changed, I believe the answer is no. I ended up using the facebook places API.