IApp
IApp

Reputation: 667

Longitude/Latitude to Postcode?

Basically I have an iOS app that I want to find the parliamentary constituency that you are currently in based on geolocation, I can do this if I have the postcode (It has the be the full postcode as in "AA00 0AA" unlike the incomplete postcode Google Maps can supply). I therefore need to convert Longitude and Latitude to a postcode but I can't seem to find out how to do it. Any help/ideas would be much appreciated.

Upvotes: 2

Views: 1007

Answers (1)

Henri Normak
Henri Normak

Reputation: 4725

Take a look at CLGeocoder, it allows reverse-geocoding, which is the process of transforming a coordinate into an address. It uses iOS 5 and the method signature your looking for is this

- (void)reverseGeocodeLocation:(CLLocation *)location 
        completionHandler:(CLGeocodeCompletionHandler)completionHandler

Pay attention to the CLPlacemarks the geocoder returns and the fact that they have a field postalCode, which should contain the info you are looking for. Be warned though, the field can also be empty (as with every other field of CLPlacemark) and the CLGeocoder may not always return a useable result.

Upvotes: 4

Related Questions