Reputation: 27
I have been completed drawing the route between two places using ClLocationCoordinate2D on map in ios 6 dynamically.Can anyone please help me out in getting the location name using CLPlacemark and CLGeocoder as reverse geocoder has been deprecated in ios 6.
Upvotes: 0
Views: 3450
Reputation: 20541
you can get information like bellow with its Delegate method..
UPDATE:
First Define this variable in .h
file like bellow..
NSString *postcode,*locationName;
and use it in bellow method...
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
for (CLPlacemark * placemark in placemarks) {
postcode = [placemark postalCode];
[postcode retain];
locationName = [placemark name];
[locationName retain];
NSLog(@"\n placemark %@",placemarks);
}
}];
[geoCoder release];
NSLog(@"\n Location Name ==> %@ ----> GotPostCode:%@",locationName,postcode);
}
here you can also use other property of CLGeocoder
like locality
,location
,etc...
Upvotes: 1
Reputation: 3203
A CLPlacemark object stores placemark data for a given latitude and longitude. Placemark data includes information such as the country, state, city, and street address associated with the specified coordinate.
Upvotes: 0