- Posts: 49
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Saving GPS coordinates
- tpervaiz
- Offline
- Senior Member
Less
More
5 years 8 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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
5 years 8 months ago - 5 years 8 months ago #172320
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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.
Attachments:
Last edit: 5 years 8 months ago by tpartner.
The topic has been locked.
- hmd_bakhshi
- Offline
- Junior Member
Less
More
- Posts: 36
- Thank you received: 0
5 years 4 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!
I copy this code to my first question but it doesn't work!
The topic has been locked.
- tpervaiz
- Offline
- Senior Member
Less
More
- Posts: 49
- Thank you received: 1
5 years 4 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
<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.
- hmd_bakhshi
- Offline
- Junior Member
Less
More
- Posts: 36
- Thank you received: 0
5 years 4 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.
- DavidPausDD
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
5 years 2 months 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.