我想从lat和long找到地名。我正在使用google place api。 我怎样才能实现这个目标
现在我可以使用此
在该纬度附近搜索答案 0 :(得分:1)
您可以使用MKReverseGeoCoder获取给定纬度和经度的名称,区域,信息等。但是,请注意它已被弃用。
ViewController应该是MKReverseGeocoderDelegate的委托。 MKReverseGeoCoder的示例用法是;
- (void)viewDidLoad {
CLLocationCoordinate2D coordinates;
coordinates.latitude = 33.8670522;
coordinates.longitude = 151.1957362;
CLLocation *location = [[CLLocation alloc] initWithLatitude:coordinates.latitude longitude:coordinates.longitude];
MKReverseGeocoder* rev = [[MKReverseGeocoder alloc] initWithCoordinate:location.coordinate];
rev.delegate = self;
[rev start];
[super viewDidLoad];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
NSLog(@"Error with reverse geo coder.");
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
NSLog(@"Geo coder finished successfully");
NSString *administrativeArea = placemark.administrativeArea;
NSString *thoroughfare = placemark.thoroughfare;
NSLog(@"%@ %@", administrativeArea, thoroughfare);
}