Skip to content

Simple wrapper for geocoding and reverse geocoding, using both Google Geocoding API and Apple iOS Geocoding Framework.

License

Notifications You must be signed in to change notification settings

onyx1409/LMGeocoderSwift

 
 

Repository files navigation

LMGeocoderSwift

LMGeocoderSwift is a simple wrapper for geocoding and reverse geocoding, using both Google Geocoding API and Apple iOS Geocoding Framework.

CI Status Version License Platform

Features

  • Wrapper for Geocoding and Reverse geocoding with blocked-based coding.
  • Use both Google Geocoding API and Apple iOS Geocoding Framework.

Requirements

  • iOS 8.0 or higher
  • Swift 5.0

Installation

LMGeocoderSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'LMGeocoderSwift'

Objective-C Version

https://github.com/lminhtm/LMGeocoder

Usage

Geocoding

Geocoder.shared.geocodeAddressString(addressString, service: .apple, alternativeService: .google) { (results, error) in
                
    // Update UI
    if let address = results?.first, error == nil {
        DispatchQueue.main.async {
            self.coordinateLabel.text = "(\(address.coordinate?.latitude ?? 0), \(address.coordinate?.longitude ?? 0))"
        }
    }
}

Reverse Geocoding

Geocoder.shared.reverseGeocodeCoordinate(coordinate, service: .apple, alternativeService: .google) { (results, error) in
                
    // Update UI
    if let address = results?.first, error == nil {
        DispatchQueue.main.async {
            self.addressLabel.text = address.formattedAddress ?? "-"
        }
    }
}

Cancel Geocode

Geocoder.shared.cancelGeocode()

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

License

LMGeocoderSwift is available under the MIT license. See the LICENSE file for more info.

Author

Minh Nguyen

About

Simple wrapper for geocoding and reverse geocoding, using both Google Geocoding API and Apple iOS Geocoding Framework.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.3%
  • Ruby 3.7%