Have an idea?

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

Ask user to enable GPS Location using Jquery

Hi Developer

is there any option to request user to enable GPS location/or restrict user to enable GPS Location in Sawtooth Offline Survey

Thanks in advance
asked Jan 29 by Nouman Saeed Bronze (995 points)
Offline Surveys already requires GPS permissions to install.  You want to prompt users to remind them to enable their device's GPS settings?
Dear, I Want to capture GPS Location in my survey, that's why i want to prompt user to enable GPS Location on GPS Question.

Otherwise user forget to enable GPS Location and cause issue...
That sounds doable.  Just a matter of how you would want it done.  How is the respondent prompted?  How do they re-trigger the JS to collect the data once they've activated their GPS?
Dear, i want to show error message if they did not enable GPS Location in their devices..
But what happens after that?  The respondent sees an error message, they go enable GPS in their settings, and then... how do they continue the survey?  If a user isn't able to enable GPS, are they unable to continue through the survey at all?
Dear, if respondent enable GPS location, device capture location and interview will be go ahead..
just it.

1 Answer

0 votes
Start with my Geolocation question from the Community Question Library.  Replace the free format's code with 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="">

<button type="button" id="geolocationGo">
    Collect GPS info.
</button>

<script>
$('#geolocationGo').click(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) {},
    {
        enableHighAccuracy: true,
        timeout: 10000,
        maximumAge: 0
    });
})
</script>


Custom JS verification:

if (!SSI_GetValue('[% QuestionName() %]_Latitude')) {
    strErrorMessage = 'GPS info not collected.';
}
answered Feb 6 by Zachary Platinum Sawtooth Software, Inc. (121,725 points)
...