Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Saving GPS coordinates

More
5 years 7 months ago #172318 by tpervaiz
Replied by tpervaiz on topic Saving GPS coordinates
Is it possible to hide the question and get the GPS Coordinates in reports only?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago - 5 years 7 months ago #172320 by tpartner
Replied by tpartner on topic Saving GPS coordinates
Assign a CSS class "hidden". But, note that the browser will likely still ask whether the respondent wants to allow location tracking.


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 7 months ago by tpartner.
The topic has been locked.
More
5 years 3 months ago #178051 by hmd_bakhshi
Replied by hmd_bakhshi on topic Saving GPS coordinates
Hi
I copy this code to my first question but it doesn't work!
The topic has been locked.
More
5 years 3 months ago #178052 by tpervaiz
Replied by tpervaiz on topic Saving GPS coordinates
Copy below script in first question's source

<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

// Identify this question
var q1ID = '{QID}';
var q1 = $('#question'+q1ID);

// Hide this question
q1.hide();

function getGPS() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showGPS, gpsError);
} else {
$('input.text', q1).val('No GPS Functionality');
}
}

function gpsError(error) {
//alert('GPS Error: '+error.code+', '+error.message);
}

function showGPS(position) {
$('input.text', q1).val(position.coords.latitude+', '+position.coords.longitude);
}

getGPS();

});
</script><script type="text/javascript" charset="utf-8">

$(document).on('ready pjax:scriptcomplete',function(){

// Identify this question
var q1ID = '{QID}';
var q1 = $('#question'+q1ID);

function getGPS() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showGPS, gpsError);
} else {
$('input.text', q1).val('No GPS Functionality');
$('input:hidden[id^="answer"]', q1).val('No GPS Functionality');
}
}

function gpsError(error) {
alert('GPS Error: '+error.code+', '+error.message);
}

function showGPS(position) {
$('input.text', q1).val(position.coords.latitude+', '+position.coords.longitude);
$('input:hidden[id^="answer"]', q1).val(position.coords.latitude+';'+position.coords.longitude);
}

getGPS();

});
</script><script type="text/javascript" charset="utf-8">

$(document).on('ready pjax:scriptcomplete',function(){

// Identify this question
var q1ID = '{QID}';
var q1 = $('#question'+q1ID);

// Click event for the button
$('.gpsLink').click(function(){
getGPS();
});

function getGPS() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showGPS, gpsError);
} else {
$('input.text', q1).val('No GPS Functionality');
$('input:hidden[id^="answer"]', q1).val('No GPS Functionality');
}
}

function gpsError(error) {
alert('GPS Error: '+error.code+', '+error.message);
}

function showGPS(position) {
$('input.text', q1).val(position.coords.latitude+', '+position.coords.longitude);
$('input:hidden[id^="answer"]', q1).val(position.coords.latitude+';'+position.coords.longitude);
}

});
</script>


Also please follow the below instructions

- type of question must be short text
- In location panel select Google Maps
- Type in CSS class(es) : hidden
The following user(s) said Thank You: hmd_bakhshi
The topic has been locked.
More
5 years 3 months ago #178053 by hmd_bakhshi
Replied by hmd_bakhshi on topic Saving GPS coordinates
thanks alot. I think my deadly mistake was that I do not turn on the google map in the local menu! it's work perfectly
The topic has been locked.
More
5 years 2 weeks ago #181156 by DavidPausDD
Replied by DavidPausDD on topic Saving GPS coordinates
Using this script, how can I move the map to the position I get to correct it if necessary?
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose