Xamarin表格:地理定位器问题

Xamarin表格:地理定位器问题,xamarin,geolocation,mvvmcross,Xamarin,Geolocation,Mvvmcross,我有一个问题是地理定位器,我已经宣布时间为10秒。然后也在 Android:10秒或10秒以上更新。在IOS中:每秒钟更新一次。 这是我的代码: public async void CurrentLocation() { try { await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(10), 0, true, new Plugin

我有一个问题是地理定位器,我已经宣布时间为10秒。然后也在 Android:10秒或10秒以上更新。在IOS中:每秒钟更新一次。 这是我的代码:

     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;
        }
请给我一些解决办法。提前谢谢

关于代码,
minimumTime
未在iOS中实现(至少尚未实现)

在后台,如果您将
deleraltime=TimeSpan.FromSeconds(10)
设置为以下状态,则它应该可以工作:

摘要:如果延迟位置更新,则为在交付更新之前应经过的最短时间(>=iOS 6)。无限期等待设置为null。默认值:5分钟

值:更新之间的时间间隔

因此,为了解决前景中的问题,您可以跳过
位置更改处理程序中不需要的位置:

Plugin.Geolocator.Abstractions.Position lastPosition = null;
var timePeriod = TimeSpan.FromSeconds(10);

private void ChangedPosition(object sender, Plugin.Geolocator.Abstractions.PositionEventArgs e)
{
    var lapsed = e.Position.Timestamp - lastPosition.Timestamp;
    lastPosition = e.Position;

    if (lapsed < timePeriod)
        return;

    // your logic
}
Plugin.geologitor.Abstractions.Position lastPosition=null;
var timePeriod=从秒开始的时间跨度(10);
私有void ChangedPosition(对象发送者,Plugin.geologitor.Abstractions.PositionEventArgs e)
{
var Fassed=e.Position.Timestamp-lastPosition.Timestamp;
lastPosition=e.位置;
如果(失效<时间段)
返回;
//你的逻辑
}
这就是它在未来基本上要做的事情