Xamarin Forms Geolocator 持续更新位置

Xamarin Forms Geolocator Continuously Updating the Location

我希望不断更新设备在 Google 地图上的当前位置。

由于各种原因,我不得不实现自己的蓝点。我所做的是:

但是,位置更新需要很长的延迟。我希望以非常低的间隔(大约 50 毫秒)更新位置,这可以给我一个与设备移动时 Google 地图的原始 蓝点 类似的结果.

我怎样才能做到这一点?

我发现CrossGeolocator有一个监听功能如果有位置更新会提示。此函数不会一直调用当前位置,而是会持续监听任何位置变化。

if (CrossGeolocator.IsSupported &&
    CrossGeolocator.Current.IsGeolocationAvailable &&
    CrossGeolocator.Current.IsGeolocationEnabled)
{
    CrossGeolocator.Current.PositionChanged += HandlePositionChanged;
    await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 10);
}