从目标C中用户的当前位置(纬度,经度)获取区域或区域名称

时间:2017-08-14 06:12:27

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

我正在尝试使用反向地理编码从用户的当前位置获取区域或区域。我正在使用 GMSGeocoding 但无法获取区域名称或区域

[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(lat, lng) completionHandler:^(GMSReverseGeocodeResponse* response, NSError* error) {
    NSLog(@"reverse geocoding results:");

   GMSAddress * address=[response firstResult];
    NSLog(@"coordinate.latitude=%f", address.coordinate.latitude);
    NSLog(@"coordinate.longitude=%f", address.coordinate.longitude);
    NSLog(@"thoroughfare=%@", address.thoroughfare);
    NSLog(@"locality=%@", address.locality);
    NSLog(@"subLocality=%@", address.subLocality);
    NSLog(@"administrativeArea=%@", address.administrativeArea);
    NSLog(@"postalCode=%@", address.postalCode);
    NSLog(@"country=%@", address.country);
    NSLog(@"lines=%@", address.lines);
    locationName=address.thoroughfare;
    _txtFromLocation.text= [[locationName stringByAppendingString:[NSString stringWithFormat:@",%@",address.locality]]stringByAppendingString:[NSString stringWithFormat:@",%@",address.country]];
      }];

请告诉我从用户当前位置获取区域或区域的方式。

enter image description here

0 个答案:

没有答案