iosmapkitclplacemark

CLPlacemark location gives district info too, why?


I need only the city info of client recent location and not district. Any idea how to avoid?

pm.locality returns: Budapest VII. kerület, I would expect only Budapest.

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {

        CLGeocoder().reverseGeocodeLocation(locations.first as CLLocation, completionHandler: {placemarks, error in

            let pm = placemarks.first as CLPlacemark

Solution

  • I would expect

    That's your problem right there. CLPlacemarks obtained by reverse geocoding categorize their pieces the way they categorize them, not the way you expect.

    So the solution here is to stop expecting and start dealing with the placemark so that you can obtain the results you want. For example, try extracting the placemark's addressDictionary and see if you can use its categorizations any more easily.

    Also, try examining other properties of the placemark. Maybe its sublocality is closer to what you are hoping for. Or maybe it's some other property.