Save CAPI interviewers’ GPS location

Compatibilità:IdSurvey 5IdSurvey 6

To save CAPI interviewers’ GPS location you have to insert into the questionnaire a question that saves device GPS location as an answer.

gps_capi_en

INSTRUCTIONS

Copy and paste into the IdCode following script (the script includes the question too):

/page P000
  <clientscript>
  <style>
      #loadingGPS{
          position: static !important;
          opacity: 1 !important;
          margin-top: 11px !important;
      }
  </style>
  <script>
      $(".single-question-responses.main-responses :text").hide();
      $("#skipButton").hide();
      $("#retryButton").hide();
      $("#skipButton").on("click",function(){
          $(".single-question-responses.main-responses :text").val("notAvailable");
          $("#loadingGPS").hide();
          $("#successGPS").hide();
          $("#skipButton").hide();
          $("#retryButton").hide(); 
          $("#notAvailablePosition ").show();
        });
      function localizzami(tentativi){
          $("#loadingGPS").show();
          tentativi ++;
          navigator.geolocation.getCurrentPosition(function(position){
              var pos = position.coords.latitude + "-" + position.coords.longitude;
              $(".main-responses :text:first").val(pos);
              $("#loadingGPS").hide();
              $("#successGPS").show();
              $("#skipButton").hide();
              $("#retryButton").hide();
            },function(PositionError){
              if(tentativi >= 2)
                  $("#skipButton").show();
              $("#retryButton").show();
              $("#loadingGPS").hide();
              $("#successGPS").hide();
              $("#retryButton").off("click").on("click",function(){
                  $("#skipButton").hide();
                  $("#retryButton").hide();
                  localizzami(tentativi);
                }); 
            },
                                                     { maximumAge: 0, timeout: 120000, enableHighAccuracy: true });
        };
      if($(".single-question-responses.main-responses :text").val() != "" &&  $(".single-question-responses.main-responses :text").val() != "notAvailable"){
          $("#loadingGPS").hide();
          $("#successGPS").show();   
          $("#skipButton").hide();
          $("#retryButton").hide();          
        }else if($(".single-question-responses.main-responses :text").val() == "notAvailable"){
            $("#loadingGPS").hide();
            $("#successGPS").hide();   
            $("#skipButton").hide();
            $("#retryButton").hide(); 
            $("#notAvailablePosition ").show();
          } else {
              localizzami(0);
            }
  </script>
  </clientscript>

  L000
  GPS Location

  1 <p style="margin-top: 20px; margin-right: 10px; float: left;">GPS Location</p> <em id="loadingGPS" class="icon icon-spinner icon-spin icon-2x fa fa-spinner fa-spin fa-2x loader"></em><img id="successGPS" style="display: none; width: 30px; height: 30px; margin-top: 13px; float: left;" src="/img/surveys/success.png" /> <div style="float: left;position: relative;z-index: 2;"><button id="retryButton" class="btn btn-success" style="color: #ffffff; padding: 6px 6px; font-size: 16px; margin-left: 5px; display: none; margin-top: 10px;">Get location</button> <button id="skipButton" class="btn" style="background: #fcce00; margin-left: 5px; padding: 6px 6px; color: #ffffff !important; font-size: 16px; display: none; margin-top: 10px;">Salta</button></div> <div id="notAvailablePosition" style="display: none;">GPS Location not available</div> ->T

idcode_gps_en

Leave A Comment?