GeolocatorPlugin icon indicating copy to clipboard operation
GeolocatorPlugin copied to clipboard

When calling GetPositionAsync the DesiredAccuracy is ignored if 'IsListening'

Open scottiebrady opened this issue 7 years ago • 2 comments

When you call the method 'GetPositionAsync' it checks if 'IsListening' is true and will return the 'lastPosition' if it's not null. I can understand why it's done this way, but it doesn't do any validation on the 'lastPosition' to make sure that it's not an old position or with the DesiredAccuracy.

So if I have a view that calls 'StartListeningAsync' followed by 'GetPositionAsync' during the OnViewAppearing it will return the 'lastPosition'. And it's possible that no 'PositionChanged' events have fired since we started the listener, so the 'lastPosition' will be from the last time the listener was running (which could be days old). It should real check the age of the 'lastPosition' to make sure it's not too old.

Alternatively, if the listener starts and fires off a 'PositionChanged' event before I call 'GetPositionAsync', it's possible that the 'lastPosition' accuracy might be over 100 metres (as the listener has just been started). So when I call 'GetPositionAsync' with a DesiredAccuracy of 5 meters, it will return the 'lastPosition' without making sure it's within my desired accuracy. Shouldn't the method compare the accuracy of 'lastPosition' against my 'DesiredAccuracy' and wait until a 'PositionChanged' event fires with higher accuracy?

scottiebrady avatar Sep 13 '17 23:09 scottiebrady

I've been having a problem with this. Is it possible to force a fresh update of the long/lat through? Right now it seems like the only way to make sure you actually have a fresh pair of coordinates is to somehow compare them to the previous ones received and see if it's a duplicate.

Jantolick avatar Dec 12 '17 18:12 Jantolick

Looks like I managed to fix this in the short term by calling StopListeningAsync and then GetPositionAsync and then recalling StartListeningAsync. I may need to stop using GetPositionAsync however since this workaround feels dirty... I hope I can get the same behaviour I need by just relying on using the listener instead.

pellet avatar May 11 '20 08:05 pellet