【发布时间】:2017-06-26 01:01:17
【问题描述】:
我正在使用 CLLocationManager 来获取用户位置。
我想获得一个位置更新。
我的问题是我变得非常糟糕horizontalAccuracy
位置是 %@ +/- 3881.91m
垂直精度:65.4401861912846,水平精度:3881.90892434957
代码:
fileprivate lazy var locationManager: CLLocationManager = {
let manager = CLLocationManager()
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.delegate = self
manager.requestAlwaysAuthorization()
manager.pausesLocationUpdatesAutomatically = false
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.distanceFilter = kCLDistanceFilterNone
return manager
}()
override init() {
super.init()
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let mostRecentLocation = locations.last else {
return
}
let verticalAccuracy = mostRecentLocation.verticalAccuracy
let horizontalAccuracy = mostRecentLocation.horizontalAccuracy
print("location is %@", mostRecentLocation)
print("verticalAccuracy: \(verticalAccuracy), horizontalAccuracy:\(horizontalAccuracy)")
}
任何建议为什么会发生这种情况? 我在靠近窗户的房间里,所以我除了精度差,但还不错。
谢谢
我得到了荒谬的结果。
我的水平精度为 15,000 m。
当我出门时效果很好,但在门里不应该像这样糟糕。
使用蜂窝三角测量和 wifi 应该会产生更好的结果。
20 分钟后,我开始在门中获得 +- 50 m 精度的良好结果。
【问题讨论】:
-
您在哪里测试应用程序?近窗不是一个好的选择。
-
@Apurv,为什么不呢?我不希望得到最好的结果,但 4 公里的精度是荒谬的。
标签: ios swift core-location cllocationmanager