Understanding Geocoding on the iPad
Being able to go from a coordinate on a map to an address is called reverse geocoding, and
MapKit used to supply the ability to do that. But whereas
MapKit implemented reverse geocoding, forward geocoding — the kind of geocoding that converts an address to a coordinate — just became available with iOS 5. Now, both forward and reverse geocoding can be found together in a new class — the
CLGeocoder class — and both have been moved to the
CoreLocation framework. So now, all’s right with the world. (Previously, you had to use one of the free or commercial services available to do forward geocoding.)
CLGeocoder class (which is part of the
CoreLocation framework that I show you how to add in Chapter 11) provides services for converting between a coordinate (specified as a latitude and longitude) and the user-friendly representation of that coordinate. User-friendly representation of the coordinate is the technical term for the street, city, state, and country information of a given location or a relevant point of interest, landmark, or other identifying information. The
CLGeocoder class also provides services for the reverse: returning the coordinate value for a text string that is the user-friendly representation of that coordinate.
To use a
CLGeocoder object, first create it and then send it a forward- or reverse-geocoding message.