navigator.geolocation getCurrentPosition not updating in Chrome Mobile navigator.geolocation getCurrentPosition not updating in Chrome Mobile google-chrome google-chrome

navigator.geolocation getCurrentPosition not updating in Chrome Mobile


I never got to the bottom of this issue, but I got a way around the problem by utilising the watchPosition call, and wrapping this in a 5 second wait before clearing the watchID. Check the code below:

var options = { enableHighAccuracy: true, maximumAge: 100, timeout: 50000 };if( navigator.geolocation) {   var watchID = navigator.geolocation.watchPosition( gotPos, gotErr, options );   var timeout = setTimeout( function() { navigator.geolocation.clearWatch( watchID ); }, 5000 );} else {   gotErr();}

I haven't played around with the "options" values or the timeout delay at the moment, but the above code brings back accurate positioning info on every platform I've tried.

Hope this helps someone with the same issue :)


I finally found a working version for firefox, chrome & default navigator in android (4.2 tested only):

function getGeoLocation() {        var options = null;        if (navigator.geolocation) {            if (browserChrome) //set this var looking for Chrome un user-agent header                options={enableHighAccuracy: false, maximumAge: 15000, timeout: 30000};            else                options={maximumAge:Infinity, timeout:0};            navigator.geolocation.getCurrentPosition(getGeoLocationCallback,                    getGeoLocationErrorCallback,                   options);        }    }


getCurrentLocation() no longer works on insecure origins in Chrome browsers. Switch to a secure original (HTTPS) to enable.