views:

50

answers:

3

Hi Stackoverflow

I am doing a map based application in iphone and i am need to get the location of the center of the map view. I need to get the location updated when the user Drags/Moves/Zoom the mapview. So that I can get the lat/lng information from the map and can sent these information to the google api to get the address info.

Can any one have any idea about how this can be made possible? Please help.

Thanks in advance Shibin M

+2  A: 

to get address information from google api you have to use reverseGeocoder.

here you pass your lat/long.

MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];

reverseGeocoder.delegate = self;

[reverseGeocoder start];

and here you get address info

-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { NSDictionary *address =[[NSDictionary alloc]initWithDictionary:placemark.addressDictionary];

NSLog(@"%@",address);

}

priyanka
+1  A: 

1st you must check that your iphone's GPS is activate or not

than I think it must work if not send me code I try to help you or this code

MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];

reverseGeocoder.delegate = self;

[reverseGeocoder start];

and here you get address info

-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { NSDictionary *address =[[NSDictionary alloc]initWithDictionary:placemark.addressDictionary];

NSLog(@"%@",address);

}

+1  A: 

Could you please specify which part of this code should be written in .h and which should be written in .m with little explanation of the code. Sorry for asking more but i am really new to all these things and having hard time understanding the code.

Thanks,

Ashutosh