Seems to be working to parse GPS out of EXIF data within image.
This commit is contained in:
parent
2673bbe617
commit
79486d9734
|
@ -1,6 +1,9 @@
|
|||
function convertDMSToDD([degrees, minutes, seconds]) {
|
||||
return degrees + minutes / 60 + seconds / 3600;
|
||||
}
|
||||
|
||||
function readURL(input) {
|
||||
if (input.files && input.files[0]) {
|
||||
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
|
@ -10,10 +13,26 @@ function readURL(input) {
|
|||
$('.file-upload-content').show();
|
||||
|
||||
$('.image-title').html(input.files[0].name);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.src = e.target.result;
|
||||
|
||||
// Render thumbnail.
|
||||
img.onload = function () {
|
||||
EXIF.getData(img, function () {
|
||||
var allMetaData = EXIF.getAllTags(this);
|
||||
var allMetaDataSpan = document.getElementById('allMetaDataSpan');
|
||||
// allMetaDataSpan.innerHTML = JSON.stringify(allMetaData, null, '\t');
|
||||
var lat = convertDMSToDD(EXIF.getTag(this, 'GPSLatitude'));
|
||||
var long = convertDMSToDD(EXIF.getTag(this, 'GPSLongitude'));
|
||||
$('#lat').val(lat);
|
||||
$('#long').val(long);
|
||||
console.log(`lat: ${lat}, long: ${long}`);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
|
||||
} else {
|
||||
removeUpload();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- EXIF JS -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/exif-js/2.3.0/exif.js" integrity="sha512-bE9sOOprru4D2nRKDQSNvhdxw47Jd0r2s7QThKB/KkU5HEPuxsk9DbK+fYIMCYlCsXkwp6M87vj84sAtYWqxvw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<!-- Then Material JavaScript on top of Bootstrap JavaScript -->
|
||||
<script src="/assets/material/material.min.js"></script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue