iosswiftcore-locationmkreversegeocoder

Does reverse geocoding require cellular/wifi?


Does reverse geocoding require cellular/wifi? I'm using the following code to find the name of the city and the zip code. Will this code work in an environment with a GPS connection but without cellular connection?

   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.")
        }
    })

Solution

  • Yes, geocoding and reverse geocoding both require an Internet connection. If you're going to do it locally you need GIS software and a large geographic database containing the geography of the area in which you're geocoding.

    The software and the databases are both big and expensive. I don't know of GIS software for mobile devices - from mobile it's all done on the cloud.

    The only thing you can do on iOS with a GPS but no internet is collect lat/long positions.

    BTW, this has nothing to do with Swift. The location manager is part of iOS and callable from any supported language. It's not "Swift geocoding." It's iOS Core Location geocoding.