【发布时间】:2016-05-25 06:47:15
【问题描述】:
我从 api 获取纬度和经度,并且需要从这些坐标中获取地名,以便我使用这段代码
CLGeocoder *ceo = [[CLGeocoder alloc]init];
CLLocation *LocationAtual=[[CLLocation alloc] initWithLatitude:[[latlong objectForKey:@"latitude"] doubleValue]
longitude:[[latlong objectForKey:@"longitude"] doubleValue]];
NSLog(@"loc %@", LocationAtual);
[ceo reverseGeocodeLocation:LocationAtual completionHandler:^(NSArray *placemarks, NSError *error)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"placemark %@",placemark);
//String to hold address
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
NSLog(@"addressDictionary %@", placemark.addressDictionary);
NSLog(@"placemark %@",placemark.region);
NSLog(@"placemark %@",placemark.country); // Give Country Name
NSLog(@"placemark %@",placemark.locality); // Extract the city name
NSLog(@"location %@",placemark.name);
NSLog(@"location %@",placemark.ocean);
NSLog(@"location %@",placemark.postalCode);
NSLog(@"location %@",placemark.subLocality);
NSLog(@"location %@",placemark.location);
NSLog(@"I am currently at %@",locatedAt);
NSLog(@" ");
}
];
但是当我控制这条线时
[ceo reverseGeocodeLocation:LocationAtual completionHandler:^(NSArray *placemarks, NSError *error)
此代码块未执行。控制去。
【问题讨论】:
-
是的先生,我对这个概念有疑问
-
是的,先生,我会读到它,但你现在能帮我吗
-
从这里获取它@sandeep stackoverflow.com/questions/14346516/…
-
@sandeeptomar 请打印您的 LocationAtual 值。
-
@DharmbirSingh 这些是先生 28.566540 77.209841 错误我从 api 获取这些值
标签: ios objective-c google-geocoder