Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

I need to get gps

Dear All,

i am using v8.4.6


could you help me sharing a small sample data entry where the gps capture is done please

Thank you
asked Apr 20, 2018 by JuanPablo687 (285 points)

1 Answer

0 votes
There's a geolocation question for Lighthouse Studio here:

https://sawtoothsoftware.com/community-question-library/1744-geolocation

For SSI Web, you can reproduce this by creating a free format question with four hidden variables: "_Latitude", "_Logitude", "_Accuracy", and "_Error".  Then set the free format's HTML to this:

<input name="[% QuestionName() %]_Latitude" id="[% QuestionName() %]_Latitude" type="hidden" value="">
<input name="[% QuestionName() %]_Longitude" id="[% QuestionName() %]_Longitude" type="hidden" value="">
<input name="[% QuestionName() %]_Accuracy" id="[% QuestionName() %]_Accuracy" type="hidden" value="">
<input name="[% QuestionName() %]_Error" id="[% QuestionName() %]_Error" type="hidden" value="">

<script>
$(document).ready(function(){
    navigator.geolocation.getCurrentPosition(function(pos){
        $('#[% QuestionName() %]_Latitude').val(pos.coords.latitude);
        $('#[% QuestionName() %]_Longitude').val(pos.coords.longitude);
        $('#[% QuestionName() %]_Accuracy').val(pos.coords.accuracy);
    }, function(err){
        $('#[% QuestionName() %]_Error').val('Err #' + err.code + ': ' + err.message);
    }, {
        enableHighAccuracy: true,
        timeout: 10000,
        maximumAge: 0
    });
})
</script>


Be sure to read the linked article.  This question is not guaranteed to record the respondent's geolocation.
answered Apr 20, 2018 by Zachary Platinum Sawtooth Software, Inc. (121,525 points)
I tried the syntax that I shared but when downloading the base I get the following message

"Err #1: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)."
That's unexpected behavior.  Can you try running the code both in Test Survey and with an uploaded survey and tell me if you get the issue with one or both?
You have to use https based SSL connections in order to fetch that data in current browsers.
...