- 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 7 months ago #172306
by tpervaiz
Replied by tpervaiz on topic Saving GPS coordinates
I used this code which is working perfectly in survey however the coordinates are not showing in response or survey report..Is there anything else I have to do?
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
5 years 7 months ago #172310
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
What LimeSurvey version are you using?
Can you attach an export (.lss) of a small sample survey?
Can you attach an export (.lss) of a small sample survey?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- tpervaiz
- Offline
- Senior Member
Less
More
- Posts: 49
- Thank you received: 1
5 years 7 months ago #172313
by tpervaiz
Replied by tpervaiz on topic Saving GPS coordinates
the version is Version 3.14.2+180807
I am able to get GPS coordinates in both ways Automatically as well as Push button but the problem is the coordinates are not showing in responses and reports
Please see the lss in attachment
Thanks in advance
I am able to get GPS coordinates in both ways Automatically as well as Push button but the problem is the coordinates are not showing in responses and reports
Please see the lss in attachment
Thanks in advance
Attachments:
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
5 years 7 months ago #172314
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
Try this for the respective scripts:
Sample survey attached:
Code:
<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>
Code:
<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>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: DenisChenu, tpervaiz, DavidPausDD
The topic has been locked.
- tpervaiz
- Offline
- Senior Member
Less
More
- Posts: 49
- Thank you received: 1
5 years 7 months ago #172315
by tpervaiz
Replied by tpervaiz on topic Saving GPS coordinates
GPS coordinates are not even showing in survey itself by using the script provided by you
Do I need more workaround?
Do I need more workaround?
Attachments:
The topic has been locked.
- tpervaiz
- Offline
- Senior Member
Less
More
- Posts: 49
- Thank you received: 1
5 years 7 months ago #172316
by tpervaiz
Replied by tpervaiz on topic Saving GPS coordinates
Its working now,, I copied half script
Thanks alottttt
Thanks alottttt
The topic has been locked.
- tpervaiz
- Offline
- Senior Member
Less
More
- Posts: 49
- Thank you received: 1
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
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
5 years 7 months ago - 5 years 7 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 7 months ago by tpartner.
The topic has been locked.
- hmd_bakhshi
- Offline
- Junior Member
Less
More
- Posts: 36
- Thank you received: 0
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!
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 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
<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 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.
- DavidPausDD
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
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.