【发布时间】:2016-06-25 20:49:12
【问题描述】:
我正在为一个应用开发概念验证功能。此应用将主要在室内使用。预期的结果是能够跟踪用户在按下按钮后是否在室内移动了 3 米以上。我使用 CoreLocation 进行这项工作 - 但结果并没有削减它。数字有时会“跳跃”,这会认为这个应用程序没用。
我正在寻找任何可能的替代方案。还查看了加速度计和 pedamater,但仍然觉得 GPS / CoreLocation 是我最好的选择。 (或者是...?)
我想到的一件事是使用 requestLocation,并每 10 秒重新检查一次,看看手机是否移动了 3 米以上。它不需要是实时的,所以我可以使用 10 秒的缓冲区。这会是最好的方法吗? (缺点是在 ios9 中引入了 requestLocation ......需要 ios8 及以下版本的替代解决方案)
这是我的代码(产生 GPS“跳跃”):
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let latestLocation: AnyObject = locations[locations.count - 1]
if startLocation == nil {
startLocation = latestLocation as! CLLocation
}
let distanceBetween: CLLocationDistance = latestLocation.distanceFromLocation(startLocation)
distanceLabel.text = String(format: "%.2f", distanceBetween)
if distanceBetween > 3.0{
labelOutput.text = "you traveled more than 3 meters"
}
}
提前谢谢..
【问题讨论】:
-
这是一篇关于ios 8室内定位的好文章。看起来影响可靠性的因素很多idownloadblog.com/2014/06/05/ios-8-indoor-positioning-m7这是wwdc的视频developer.apple.com/videos/play/wwdc2014/708
标签: gps swift2 cllocationmanager