CLLocationManager 在没有互联网/蜂窝连接的情况下是否可以工作?
愚蠢的问题!!虽然我想知道 CLLocationManager 是否可以在没有互联网的情况下工作?
即 iPhone 根本没有连接到互联网
Silly question !! Though I want to know that is it possible that CLLocationManager works without Internet ?????
i.e. iPhone is not connected to internet at all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
iPhoneiPadDev 的答案略有错误:虽然位置管理器有时会失败,但它可以在没有网络连接的情况下工作。如果您想亲眼目睹这一点,请开车去蜂窝信号接收很差或根本不存在的地方:GPS 仍然可以工作。
这在很大程度上取决于您周围的环境条件以及您使用的设备。 iPod Touch 和某些 iPad 没有 GPS,而是依靠 WiFi 热点来确定其位置数据。如果您没有网络访问权限,
CLLocationManager
将返回无效位置。iPhone 和 3G iPad 有 GPS,因此您可能会返回适当的位置。 但是,他们使用 A-GPS(辅助 GPS),它使用来自网络的信息来实现更快的 GPS 锁定。如果您没有互联网连接,GPS 芯片可能需要一些时间才能获取信号并提供准确的位置:如果您在室内或看不到天空,准确性可能会大幅下降。
要点:
CLLocationManager
可以并且将会返回您的位置,即使没有可用的位置:但是,坐标将是无效的。在使用之前测试返回的位置并确保您对它们的正确性感到满意非常重要。iPhoneiPadDev's answer is slightly wrong: whilst sometimes the location manager will fail, it can work without network connectivity. If you want to see this for yourself, go for a drive somewhere with terrible or nonexistent cellular reception: GPS will still work.
It very much depends on the environmental conditions around you, and the device you're using. iPod Touches and some iPads don't have GPS, and rely on WiFi hotspots to determine their location data. If you don't have network access the
CLLocationManager
will return an invalid location.iPhones and 3G iPads do have GPS, so you may get an appropriate location returned. However, they use A-GPS (assisted GPS), which uses information from the network to allow a faster GPS lock. If you don't have internet connectivity it may take some time for the GPS chip to obtain a signal and provide an accurate location: and accuracy may be wildly off, if you're indoors or don't have plain sight of the sky.
Important point:
CLLocationManager
can and will return you locations even if none are available: the coordinates, however, will be invalid. It's important to test the locations being returned and make sure you're satisfied they are correct before using them.是的,如果在设备设置中启用了定位服务,它就可以工作。无需互联网连接。
Yeah it works if Location Services are enabled in the device settings. No need for Internet connection.
是的,但在开阔的天空中(意味着在道路上、地面上)。
要解决此问题:
当您需要位置时,在离线模式下记录时间戳(例如“RecordDate”),然后比较 didUpdateToLocations: 方法给出的时间戳。
如果 didUpdateToLocations 的时间戳 >记录时间戳然后使用它
Yes but in open sky(Means on road, ground).
To fix this:
Record timestamp(Say "RecordDate") in offline mode when you want location then compare timestamp given by didUpdateToLocations: method.
if didUpdateToLocations's timestamp > Recorded Timestamp then use it
Core Location 使用许多传感器来获取位置:蓝牙、Wi-Fi、GPS、气压计、磁力计以及苹果所谓的“蜂窝硬件”。 GPS、BLE、气压计和磁力计都不需要数据连接。
Core Location uses a number of sensors to get a location: Bluetooth, Wi-Fi, GPS, barometer, magnetometer, and what Apple calls "cellular hardware". GPS, BLE, barometer, and magnetometer all don't need a data connection.