ios - 在 iOS 中获取准确位置

标签 ios swift gps cllocationmanager

我使用此设置设置位置精度:

locationManager.desiredAccuracy = kCLLocationAccuracyBest

然后我得到了这个位置:

if let location = locations.first {
....
}

但是它多次更新位置,其中很多都不准确。例如,当我找到位置时,它距离设备位置大约 100 米。

如何获得准确的位置?

我知道在设备修复位置之前,前几个位置并不准确。

最佳答案

来自 the documentation :

The receiver does its best to achieve the requested accuracy; however, the actual accuracy is not guaranteed.

因此,您无法保证检测到的位置有多接近,但您可以尝试其他一些事情:

  1. 使用 kCLLocationAccuracyBestForNavigation .这应该能让您获得更准确的读数,但会消耗更多电池。

  2. 过滤位置,但我不知道这是否可行,因为您拥有的唯一数据是从您正在使用的位置管理器收到的数据。

关于ios - 在 iOS 中获取准确位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46407728/

相关文章:

ios - Swift - 游戏中心不可用

ios - Swift - TestFlight 版本中的 Vidyo SDK 问题

google-maps - 2个GPS坐标之间的线的功能

Objective-C:阻塞线程直到 NSTimer 完成(iOS)

ios - 自定义导航栏后退按钮点击区域

ios - 如何在 iOS 上搜索并连接附近的经典蓝牙设备(非 BLE)?

ios - 用户购买和下载应用程序时,苹果会开具收据吗?

Swift 4 隐藏按钮不再出现

ANDROID:addProximityAlert() 是如何工作的?

ios - 室内定位和 iBeacons