Geo Locator Listening issue

I have one issue is geo Locator that I have declared Time as 10 sec. then also in Android: it updates after 10 or more than 10 sec., In IOS: it updates in every sec. This is my Code:

  public async void CurrentLocation()
  {

    try
    {
        await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(10), 0, true, new Plugin.Geolocator.Abstractions.ListenerSettings
        {
            ActivityType = Plugin.Geolocator.Abstractions.ActivityType.AutomotiveNavigation,
            AllowBackgroundUpdates = true,
            DeferLocationUpdates = true,
            DeferralDistanceMeters = 1,
            //DeferralTime = TimeSpan.FromSeconds(10),
            ListenForSignificantChanges = false,
            PauseLocationUpdatesAutomatically = false

        });
        count++;
        CrossGeolocator.Current.PositionChanged += changedPosition;
    }

Please give me some solution. Thanks in Advance.

Answers

  • Tracy320Tracy320 Member ✭✭

    Have you found the solution?

  • abhay27abhay27 Member ✭✭

    Not yet

  • jezhjezh Member, Xamarin Team Xamurai

    @You can try the following code:

          public async void CurrentLocation()
      {
        try
            {
                    await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(5), 10, true, new 
             Plugin.Geolocator.Abstractions.ListenerSettings
                {
                    ActivityType = Plugin.Geolocator.Abstractions.ActivityType.AutomotiveNavigation,
                    AllowBackgroundUpdates = true,
                    DeferLocationUpdates = true,
                    DeferralDistanceMeters = 1,
                    DeferralTime = TimeSpan.FromSeconds(1),
                    ListenForSignificantChanges = true,
                    PauseLocationUpdatesAutomatically = false
                });
         count++;
         CrossGeolocator.Current.PositionChanged += changedPosition;
       }
    

    However, you will only get an update once a new location is available. This seems to be a limitation of the Network Provider. If you want more frequent updates use the GPS provider. Depending on the GPS hardware you should get a maximum update rate around 4Hz.

Sign In or Register to comment.