【问题标题】:Windows-Geolocator returns chached positions after about 15 minutesWindows-Geolocation 在大约 15 分钟后返回缓存的位置
【发布时间】:2021-07-02 23:12:34
【问题描述】:

我使用 Windows-Geolocator 中的 PositionChanged-Event 在地图上显示用户当前位置。一切正常,但大约 15 分钟后,地理定位器只返回相当旧的位置(30 秒到一分钟):

这是我的日志文件中的一个 sn-p:

2021-04-06 18:07:23,787 信息 [127:WindowsGnssPositionProvider:LocatorOnPositionChanged()]-> LocatorOnPositionChanged vom Geolocator: Long: xxxx, Lat: xxxx,精度:4,时间戳:06.04.2021 18:06:22 +02:00, 来源:卫星

距离越远,时间越久。

这是我的地理定位器实例:

geolocator = new Geolocator()
{
    DesiredAccuracy = PositionAccuracy.High,
    ReportInterval = 1000
};
geolocator.PositionChanged += Geolocator_PositionChanged;

有没有办法解决这个问题或从地理定位器中清除缓存?

【问题讨论】:

    标签: c# wpf windows geolocation


    【解决方案1】:

    尝试用计时器替换您的位置更改事件。 我不知道这个库,但我可以想象你这个事件被如此频繁地触发,以至于你无法跟上,而是兑现所有事件,从而延迟了这个过程:

    System.Timers.Timer t = new System.Timers.Timer(1000);
    t.Start();
    t.Elapsed += Geolocator_PositionChanged;
    

    【讨论】:

    • 您好,感谢您的回答。但这不是我的问题。我每秒都会获得位置,但是如果您查看“时间戳” - 来自位置的属性(确定位置的系统时间),您可以看到地理定位器在每个新 PositionChanged-Event 上返回旧位置
    • 您是否停止更改位置?还是您的位置变化低于您定义的阈值?
    • 哦,对不起,我在示例中写错了属性。 ReportInterval = 1000 而不是 MovementThreshold。在我的真实代码中,我写了 ReportInterval
    • 在这一点上,从来没有使用过这个库,我已经帮不上忙了……祝你好运! :) 您可以每隔一秒创建一个新的地理定位器并处理旧的:D
    猜你喜欢
    • 2015-08-13
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-30
    • 2021-08-10
    相关资源
    最近更新 更多