Welcome to the LimeSurvey Community Forum

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

Capture Accurate GPS Coordinates and show current location on map

  • tpervaiz
  • tpervaiz's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 months 5 days ago #264675 by tpervaiz
Hi, I have an Google API used in my limesurvey where I am able to get the gps coordinates however the current location doesnt show on map instead the map is watermarked with "For Development Purpose Only" and the location always show in Hamburg. below is the my code to capture the GPS coordinates.
So can anyone help me to fix the location on map and get me the code to get the accurate GPS coordinates as below code sometime provide the last location coordinates.  

GPS Coordinates <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>

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 5 days ago #264676 by Joffm
You have to create a Google maps API key.
[url] developers.google.com/maps/documentation...pt/get-api-key?hl=en [/url]

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • tpervaiz
  • tpervaiz's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 months 3 days ago #264713 by tpervaiz
Thanks for your reply but I am already using the API key however the issue in map is not resolved as the location in map shows Hamburg with Development purpose only watermark. So how can i resolve it?

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 months 3 days ago #264714 by DenisChenu
You put the API key in LimeSurvey configuration and it don't work ?

What is your LimeSurvey version ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • tpervaiz
  • tpervaiz's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 months 3 days ago #264715 by tpervaiz
The version is 6.4.9 The coordinates in text field I am able to get however maps has the same issue shows doesn't show a pin point to current location

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 months 3 days ago #264717 by DenisChenu


But for «Hamburg with Development purpose only watermark» maybe there are an issue : can you update to the last version ? And report the issue if it still happen ?
If it still don't work : community.limesurvey.org/bug-tracker/

To have location by browser : you can get inspiration here : gitlab.com/SondagesPro/QuestionTheme/MapIgn

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose