【问题标题】:Get coordinates from photo with JavaScript使用 JavaScript 从照片中获取坐标
【发布时间】:2015-07-25 16:17:52
【问题描述】:

我正在关注此线程 Get coordinates from photo with JavaScript 以从图片中获取纬度和经度(我检查了图片并具有属性),我正在尝试使用 javascript 获取:

$(function(){
  
  $("#file-input").on("change", function(e) {
            EXIF.getData(e.target.files[0], function() {
             
                var result = EXIF.pretty(this);
                $("#span").text(result);
            });
        });

  
  
});
<script src="https://raw.githubusercontent.com/exif-js/exif-js/master/exif.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>


<input type="file" id="file-input" />
<span id="span">Here</span>

但它总是返回 GPSLatitudeLGPSLongitud: [3 values] 但我无法访问这些属性。

【问题讨论】:

    标签: javascript exif


    【解决方案1】:

    另外,在尝试读取 EXIF 标头之前,请确保图像已完全加载。 EXIF-JS 文档警告它in greater detail,并带有关于 jQuery 的特定警告。

    【讨论】:

      【解决方案2】:

      试试 EXIF.getTag(this,'GPSLatitude'), 您将得到 3 对,它们由逗号 (,) 分隔。您可以将其转换为字符串并将它们拆分为一个数组,继续执行其余步骤。

      【讨论】:

      • 对于那些不太了解 gps 的人(比如我),有 3 种格式,this lib 可以帮助在这 3 种格式之间进行转换
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-10
      • 2021-05-26
      • 1970-01-01
      • 2012-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多