getCurrentPosition not working after turning the GPS off on the device even if it turned on again?

navigator.geolocation.getCurrentPosition not working after turning the GPS off on the device even if it turned on again ? and also it keep getting error if i start the apps with the GPS is off and keep error even if the GPS turned on again while the App is runing, only if i start the App and the GPS is on … it work only in this situation. any solution ?

                    var myoption = {
                        maximumAge: 0,
                        timeout: 10000,
                        enableHighAccuracy: true
                    navigator.geolocation.getCurrentPosition(function (position) {

                        var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
                            lat: pos.k,
                            lng: pos.D
                        $scope.myCurrentPosLat = pos.k;
                        $scope.myCurrentPosLng = pos.D;
                    }, function (err) {
    'error !!',  // message
    'error msg',       
                    }, myoption);

That’s because that method is only fired once. You either need something to detect when the GPS is turned ON/OFF and then call getCurrentPoisition , or use the watchPosition method.

@joseadrian i fire the getCurrentPosition from a button on my view, so its not only once, if i click this button and my GPS was on before starting the App it success , if i turend the GPS off and click this button i will get error and i will keep getting error even if i turn the GPS on again …

That’s weird. What’s the error message you get?

@joseadrian am keep getting Timeout Expired , my timeout option is 10000 … so ?

Have you tried setting the timeout to more than 10 seconds?

What device you are testing with?

@pcr am using galaxy note 4

@joseadrian yes i did , the same

Did you wrap the function in:

document.addEventListener(“deviceready”, function () {
$cordovaPlugin.someFunction().then(success, error);
}, false);

// OR with IONIC

$ionicPlatform.ready(function() {
$cordovaPlugin.someFunction().then(success, error);

The code above is for $cordova functions. you should also wait for device ready for you code.
Did you try $cordova??

@pcr also the same , i checked with another device, galaxy note 1 also the same

I have the same problem on Android devices, iOS everything right, any solution that you have found?

I have the exact same problem, when opening the app with the GPS on everything works, but if i turn off the GPS and on again I get Timeout error. same goes for opening the app if the gps is off, turning it on while inside the app dosent help.

is there a way to Initialize the plugin?

Im using one plus one ad my developing device,

any one solved this issue?

i joined to question too i have this issue on wp8 on android i didnt remeber i will check later

I still have a problem. Does someone has found a workaround (except testing with another plugin if it’s on or off) ?


I have the same problem. Anyone with news about the issue?

Same error here. Have you found a solution?

same issue here. anyone found a solution for this?

Same issue, has anyone found solution?