swift - 当前位置和更新位置之间的距离
问题描述
我想得到两个位置之间的距离。
第一个位置是我当前的位置,另一个位置是用户更新的位置。
那么,如何跟踪用户位置并测量当前位置与用户更新位置之间的距离
我尝试了此代码,但该措施不正确。
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let loc = locations.last else {return}
guard let startLocation = startLocation else {
self.startLocation = loc
return
}
guard let current = manager.location else { return }
let distance = current.distance(from: startLocation)
print("Distance: \((distance))")
}
解决方案
推荐阅读
- javascript - discord.js-commando TypeError: this.fetchUser 不是一个函数
- java - 通过代理服务器连接到数据库休眠、JDBC
- python - 在 pandas 中创建 n 个行的副本
- python-3.x - 如果将 Firebase 广告和分析添加到 buildozer.spec 并请求广告,Kivy Buildozer APK 会崩溃
- c# - 在 EF 上查询虚拟列表属性
- linux - Linux At Now 命令调用带有属性的 Bash 脚本
- sql-server - 如何修复 - 无法加载 DLL 'SqlServerSpatial110.dll' 错误
- jenkins - 如何在 Linux 的从节点中运行 Jenkins 作业时指定用户
- c++ - 缺少功能描述 (IDE)
- c++ - 使用 Eigen::FFT 执行 FFT 时的频率