简体   繁体   English

CLLocationManager如何获取位置?

[英]How does CLLocationManager get location?

TL;DR: My objective: Try all forms of getting a location and then choose the most accurate one, (try get a location for a minute then time out). TL; DR:我的目标:尝试各种获取位置的方法,然后选择最准确的一种(尝试获取位置一分钟然后超时)。

I'm a little confused about where it gets the location from, is it GPS? 我对它从哪里获取位置感到困惑,这是GPS吗? Cellular? 蜂窝电话? or a mix of both depending on toolkit? 还是两者都取决于工具包?

While getting location on Android I used both and then choose which provider based on accuracy. 在Android上获取位置信息时,我同时使用了两者,然后根据准确性选择了哪个提供商。 I do not see anything similar for iOS. 我没有看到与iOS类似的东西。

I'm using CLLocationManager which is showing good accuracy but I'm not sure where the location is from. 我正在使用CLLocationManager,它显示出良好的准确性,但是我不确定该位置来自哪里。

On iOS, location manager is built more intelligently. 在iOS上,位置管理器的构建更加智能。 Relying on your configuration, it either uses GPS or WiFi/cell radios, as described in the CLLocationManager documentation: 依靠您的配置,它可以使用GPS或WiFi /蜂窝无线电,如CLLocationManager文档中所述:

For the services you use, configure any properties associated with that service accurately. 对于您使用的服务,请准确配置与该服务关联的所有属性。 Core Location manages power aggressively by turning off hardware when it is not needed. 核心位置通过在不需要时关闭硬件来积极管理电源。 For example, setting the desired accuracy for location events to one kilometer gives the location manager the flexibility to turn off GPS hardware and rely solely on the WiFi or cell radios, which can lead to significant power savings. 例如,将位置事件的所需精度设置为一公里,可以使位置管理器灵活地关闭GPS硬件,而仅依靠WiFi或蜂窝无线电,这可以节省大量电能。

For more information, read CLLocationManager documentation . 有关更多信息,请阅读CLLocationManager文档

EDIT 编辑

And, If you want the most accurate location, you should put kCLLocationAccuracyBestForNavigation for location manager's desiredAccuracy property. 而且,如果您想要最准确的位置,则应将kCLLocationAccuracyBestForNavigation用作位置管理器的desiredAccuracy属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM