如果我有一个经度和纬度(不是我的当前位置),我该如何使用GLGeocoder
进行反向地理编码查找?
self.geoCoder = [[CLGeocoder alloc] init];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
// [self.locationManager startUpdatingLocation];
[self.geoCoder reverseGeocodeLocation: locationManager.location completionHandler: ^(NSArray *placemarks, NSError *error) {
// [self.locationManager stopUpdatingLocation];
CLPlacemark *placemark = [placemarks objectAtIndex:0];
// Long address
// NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
// Short address
NSString *locatedAt = [placemark subLocality];
cell.textLabel.text = spot.name;
cell.detailTextLabel.text = [NSString stringWithFormat:@"Cab no: %@, spotted at %@", spot.cabno, locatedAt];
}];
我需要将经度和纬度设置为反向地理编码的目标,但显然只会针对我的位置进行地理编码。
initWithLatitude
,但它可能是在CLLocationManager
而不是CLLocation
对象上。干杯! - James