这是我迄今为止对我的地址进行反向地理编码的代码:
-(void)getJobs:(NSData *)responseData{
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSArray *array1 = [json valueForKey:@"activities"];
NSArray *array2 = [array1 valueForKey:@"activity_where"];
NSArray *array3 = [array1 valueForKey:@"activity_city"];
NSMutableArray * addresses = [NSMutableArray array];
for(int i = 0; i < [array2 count]; i++)
{
NSString * geocodeAddresses = [NSString stringWithFormat:@"%@, %@",
[array2 objectAtIndex:i],
[array3 objectAtIndex:i]];
[addresses addObject:geocodeAddresses];
}
NSMutableDictionary *addressDictionary = [[NSMutableDictionary alloc] init];
[addressDictionary setObject:addresses forKey:@"array"];
NSLog(@"%@",addressDictionary);
每当我注销时,我都会得到以下信息:
array = (
"some address",
"some address",
"some address",
);
}
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressDictionary:[addressDictionary valueForKey@"array"] completionHandler:^(NSArray* placemarks, NSError* error){
for (CLPlacemark* aPlacemark in placemarks)
{
// Process the placemark.
NSString *latDest = [NSString stringWithFormat:@"%.4f",aPlacemark.location.coordinate.latitude];
NSString *lngDest = [NSString stringWithFormat:@"%.4f",aPlacemark.location.coordinate.longitude];
CLLocationCoordinate2D annotationCoordinate =
CLLocationCoordinate2DMake([latDest doubleValue],
[lngDest doubleValue]);
UserAnnotation *annotation = [[UserAnnotation alloc] init];
[self.mapView addAnnotation:annotation];
现在我正在尝试从我的字典中对所有这些地址进行反向地理编码。有任何想法吗?