当用户从 iOS 项目中的 CoreLocation 步行时,我正在选取用户的 GPS 坐标,我想选取每 1 米或每 10 秒的纬度和经度,
我可以使用 DesiredAcuracy 和 DistanceFilter 来执行此操作吗?
如果不是,这两个(DesiredAcuracy 和 DistanceFilter)实际上会做什么?
或者我应该创建自己的计时器来完成它吗?
最佳答案
我可以使用 DesiredAcuracy 和 DistanceFilter 这样做吗? 是的,根据 docs :
期望准确度
The receiver does its best to achieve the requested accuracy; however, the actual accuracy is not guaranteed.
You should assign a value to this property that is appropriate for your usage scenario. For example, if you need the current location only within a kilometer, you should specify
kCLLocationAccuracyKilometer
and notkCLLocationAccuracyBestForNavigation
. Determining a location with greater accuracy requires more time and more power.
在你的情况下,你应该使用 kCLLocationAccuracyKilometer
用于未插入的设备(例如,用户使用它来运行距离)或 kCLLocationAccuracyBestForNavigation
用于插入的设备(例如,在车里)
kCLLocationAccuracyBestForNavigation
Use the highest possible accuracy and combine it with additional sensor data. This level of accuracy is intended for use in navigation applications that require precise position information at all times and are intended to be used only while the device is plugged in.
kCLLocationAccuracyKilometer
Accurate to the nearest kilometer. Available in iOS 2.0 and later.
kCLLocationAccuracyBest
Use the highest-level of accuracy. Available in iOS 2.0 and later.
距离过滤器
This distance is measured relative to the previously delivered location. >Use the value
kCLDistanceFilterNone
to be notified of all movements. The default value of this property iskCLDistanceFilterNone
.
因此,如果您需要频繁的距离更新(即用户必须移动多远才能收到更新),您应该使用kCLDistanceFilterNone
。
关于ios - DesiredAcuracy和DistanceFilter在CoreLocation中的作用是什么,ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31476113/