I am building a mobile site that needs to fetch high accuracy location from the user's phone. I using the HTML5 Geolocation .watchPosition function and enableHighAccuracy: true.
When tested on IOS devices, The code forces GPS to turn on and return me high accuracy data (4m), but when I tried with my MotoX (kitkat) and Nexus 5, Location symbol does not appear at the phone top bar and the accuracy returned was low (100m).
Something I have also noticed is that even the www.maps.google.com cannot initialize my phone's GPS (uses only inferred location from wifi+network), although all native apps (including Google Maps App) can use it and my phone's location mode is set to "High Accuracy".
I have tested this on the following Android browsers with wifi on and off and had the same result: -Chrome, -Opera Classic -Opera -Dolphin
My JS conde:
navigator.geolocation.watchPosition(success,fail,
{ enableHighAccuracy: true,
//timeout: 100000,
//maximumAge: 0
});
and the success function is:
function success(pos) {// Location was found
//set global variables with coordinates
globalLat=pos.coords.latitude;
globalLng=pos.coords.longitude;
$("#precision").html=pos.coords.accuracy;
alert(pos.coords.accuracy);
//create google location from coordinates
latlng=new google.maps.LatLng(globalLat, globalLng);
//send location to server and get response every 6 seconds;
setInterval(function(){SendAndGetLocation();}, 6000);
//create map or update it's center in case it was already created
if(googleMap===undefined){
createMap();
}else{
googleMap.setCenter(latlng);
}
//Draw user's location on map
drawLocalMarker(globalLat, globalLng);
}
Can anyone think of what might be happening?
Cheers