[英]Get location in metadata of image when source type is Camera in UIImagePickerController ( kind of geotagging )
I am trying to get or capture user location within metadata of image picked by UIImagePickerController
having source type set UIImagePickerControllerSourceTypeCamera
. 我试图获得或摄取的图像的元数据中获取用户位置
UIImagePickerController
有源类型设置UIImagePickerControllerSourceTypeCamera
。
When source type is camera(image clicked by camera), we can get metadata from the info
parameter of didFinishPickingMediaWithInfo
but it doesn't contain location information. 当源类型为camera(摄像机单击的图像)时,我们可以从
didFinishPickingMediaWithInfo
的info
参数中获取元数据,但其中不包含位置信息。
If source type is photolibrary (UIImagePickerControllerSourceTypePhotoLibrary)
then we can get location in metadata
with below code, 如果源类型为图片库
photolibrary (UIImagePickerControllerSourceTypePhotoLibrary)
则可以使用以下代码获取metadata
位置,
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
PHFetchResult *fetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
PHAsset *asset = fetchResult.firstObject;
NSLog(@"%f,%f",asset.location.coordinate.latitude,asset.location.coordinate.longitude);
[picker dismissViewControllerAnimated:YES completion:nil];
}
Second thing we can also manage location with CLLocationManager
, I mean we can capture location in didFinishPickingMediaWithInfo
. 第二件事,我们也可以使用
CLLocationManager
管理位置,这意味着我们可以在didFinishPickingMediaWithInfo
捕获位置。 But I just want to know that is it possible to pick location with metadata in didFinishPickingMediaWithInfo
when image is picked by camera or source type is camera ? 但是我只想知道,当按摄像机选择图像或源类型为camera时,是否可以使用
didFinishPickingMediaWithInfo
元数据来选择位置?
Any help will be appreciated. 任何帮助将不胜感激。 Thanks!
谢谢!
我得出的结论是,如果我们使用Camera
则无法在元数据中获取位置,因此,如果要在从Camera捕获图像时获取位置,则必须在捕获时使用默认位置服务( CLLocationManager
)-I在didFinishPickingMediaWithInfo
方法中的平均值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.