ios - 反向地理编码是否需要蜂窝/wifi?

标签 ios swift core-location mkreversegeocoder

反向地理编码是否需要蜂窝/Wi-Fi?我使用以下代码来查找城市名称和邮政编码。此代码可以在有 GPS 连接但没有蜂窝网络连接的环境中工作吗?

   geoCoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) -> Void in
        print("REVERSE COMPLETED")
        // Place details
        var placeMark: CLPlacemark!
        placeMark = placemarks?[0]

        // Address dictionary
        print(placeMark.addressDictionary)

        // City
        if let city = placeMark.addressDictionary!["City"] as? NSString {
            print("You are in \(city)")
        } else {
            print("An error occured while fetching the CITY.")
        }

        // Zip code
        if let zip = placeMark.addressDictionary!["ZIP"] as? NSString {
            print("The zip code is \(zip)")
        } else {
            print("An error occured while fetching the ZIP code.")
        }
    })

最佳答案

是的,地理编码和反向地理编码都需要互联网连接。如果您要在本地执行此操作,则需要 GIS 软件和包含您要进行地理编码的区域的地理信息的大型地理数据库。

软件和数据库既庞大又昂贵。我不知道适用于移动设备的 GIS 软件 - 在移动设备上,这一切都是在云端完成的。

在有 GPS 但没有互联网的 iOS 上,您唯一能做的就是收集纬度/经度位置。

顺便说一句,这与 Swift 无关。位置管理器是 iOS 的一部分,可以从任何支持的语言调用。这不是“Swift 地理编码”。这是 iOS 核心位置地理编码。

关于ios - 反向地理编码是否需要蜂窝/wifi?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38624347/

相关文章:

swift - 当网络连接不可用时,Realm 使用本地数据库而不是同步?

iphone - iOS Significant Location Change 是否应该在重新启动*锁定*手机后唤醒我的应用程序?

iOS-UITextField : extend the bottom line for ANY resolution

ios - (底部)工具栏导航在升级到 Xcode 9.0.1(& Swift 3 到 4)后不再响应

swift - 如何组合平面图使其只需要使用一次

swift - 下划线符号是否忽略或检查 Swift 中 switch 语句中的空值?

ios - 为什么 'CLLocationManager.locationServicesEnabled()' 默认为真?

objective-c - 尝试添加核心位置时出现未知问题

ios - ARC 和 UIAlertView : unrecognized selector sent to instance

ios - 如何仅在 iOS 版本大于特定版本时导入文件