从照片中获取GPS元数据

时间:2014-11-05 04:20:22

标签: ios objective-c ios8 ios7.1

总图是很好地提出信息。 但是没有应用过滤器中图片的gps信息。 有办法解决吗?

- (void)getGPSLocation : (ALAsset*)asset
{
    NSMutableDictionary *imageMetadata = nil;
    NSDictionary *metadata = asset.defaultRepresentation.metadata;
    imageMetadata = [[NSMutableDictionary alloc] initWithDictionary:metadata];

    latitude = [[[imageMetadata objectForKey:@"{GPS}"]objectForKey:@"Latitude"]doubleValue];
    longitude = [[[imageMetadata objectForKey:@"{GPS}"]objectForKey:@"Longitude"]doubleValue];

    CLGeocoder *ceo = [[CLGeocoder alloc]init];
    CLLocation *loc = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude]; //insert your coordinates

    addr = [NSString alloc];

    [ceo reverseGeocodeLocation: loc completionHandler:
     ^(NSArray *placemarks, NSError *error) {

         CLPlacemark *placemark = [placemarks objectAtIndex:0];

         NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];

         NSLog(@"I am currently at %@",locatedAt);
         addr = locatedAt;
         //         [_address setText:locatedAt];
         //         [self setPin:latitude longitude:longitude addr:addr];
     }];
}

1 个答案:

答案 0 :(得分:0)

CLLocation *location = [asset valueForProperty:ALAssetPropertyLocation];

latitude = (double)location.coordinate.latitude;
longitude = (double)location.coordinate.longitude;

解决。