我不确定这是否是谷歌地图的新功能,但我认为这个版本的 iOS 版谷歌地图似乎已经有了反向地理编码方法……我真的不知道如何使用。 In their documentation page ,在 Camera Position 部分下,它们有一个功能,但它看起来不像是 SDK 附带的功能......或者这里可能有一些我不明白的地方。有人可以帮忙吗?这是 XCode 中出现的函数:
- (void)reverseGeocodeCoordinate:(CLLocationCoordinate2D)coordinate
completionHandler:(GMSReverseGeocodeCallback)handler{}
如果我的坐标在一个数组中,我该如何使用它?我如何获得地址和国家以及所有可能的结果?
顺便说一句,这就是他们所拥有的......它如何比较:
- (void)mapView:(GMSMapView *)mapView
idleAtCameraPosition:(GMSCameraPosition *)cameraPosition {
id handler = ^(GMSReverseGeocodeResponse *response, NSError *error) {
if (error == nil) {
GMSReverseGeocodeResult *result = response.firstResult;
GMSMarker *marker = [GMSMarker markerWithPosition:cameraPosition.target];
marker.title = result.addressLine1;
marker.snippet = result.addressLine2;
marker.map = mapView;
}
};
[geocoder_ reverseGeocodeCoordinate:cameraPosition.target completionHandler:handler];
}
最佳答案
你可以试试这段代码
[[GMSGeocoder geocoder]reverseGeocodeCoordinate:CLLocationCoordinate2DMake(latitude, longitude)
completionHandler:^(GMSReverseGeocodeResponse * response, NSError *error){
for(GMSReverseGeocodeResult *result in response.results){
NSLog(@"addressLine1:%@", result.addressLine1);
NSLog(@"addressLine2:%@", result.addressLine2);
}
}];
关于ios - objective-c 谷歌地图委托(delegate)方法 reverseGeocodeCoordinate 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22583240/