This following code doesn’t work : var watchID = $cordovaGeolocation.watchPosition({ frequency: 1000 });
watch.promise.then(function() { // Not currently used }, function(err) { // An error occured. Show a message to the user }, function(position) { // Active updates of the position here // position.coords.latitude/longitude }); });
I think we have to replace this : watch.promise.then(function() {... and replaced by watch.then(function() {...
In addition, here, watchID is an object and not a simple number or integer
so, when we try this : $cordovaGeolocation.clearWatch(watchID) => That’s doesn’t work !!!
For today, I had used the following code that works : watchID = navigator.geolocation.watchPosition(function(position){... ... if (watchID != null) { $cordovaGeolocation.clearWatch(watchID); watchID = null; } $cordovaGeolocation.getCurrentPosition().then(function(position) {...
I got similar issue with $cordovaGeolocation.clearWatch and just wanted to update the thread … the returned object from $cordovaGeolocation.watchPosition has NO watchId property (but watchID).