Search code examples
javascript.netmobilephotoexif

Exif javascript not returning GPS information while take picture in camera Mobile


We are having the .NET core web app using both dropzone and EXIF to upload picture and find GPS lattitude and longtitude details from the photo.

We created an android app using the same code as webview , here the problem is, though the camera settings allowed to share location , exif not returning GPS details. But same working if the picture is already taken and upload via gallery app.

Code in javascript

new Dropzone("#dropzone", {
                url: "#",
                paramName: "file", //the parameter name containing the uploaded file
                clickable: true,
                uploadMultiple: true,
                addRemoveLinks: true,
                autoProcessQueue: true,
                //acceptedFiles: ".png,.jpg,.jpeg,.PNG,.JPG",
                acceptedFiles: "image/*",
                capture: "camera",
                dictDefaultMessage: "<strong>Drop files here or click to upload. </strong>", //override the default text
                init: function () {
                    this.on('addedfile', function (file) {
                        if ($("#dropzone").hasClass('dropzone')) {
                            jQuery("#dropzone").attr('style', 'background-image: none !important;');
                        }

                        var isExist = existingImageName.filter(function (item) { return item === file.name });
                        if (isExist.length > 0) {
                            abp.notify.error("Image with this name is already exist,please select image with different name");
                            this.removeFile(file);
                            return;
                        }
                        else {
                            existingImageName.push(file.name);
                            imagefile.push(file);
                            var objFile = this;
                            console.log("exif calls");
                            dealLocationLat = "";
                            dealLocationLng = "";
                            EXIF.getData(file, function () {
                                    if (Object.keys(this.exifdata).length > 0) {
                                        if (AgeofImage(this.exifdata) || DealImageDateCheck(this.exifdata.DateTime)) {
                                            var allMetaData = EXIF.getAllTags(this);

enter image description here

I tried in web browsers and it is working fine and in mobile browser chrome both camera and gallery app working well and good. App also working well with gallery app sharing photo but taking camera picture from app not returning GPS


Solution

  • I changed "addedfile" event to complete, then it returns the geo-locations.

    it was like below

    
    then I moved my code like below.
    
    ````this.on('complete', function (file) { //code here });