Chrome and HTML5 GeoLocation denial callback

Google mapsWeb DevelopmentJavascriptFront End Scripts

For timeout callback in Google Chrome, try the following code:

_callback = false;
function successCallback(position) {
   _callback = true;
   console.log('success');
}

function errorCallback(error) {
   _callback = true;
   alert('error');
}
setTimeout(function(){if(!_callback)console.log('ignored')}, 20000);

navigator.geolocation.getCurrentPosition(
   successCallback,
   errorCallback,
   {timeout: 2000}
);
raja
Published on 10-Apr-2018 12:25:07
Advertisements