0
votes

I'm using ngCordova in an Ionic project and the geolocation watchPosition method is behaving stragely.

I have a factory which returns a promise:

  var watchOptions = {
    frequency: 5000,
    timeout: 7000,
    maximumAge: 100,
    enableHighAccuracy: false
  };

  var watch = $cordovaGeolocation.watchPosition(watchOptions);
  return watch;

I'm using the data returned from the promise in a controller:

  GetCurrentLocation.then(null, function(err) {
    console.log(err); 
  }, function(position) {
    console.log(position);
  });

When the state changes to the page using this controller it logs the position once, but then not again after that. Actually, sometime it will randomly log it again. I'm not sure if the position has to move a certain amount for it to update the position or if I'm doing something wrong here.

1
watchPosition gets invoked everytime the position changes no matter what amount. Does the console get logged when you change lat lng from chrome Emulator? - arun

1 Answers

0
votes

These options work for me ( using ngCordova also)

 var posOptions = {
      enableHighAccuracy: true, maximumAge: 5000, timeout: 8000
 };

Could you try this once and make sure your Wifi is turned off? Noticed some strange behaviour then :)