ios 当蜂窝数据和 Wi-Fi 都关闭时,是否可以获取用户位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13037138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:55:05  来源:igfitidea点击:

Is it possible to get user location when both cellular data and wi-fi are turned off?

iphoneiosgpsmkmapviewcore-location

提问by cowfaboo

I was in Scotland with a Canadian phone recently, and to avoid roaming charges I had my cellular data turned off throughout the trip. However, the pictures I took still had accurate geotags, meaning my location was still available to my camera apps (even though I couldn't actually see these locations on a map until I got home).

我最近带着一部加拿大电话在苏格兰,为了避免漫游费用,我在整个旅程中都关闭了手机数据。然而,我拍的照片仍然有准确的地理标签,这意味着我的位置仍然可供我的相机应用程序使用(即使我在回家之前实际上无法在地图上看到这些位置)。

My question is: how would I go about retrieving location data in a situation like that, where I can't actually display a map because there is no internet connection? And, just to improve my understanding, how is the location actually being retrieved? If "cellular data" is off, is GPS still available, or can the location only be calculated using nearby wi-fi hotspots at that point? And finally, if both cellular data AND wi-fi is turned off on a device, can location still be retrieved (i.e. is GPS still active)?

我的问题是:在这种情况下我将如何检索位置数据,因为没有互联网连接,我实际上无法显示地图?而且,只是为了提高我的理解,实际上是如何检索位置的?如果“蜂窝数据”关闭,GPS 是否仍然可用,或者只能使用附近的 wi-fi 热点计算位置?最后,如果设备上的蜂窝数据和 Wi-Fi 均已关闭,是否仍可检索位置(即 GPS 是否仍处于活动状态)?

Any info on the subject is welcome - all I am trying to do is handle all possible situations created by the presence or lack of location services and an internet connection in an app where I (if possible) display and store the user's location.

欢迎提供有关该主题的任何信息 - 我所要做的就是处理由定位服务的存在或缺失以及应用程序中的互联网连接造成的所有可能情况,我(如果可能)在其中显示和存储用户的位置。

Thanks!

谢谢!

回答by rmaddy

iOS devices that have actual GPS hardware in them can give accurate location data even if there is no WiFi or cellular.

即使没有 WiFi 或蜂窝网络,装有实际 GPS 硬件的 iOS 设备也可以提供准确的位置数据。

Of course, most map apps require an Internet connection to display a map. But if you have a map app with local map data, then you would be able to see the map with your position even without any Internet connection.

当然,大多数地图应用程序需要 Internet 连接才能显示地图。但是,如果您有一个带有本地地图数据的地图应用程序,那么即使没有任何 Internet 连接,您也可以查看带有您所在位置的地图。

On devices with an actual GPS, location services works just fine with no Internet. It may take a little longer to zero in on your position but it still works normally. Of course on iOS devices with no real GPS, you do need a cellular or WiFi signal to get any position data.

在具有实际 GPS 的设备上,定位服务在没有互联网的情况下也能正常工作。将您的位置归零可能需要更长的时间,但它仍然可以正常工作。当然,在没有真正 GPS 的 iOS 设备上,您确实需要蜂窝或 WiFi 信号来获取任何位置数据。