Question

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.

Était-ce utile?

La solution

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top