CLLocation forward GeoLocation method
The new MapKit framework for the iPhone OS 3.0 provides a very easy to use way of doing reverse geolocation (getting address information by providing latitude and longitude). But, it would seem that there is nothing built in for getting latitude and longitude values for a given address. Luckily, Google to the rescue! The following code-snippet is a category on CLLocation with the one method
- (CLLocation *)locationUsingForwardGeoLocation:(NSString *)address; |
which takes an address string, and, using Google maps API, does a lookup and returns a CLLocation object for the given address. If no address could be found then nil is returned.
Usage is very simple:
CLLocation *ottawa = [CLLocation locationUsingForwardGeoLocation:@"Ottawa, Ontario"]; // Do whatever with the returned CLLocation object |
CLLocation+ForwardGeoLocation.h View
CLLocation+ForwardGeoLocation.m View
Report any bugs or issues here
Credit for some of the code and the original idea go to http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial/


