lundi 20 avril 2015

jQuery mobile and html5 location permission and values

I am trying to make a android webview app to use the user geoLocation :

if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition,showError,{maximumAge:60000, timeout:20000, enableHighAccuracy:true}); 
        console.log("Location supported")
        }

To show the position on success :

    function showPosition(position) {
            currentLatitude = position.coords.latitude;
            currentLongitude = position.coords.longitude;
                console.log( "In show :  " + position.coords.latitude + ", " +position.coords.longitude)
      }   

To show the error code :

    function showError(error) {
      var x = $('#curr_loc_target');
        console.log("In show Error");
      switch(error.code) {
        case error.PERMISSION_DENIED:
          console.log("permission denied"); 
          break;
        case error.POSITION_UNAVAILABLE:
          console.log("Location information is unavailable.");
          break;
        case error.TIMEOUT:
          console.log("The request to get user location timed out.");
          break;
        case error.UNKNOWN_ERROR:
          console.log("An unknown error occurred.");
          break;
        }

It works fine on any desktop web browser but not and mobile browser, there are to problems that : 1- The app don't ask the user for permission the use Location and the error from showError function is TIMEOUT,i think the webview code is irrelevant because even on a mobile browser the problem is the same.

2- The values in longitude , latitude are equal to ' '. If anyone think that i need to add it here, i will.

Thank for any help!

Aucun commentaire:

Enregistrer un commentaire