location accuracy issue


(Patriack) #1

hi,

Recently, I have to use “navigator.geolocation.getCurrentPosition()” on a web site, used by a phones. However, the precision is between 200 to 4000 meters of precision. I Ask you more information to know what could be give this precision.

phone used : Sonim-XP7700
Android version : 5.1

My code (who try to get a possition with a precision less than 150 meters, in 20 second. ):

{
timeoutID = setTimeout(failGetWatchedPosition, 20000);
watchID = navigator.geolocation.watchPosition(successGetWatchedPosition);
}

function successGetWatchedPosition(position)
{
document.getElementById("<%= this.hid_longitude.ClientID %>").value = position.coords.longitude;
document.getElementById("<%= this.hid_lattitude.ClientID %>").value = position.coords.latitude;
document.getElementById("<%= this.hid_accuracy.ClientID %>").value = position.coords.accuracy;
document.getElementById("<%= this.hid_altitude.ClientID %>").value = position.coords.altitude;
document.getElementById("<%= this.hid_speed.ClientID %>").value = position.coords.speed;

                if(position.coords.accuracy < 250)
                {
                    clearTimeout(timeoutID);
                    navigator.geolocation.clearWatch(watchID);
               
                    __doPostBack('punch', isPunchIn?'in':'out');
                }
            }
           
            function failGetWatchedPosition()
            {
                clearTimeout(timeoutID);
                navigator.geolocation.clearWatch(watchID);
               
                document.getElementById("hid_longitude").value = "";
                document.getElementById("hid_lattitude").value = "";
               
                document.getElementById("<%= this.hid_error.ClientID %>").value = "la position n'a pas put être déterminer dans les 20 secondes alouées.";
          
                __doPostBack('punch', isPunchIn?'in':'out');
            }