LMGeocoder is a simple wrapper for geocoding and reverse geocoding, using both Google Geocoding API and Apple iOS Geocoding Framework.
- Wrapper for Geocoding and Reverse geocoding with blocked-based coding.
- Use both Google Geocoding API and Apple iOS Geocoding Framework.
iOS 8.0 or higher
LMGeocoder is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LMGeocoder'
https://github.com/lminhtm/LMGeocoderSwift
[[LMGeocoder sharedInstance] geocodeAddressString:addressString
service:LMGeocoderServiceGoogle
alternativeService:LMGeocoderServiceApple
completionHandler:^(NSArray *results, NSError *error) {
if (results.count && !error) {
LMAddress *address = [results firstObject];
NSLog(@"Coordinate: (%f, %f)", address.coordinate.latitude, address.coordinate.longitude);
}
}];
[[LMGeocoder sharedInstance] reverseGeocodeCoordinate:coordinate
service:LMGeocoderServiceGoogle
alternativeService:LMGeocoderServiceApple
completionHandler:^(NSArray *results, NSError *error) {
if (results.count && !error) {
LMAddress *address = [results firstObject];
NSLog(@"Address: %@", address.formattedAddress);
}
}];
[[LMGeocoder sharedInstance] cancelGeocode];
To run the example project, clone the repo, and run pod install
from the Example directory first.
LMGeocoder is available under the MIT license. See the LICENSE file for more info.
Minh Nguyen