Skip to content

📍 Map modal for searching and selecting a location

License

Notifications You must be signed in to change notification settings

hlfcoding/HLFMapViewController

Repository files navigation

HLFMapViewController

Version License Platform Code Climate

A generic implementation of a common feature: searching and selecting a nearby location from an MKMapView.

screenshot-1   screenshot-2

Usage

This version uses Swift 3. The final Swift 2 version is 0.2.5.

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

In addition to turning on the 'Maps' capability, you'll need to add location-services to UIRequiredDeviceCapabilitiesand fill in NSLocationAlwaysUsageDescription in your Info.plist.

Other than that just set up the view controller and implement the delegate method:

// ...
let mapViewController = MapViewController(nibName: "MapViewController", bundle: MapViewController.bundle)
mapViewController.delegate = self
mapViewController.selectedMapItem = self.selectedMapItem // Optional.
// ...

func mapViewController(_ mapViewController: MapViewController, didSelectMapItem mapItem: MKMapItem) {
    self.selectedMapItem = mapItem // Save, submit, etc.
    mapViewController.dismissViewController(animated: true, completion: nil)
}

See example app for more details.

Installation

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

pod "HLFMapViewController"

License

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