0

I need to to fetch the Latitude and Longitude of Image captured or uploaded using SF 1 App.I am using EXIF to fetch the same in javascript(helper) While it is working on android , same does not work on IOS. Anyone have any idea how to do it. Below is part of my code which I tried:

 pic.onload = function(){
                                    alert('EXIF'+EXIF);

                                    window.setTimeout(
                                        $A.getCallback(function() {
                                            EXIF.getData(this, function (){
                                                alert('inside exif');
                                                alert('lat'+EXIF.getTag(this, 'GPSLatitude'));
                                                alert('long'+EXIF.getTag(this, 'GPSLongitude'));
                                                var longitude = EXIF.getTag(this, 'GPSLongitude');
                                                var latitude = EXIF.getTag(this, 'GPSLatitude');
                                                if((longitude != null && latitude != null && typeof latitude != 'undefined' && typeof longitude !='undefined') || component.get("v.isLatLongRequired")  == false)  {
                                                    if(longitude != null && latitude != null && typeof latitude != 'undefined' && typeof longitude !='undefined'){
                                                        console.log('image contains lat long'+(latitude[0].numerator + latitude[1].numerator /(60 * latitude[1].denominator) + latitude[2].numerator / (3600 * latitude[2].denominator)));
                                                        component.set("v.latitude", (latitude[0].numerator + latitude[1].numerator /(60 * latitude[1].denominator) + latitude[2].numerator / (3600 * latitude[2].denominator)));
                                                        component.set("v.longitude", (longitude[0].numerator + longitude[1].numerator /(60 * longitude[1].denominator) + longitude[2].numerator / (3600 * longitude[2].denominator)));
                                                        console.log("latitute"+component.get("v.latitude"));
                                                        console.log("longitude"+component.get("v.longitude"));
                                                        if(component.get("v.latitude") == null || component.get("v.longitude") == null || isNaN(component.get("v.latitude")) || isNaN(component.get("v.longitude")))
                                                        {
1

it doesn’t work on iOS because the OS clean up the geolocation during the upload. Your code should work on iOS for an image uploaded on Android. That will confirm it.

  • Hi @Jean, Yes I got it, but do I have any work around here, as this is required thing in my project, as I need to have the location values of image uploaded via IOS. I am stuck on the same after trying a lot. – Pankaj Andhale Jun 2 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.