Wednesday, 15 January 2014

javascript - Geolocation HTML5 API enableHighAccuracy:True does not force GPS to turn on om Android devices -



javascript - Geolocation HTML5 API enableHighAccuracy:True does not force GPS to turn on om Android devices -

i building mobile site needs fetch high accuracy location user's phone. using html5 geolocation .watchposition function , enablehighaccuracy: true.

when tested on ios devices, code forces gps turn on , homecoming me high accuracy info (4m), when tried motox (kitkat) , nexus 5, location symbol not appear @ phone top bar , accuracy returned low (100m).

something have noticed www.maps.google.com cannot initialize phone's gps (uses inferred location wifi+network), although native apps (including google maps app) can utilize , phone's location mode set "high accuracy".

i have tested on next android browsers wifi on , off , had same result: -chrome, -opera classic -opera -dolphin

my js conde:

navigator.geolocation.watchposition(success,fail, { enablehighaccuracy: true, //timeout: 100000, //maximumage: 0 });

and success function is:

function success(pos) {// location found //set global variables coordinates globallat=pos.coords.latitude; globallng=pos.coords.longitude; $("#precision").html=pos.coords.accuracy; alert(pos.coords.accuracy); //create google location coordinates latlng=new google.maps.latlng(globallat, globallng); //send location server , response every 6 seconds; setinterval(function(){sendandgetlocation();}, 6000); //create map or update it's center in case created if(googlemap===undefined){ createmap(); }else{ googlemap.setcenter(latlng); } //draw user's location on map drawlocalmarker(globallat, globallng); }

can think of might happening?

cheers

don't misled gps, mean dont assume it's going give accurate results, consider app beingness tombstoned, or device going sleep, in case accuracy of network provider sometime more accurate, i'm doing similar stuff self , gave on high accuracy these reason

http://www.andygup.net/how-accurate-is-html5-geolocation-really-part-2-mobile-web/ , http://www.andygup.net/six-most-common-use-cases-for-android-gps/

javascript android gps w3c-geolocation

No comments:

Post a Comment