【问题标题】:How do you get a UIImage's geographic coordinates?你如何获得 UIImage 的地理坐标?
【发布时间】:2012-07-25 19:49:15
【问题描述】:

在 UIImagePickerController 中拍摄图片后,如何获取 UIImage 的 GPS 坐标?图像是否包含其元数据中的坐标,或者我应该为图像及其坐标创建一个类并保存它? 谢谢。

【问题讨论】:

    标签: iphone xcode gps uiimage uiimagepickercontroller


    【解决方案1】:

    请尝试查看this 并按照该答案中的说明进行操作..

    我已经做到了,并取得了成功..

    希望它对你有用..

    【讨论】:

      【解决方案2】:

      实际上,您可以在拍照后立即访问图像的元数据。选择图像后系统调用的协议方法是,

      (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
      

      NSDictionary 参数 info 包含一个键:UIImagePickerControllerMediaMetadata

      AFAIK,您需要 CLLocationManager 来获取当前位置并对其进行地理标记。

      【讨论】:

        【解决方案3】:

        iOS 8 开始,您可以使用Photos Framework

          func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
          let url = info[UIImagePickerControllerReferenceURL] as? URL
                if url != nil {
        
                    let fetchResult = PHAsset.fetchAssets(withALAssetURLs: [url!], options: nil)
                    let asset = fetchResult.firstObject
                    print(asset?.location?.coordinate.latitude)
                    print(asset?.creationDate)
                }
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-11-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-02-27
          • 1970-01-01
          • 2014-09-02
          • 2012-07-22
          相关资源
          最近更新 更多