【问题标题】:objective-c google maps delegate method reverseGeocodeCoordinate methodObjective-c 谷歌地图委托方法 reverseGeocodeCoordinate 方法
【发布时间】:2014-03-22 20:36:52
【问题描述】:

我不确定这是否是谷歌地图的新功能,但我认为这个版本的 iOS 版谷歌地图似乎已经有了反向地理编码方法……我真的不知道如何使用。 In their documentation page,在相机位置部分下,它们有一个功能,但它看起来不像 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];
}

【问题讨论】:

    标签: ios objective-c google-maps geocoding reverse-geocoding


    【解决方案1】:

    你可以试试这个代码

    [[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);
        } 
    }];
    

    【讨论】:

      猜你喜欢
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多