Search

Geocoding and reverse Geocoding

Applications developed with the Sygic iOS SDK can perform offline and online geocoding, which allows geocode and reverse geocode requests to be performed event without an active data connection. This is done automatically when an active data connection is not available, as long as the map and database information have been previously downloaded.

class SearchViewController: UIViewController {
    var reverseSearchResults: [SYReverseSearchResult] = []

    // Create an instance of SYReverseSearch
    let reverseSearch = SYReverseSearch()

    // Example of your method to perform reverse geocoding for specific coordinate
    func reverseSearch(at coordinate: SYGeoCoordinate) {

        // Perform request for coordinate
        self.reverseSearch.reverseSearch(with: coordinate) { [weak self] (reverseSearchResults) in
            self?.reverseSearchResults = reverseSearchResults

            // Example of accessing reverse geocoding results description
            if let firstResult = reverseSearchResults.first {
                let resultDescription = firstResult.resultDescription // Contains textual description of the found result

                let countryIsoCode = resultDescription.countryIso
                let city = resultDescription.city
                let street = resultDescription.street
                let houseNumber = resultDescription.houseNumber
            }
        }
    }
}