tags:

views:

168

answers:

2

Hi all,

I have been researching a few different apps lately for my company which are all able to convert your current GPS location to an address. I have been googling and searching through the stack but I can't seem to find any helpful information on the net to tell me how to achieve this. So my question is this; how do you a) get your current GPS coordinates and then b) transform them into a real address i.e. street number/name, city, country

cheers guys

+1  A: 

a) get your current GPS coordinates

You need to use CLLocationManager for that (you may need to store manager to release it when it no longer will be needed) -

CLLocationManager* manager = [[CLLocationManager alloc] init];
manager.delegate = self;
//Set location manager's properties if needed
[manager startUpdatingLocation];

Then your delegate object will be able to receive messages when GPS location updates (or fails to do that):

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

b) transform them into a real address

After you have gps coordinate of tour location you can create MKReverseGeocoder object to query google reverse geocoding service. If request succeeds geocoder's delegate will receive MKPlacemark object with address info.

Vladimir