- Posts: 10
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Saving GPS coordinates
- marcic
- Topic Author
- Offline
- New Member
Less
More
11 years 1 week ago #95003
by marcic
Saving GPS coordinates was created by marcic
Hi there,
I was wondering if Limesurvey can save GPS coordinates obtained after clicking a link with a Javascript? I can get the coordinates to show in a Text display type of question but could not manage to get the two lines to be saved.
Maybe some of you are aware of a workaround available.
attached see lss file with one group and question with the script
Best,
Marcis
I was wondering if Limesurvey can save GPS coordinates obtained after clicking a link with a Javascript? I can get the coordinates to show in a Text display type of question but could not manage to get the two lines to be saved.
Maybe some of you are aware of a workaround available.
attached see lss file with one group and question with the script
Best,
Marcis
The topic has been locked.
- orvil
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
11 years 1 week ago #95008
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Saving GPS coordinates
Hi,
use an equation type question to read the text field (with EM). The result of the equation will be stored.
And: may be it is possible to poke your data directly to an equation type question.
use an equation type question to read the text field (with EM). The result of the equation will be stored.
And: may be it is possible to poke your data directly to an equation type question.
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- marcic
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 1
11 years 1 week ago #95019
by marcic
Replied by marcic on topic Saving GPS coordinates
Thanks for your reply but apparently my skills with javascript are too weak and I cannot implement your propsed solution.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
11 years 1 week ago #95025
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
Please attach your 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.
- marcic
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 1
11 years 1 week ago - 11 years 1 week ago #95026
by marcic
Replied by marcic on topic Saving GPS coordinates
Sorry, apparently the lss file was not attached. Here it is again.
What I was trying to do was to implement one of these solutions:
macmost.com/iphone-gps-location-with-javascript.html
merged.ca/iphone/html5-geolocation
What I was trying to do was to implement one of these solutions:
macmost.com/iphone-gps-location-with-javascript.html
merged.ca/iphone/html5-geolocation
Last edit: 11 years 1 week ago by marcic. Reason: no file attached
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
11 years 1 week ago #95031
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
Still no file attached but here's an example using your first link in a short-text question.
Add this to the question source (I used a button element to fire the geolocation function):
Here's a test survey:
Add this to the question source (I used a button element to fire the geolocation function):
Code:
<button class="gpsLink" type="button">Get GPS Data</button> <script type="text/javascript" charset="utf-8"> $(document).ready(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'); } } function gpsError(error) { alert('GPS Error: '+error.code+', '+error.message); } function showGPS(position) { $('input.text', q1).val(position.coords.latitude+', '+position.coords.longitude); } }); </script>
Here's a test survey:
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: marcic
The topic has been locked.
- marcic
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 1
11 years 1 week ago #95052
by marcic
Replied by marcic on topic Saving GPS coordinates
Excellent! works as I imagined how it should work. Perhaps this could be added to workarounds?
Thanks,
Marcis
Thanks,
Marcis
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
11 years 1 week ago #95053
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
Sure, we could add it but I'm hesitant given that it won't work in IE 7-8.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- dgtano
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
9 years 1 month ago #118147
by dgtano
Replied by dgtano on topic Saving GPS coordinates
Hello. Thank you very much for your contribution.
I would automatically save the GPS coordinates, without the button. Is it possible?
I would automatically save the GPS coordinates, without the button. Is it possible?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
9 years 1 month ago #118196
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
This will fire the getGPS() function when the page is loaded.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(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'); } } 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>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- dgtano
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
9 years 1 month ago #118197
by dgtano
Replied by dgtano on topic Saving GPS coordinates
Fantastic. Tks a lot
The topic has been locked.
- shawnchan
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
9 years 1 month ago - 9 years 1 month ago #118541
by shawnchan
Replied by shawnchan on topic Saving GPS coordinates
Hello,
Thank you very much for your effort, it looks like everybody else can work it out with your sample survey. I also tried to do it with your sample survey [limesurvey_survey_geolocation.lss ], but nothing shows in the text box after clicking the button, although a pop-up window shows up and asking for permission to get the location. Do you have any idea on this? I can get the location in Google map so I guess it's not the signal problem.
I also tried it on both android device and IPAD but it's still not working.
Thanks a lot.
LimeSurvey: Version 1.91+ Build 11379
Thank you very much for your effort, it looks like everybody else can work it out with your sample survey. I also tried to do it with your sample survey [limesurvey_survey_geolocation.lss ], but nothing shows in the text box after clicking the button, although a pop-up window shows up and asking for permission to get the location. Do you have any idea on this? I can get the location in Google map so I guess it's not the signal problem.
I also tried it on both android device and IPAD but it's still not working.
Thanks a lot.
LimeSurvey: Version 1.91+ Build 11379
Last edit: 9 years 1 month ago by shawnchan.
The topic has been locked.