IOS 经纬度 转换地理位置信息


-(NSString *)latitudeStr:(NSString *)Latitude LongitudeStr:(NSString *)Longitude
{
    static NSString * addstroing = @"";
    
    NSString * A = Latitude;
    NSString * B = Longitude;
    float a = [A floatValue];
    float b = [B floatValue];
    
    CLLocation * location = [[CLLocation alloc] initWithLatitude:a longitude:b];
    
    //位置反编码, IOS5.0之后
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
        for (CLPlacemark *placemark in placemarks) {
            //CLPlacemark 地标
//            NSLog(@"位置:%@", placemark.name);
//            NSLog(@"街道:%@", placemark.thoroughfare);
//            NSLog(@"子街道:%@", placemark.subThoroughfare);
//            NSLog(@"市:%@", placemark.locality);
//            NSLog(@"区\\县:%@", placemark.subLocality);
//            NSLog(@"行政区:%@", placemark.administrativeArea);
//            NSLog(@"国家:%@", placemark.country);
            
            addstroing = [NSString stringWithFormat:@"%@%@%@%@",placemark.administrativeArea,placemark.locality,placemark.subLocality,placemark.thoroughfare];
            
            addressLabel.text = placemark.name;

        }
    }];
    
    return addstroing;
}

你可能感兴趣的:(IOS,iOS)