Here i m detailing, how to get detail information from lat/long.
for .h file.
import framework
implement MKMapViewDelegate and MKReverseGeocoderDelegate
Declare MKReverseGeocoder *reverseGeocoder;
@property (nonatomic, retain) MKReverseGeocoder *reverseGeocoder;
for .m file.
@synthesize reverseGeocoder;
CLLocationCoordinate2D coord2d;
coord2d.latitude =19.3;
coord2d.longitude =73.9 ;
self.reverseGeocoder =[[[MKReverseGeocoder alloc] initWithCoordinate:coord2d] autorelease];
Note: If we get data detail for Current location then we can use below statement:
[[[MKReverseGeocoder alloc] initWithCoordinate:mapView.userLocation.location.coordinate] autorelease];
reverseGeocoder.delegate = self;
[reverseGeocoder start];- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
NSString *errorMessage = [error localizedDescription];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Cannot obtain address."
message:errorMessage
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(@"Thoroughfare : %@",placemark.thoroughfare);
NSLog(@"Sub-thoroughfare : %@",placemark.subThoroughfare);
NSLog(@"Locality : %@",placemark.locality);
NSLog(@"Sub-locality : %@",placemark.subLocality);
NSLog(@"Administrative Area : %@",placemark.administrativeArea);
NSLog(@"Sub-administrative Area : %@",placemark.subAdministrativeArea);
NSLog(@"Postal Code : %@",placemark.postalCode);
NSLog(@"Country : %@",placemark.country);
NSLog(@"Country Code: %@",placemark.countryCode);
}
No comments:
Post a Comment