2014-11-05 30 views
0

一般图片可以很好地显示信息。 但是在应用过滤器的图片上没有gps信息。 有没有办法解决?从照片中获取GPS meta

- (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]; 
    }]; 
} 
+0

我从你的问题中了解到,你正在尝试使用没有附加位置数据的图像,对吧? – Abdul91 2014-11-05 06:09:31

+0

准确。如果使用过滤器在基本相机应用程序中拍摄照片。 – realmasse 2014-11-05 07:04:58

+0

你可能已经尝试过,但只是为了确认,你是否尝试过没有任何过滤器的图像相同的代码,并确保相机的位置服务在设备设置中?设置 - >隐私 - >位置服务 – Abdul91 2014-11-05 07:22:22

回答

0
CLLocation *location = [asset valueForProperty:ALAssetPropertyLocation]; 

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

解决。