【发布时间】:2013-05-21 12:21:22
【问题描述】:
我想从 lat 和 long 中找到地名。我正在使用 google place api。 我怎样才能做到这一点
现在我可以用这个来搜索附近的纬度和经度了
【问题讨论】:
标签: objective-c google-maps google-places-api
我想从 lat 和 long 中找到地名。我正在使用 google place api。 我怎样才能做到这一点
现在我可以用这个来搜索附近的纬度和经度了
【问题讨论】:
标签: objective-c google-maps google-places-api
您可以使用 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);
}
【讨论】: