 import UIKit
 import MapKit
 import CoreLocation
-import AddressBookUI
 
 public class MapViewController: UIViewController {
 	public var completion: (Location? -> ())?

		
		mapView.delegate = self
		
		// search
		navigationItem.titleView = searchBar
		definesPresentationContext = true
	}
}


	}
}

// MARK: Selecting location with gesture

extension MapViewController {
	func addLocation(gestureRecognizer: UIGestureRecognizer) {
		if gestureRecognizer.state == .Began {
			let point = gestureRecognizer.locationInView(mapView)
			let coordinates = mapView.convertPoint(point, toCoordinateFromView: mapView)
			let location = CLLocation(latitude: coordinates.latitude, longitude: coordinates.longitude)
			
			// remove current location
			cleanAnnotations()
			
			// add annotation to map
			let annotation = MKPointAnnotation()
			annotation.coordinate = coordinates
			mapView.addAnnotation(annotation)
			
			geocoder.cancelGeocode()
			geocoder.reverseGeocodeLocation(location) { response, error in
				let placemark = (response as? [CLPlacemark])?.first
				if let placemark = placemark {
					// get POI name from placemark if any
					let name = (placemark.areasOfInterest as? [String])?.first
					self.location = Location(name: name, placemark: placemark)
					
					// set annotatio title
					annotation.title = self.location!.title
				}
			}
		}
	}
}

// MARK: MKMapViewDelegate

extension MapViewController: MKMapViewDelegate {
