【问题标题】:CLLocationManager giving wrong location updatesCLLocationManager 提供错误的位置更新
【发布时间】:2015-04-22 03:46:29
【问题描述】:

我正在开发一个跟踪应用程序,它需要在地图上显示跟踪路径。当我开始更新位置并且安装后没有移动设备时,locationManagar 报告错误的位置更新,

我正在根据报告的位置点绘制路线,

另外,当用户在直路上高速行驶时,也会出现这样的故障,

如何忽略这些错误的位置更新

您可以下载应用程序here并自己测试

【问题讨论】:

  • 你找到解决办法了吗?
  • 是的,您可以使用 lastLocation.horizo​​ntalAccuracy 并且您可以计算从最后一个已知位置所覆盖的距离,并且可以设置偏移量,无论新位置是否距离 X 米?以及 CoreMotion 以根据您的要求实际检查设备是否在移动。
  • @zaheer 请提供更多细节,例如它的示例代码
  • 我明天更新
  • @zaheer 你能帮帮我吗.. 我怎么能忽略错误的位置

标签: ios xcode gps cllocationmanager


【解决方案1】:

查看水平精度,检查此项以确保您的位置准确。例如10米以下或零以下:

    // test that the horizontal accuracy does not indicate an invalid measurement
    if (lastLocation.horizontalAccuracy < 0)
        return;

并确保您有一个新位置,因为它将返回最后一个默认位置:

// test the age of the location measurement to determine if the measurement is cached
        // in most cases you will not want to rely on cached measurements
        NSTimeInterval locationAge = -[lastLocation.timestamp timeIntervalSinceNow];
        if (locationAge > 5.0)
            return;

还要确保在 CLLocationManager 上设置了正确的 desiredAccuracy。例如:

_manager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;

【讨论】:

  • 我做了所有这些技巧,但不幸的是这些都对我不起作用。
  • 也许您可以使用当前代码更新您的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-29
相关资源
最近更新 更多