Reputation: 3291
I am new in iphone development and right now i am facing problem for developing developing an application in which i need to get coordinate(lat, long) when user tapped on screen for two second and also get user location name,i got coordinate but i am unable to get user location name on which user tapped. so kindly help me on that?
Upvotes: 2
Views: 2145
Reputation: 37985
In iOS 5+ use CLGeocoder
and its reverseGeocodeLocation:completionHandler:
method.
In your case, you're probably most interested in the areasOfInterest
property.
Example:
CLGeocoder* gc = [[CLGeocoder alloc] init];
double lat, lon; // get these where you will
[gc reverseGeocodeLocation:[[CLLocation alloc] initWithLatitude:lat longitude:lon] completionHandler:^(NSArray *placemarks, NSError *error) {
for ( CLPlacemark* place in placemarks ) {
if ( place.region )
NSLog( @"%@", place.region );
// throroughfare is street name, subThoroughfare is street number
if ( place.thoroughfare )
NSLog( @"%@ %@", place.subThoroughfare, place.thoroughfare );
for ( NSString* aoi in place.areasOfInterest )
NSLog( @"%@", aoi );
}
}];
Upvotes: 1