jamesmontemagno / GeolocatorPlugin

Geolocation plugin for Xamarin and Windows
MIT License
294 stars 158 forks source link

CrossGeolocator.Current.StartListeningAsync() not working properly #353

Open BurhanMunir opened 1 year ago

BurhanMunir commented 1 year ago

I am stuck how to use CrossGeolocator.Current.StartListeningAsync() method. what it's parameters for timespan and distance do. and what if I put one of these parameters equal to zero .. I Actually need listening after particular seconds only or after particular distance only.

Bug Information

Version Number of Plugin:Xam.Plugin.Geolocator(4.5.0.6) Device Tested On:Android and iOS Simulator Tested On: Version of VS: 2022 Version of Xamarin:5.0.0.2012 Versions of other things you are using:

Steps to reproduce the Behavior

Expected Behavior

Startlistener should listen after the particular time or particular distance

Actual Behavior

Startlistener mixes up the time and distance

Code snippet

if (await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(Helper.Utils.Seconds), 1, false ,new ListenerSettings { DeferralTime = TimeSpan.FromSeconds(Helper.Utils.Seconds), DeferralDistanceMeters=null, DeferLocationUpdates=false, AllowBackgroundUpdates = true })) { Helper.Utils.IsTracking = true; }

if (await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(Helper.Utils.Seconds), Helper.Utils.Meters, false ,new ListenerSettings { AllowBackgroundUpdates= true } )) { var location = await Geolocation.GetLocationAsync();

                            previousLatitude = location.Latitude;
                            previousLongitude = location.Longitude;
                            Helper.Utils.IsTracking = true;
                        }

Screenshotst