문제

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.

도움이 되었습니까?

해결책

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...

다른 팁

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.

Check Link

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top