You are viewing limited content. For full access, please sign in.

Question

Question

Capture of GPS Coordinates

asked on September 3, 2014

We have a client who is interested in utilizing Laserfiche Forms on a handheld device out in the field.  They want to capture GPS coordinates/coordinate stamp off of the device as metadata.  This would not be an extraction from an image per se but the coordinates off of the device.  Is this possible?

 

Thanks.

 

0 0

Answer

SELECTED ANSWER
replied on September 4, 2014

Kenneth has the right idea here I think. Keep in mind that HTML5 support is largely browser dependent, but if they're on a current Android or iOS phone/tablet, the default browser (Chrome and Safari respectively) should work fine. CanIUse.com is a pretty cool reference to check if the feature will work on your platform. 

2 0

Replies

replied on September 4, 2014

Take a look at the information here: http://www.w3schools.com/html/html5_geolocation.asp

 

HTML5 provides geolocation variables but they will only work if the user approves it/allows it in the browser. I would try using as much out of the box tools at your disposal first before trying to do anything too over the top to get the results you want. Since Forms is built heavily on HTML5 (from what I understand), using this functionality should not be out of the question and you would not really want a user using a form anyways without proper HTML5 support, so this would also potentially give you the best compatibility

2 0
replied on September 4, 2014 Show version history

I got this to work on a simple form in case anyone is interested.

 

Assuming two single line fields with ids q1 and q2, the following code will auto-populate them with the device's lattitude and longitude.

function getLocationConstant() {
    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError);  
    } else {
        $("#Field1, #Field2").val("Geolocation not supported");
    }
}

// If geolocation is successful
function onGeoSuccess(event) {
    $("#Field1").val(event.coords.latitude);
    $("#Field2").val(event.coords.longitude);
}

// If geolocation error occurs
function onGeoError(event) {
    $("#Field1, #Field2").val("Geolocation error occurred.");
}

$(document).ready(function() {
	getLocationConstant();
});

When the form is loaded, it might look something like this:

 

 

As Ken said, the user needs to explicitly allow location detection on their browser. If they don't, or if the device doesn't have location services, the fields get populated with a "geolocation not supported" message.

 

Edit: The browser may prompt the user to allow it to gather location information. This can present a problem when Laserfiche Forms saves a copy of the form to the repository. Because Forms does this by opening the form in a browser and generating an image, the browser prompt may still occur. If it does, it can interfere with scripts you are running on the form.

4 0
replied on September 9, 2014

Hi Hedy, 

 

If your question has been answered, please let us know by clicking the "This answered my question" button on the appropriate response.

 

If you still need assistance with this matter, just update this thread. Thanks!

1 0
replied on September 7, 2014

hi try following code

 

window.onload=function()
{
  
           if(navigator.geolocation)
               {
              navigator.geolocation.getCurrentPosition(showPosition);
       
               }
           else
              {
            alert("Geolocation is not supported by this browser.");
              }
        
}
function showPosition(pos)
{
    $('.lati input').val(pos.coords.latitude);  
    $('.lalon input').val(pos.coords.longitude)
    //alert("Latitude: "+pos.coords.latitude+"\nLongitude: "+pos.coords.longitude);
}

 

 

0 0
replied on January 15, 2016

Hi there,

Geolocation field is supported out of box in Laserfiche Forms 10.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.