Simple location picker with a built in maps. The selected item can be returned to the calling controller as a CLLocationCoordinate2D
.
- Link
CoreLocation.framework
andMapKit.framework
to your project - Fill in
NSLocationWhenInUseUsageDescription
in your Info.plist - Import
CoreLocation
andLocationPickerController
- Initialize the LocationPickerController
- Push the controller
import CoreLocation
import LocationPickerController
let viewController = LocationPickerController(success: {
[weak self] (coordinate: CLLocationCoordinate2D) -> Void in
self?.locationLabel.text = "".appendingFormat("%.4f, %.4f",
coordinate.latitude, coordinate.longitude)
})
let navigationController = UINavigationController(rootViewController: viewController)
self.present(navigationController, animated: true, completion: nil)
LocationPickerController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "LocationPickerController"
Swift 5.0 / iOS 12.0+
LocationPickerController is available under the MIT license. See the LICENSE file for more info.