 	
 	public var location: Location? {
 		didSet {
-			if let location = location {
-				searchBar.text = location.name
-			} else {
-				searchBar.text = ""
-			}
+			searchBar.text = flatMap(location, { $0.title }) ?? ""
+			updateAnnotation()
 		}
 	}
 	

			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
				}
			}
		}

		pin.canShowCallout = true
		return pin
	}
	
	public func mapView(mapView: MKMapView!, didAddAnnotationViews views: [AnyObject]!) {
		if let annotations = mapView.annotations {
			assert(annotations.count == 1, "Only one annotation should be on map at a time")
		}
	}
}

// MARK: UISearchBarDelegate

extension MapViewController: UISearchBarDelegate {
	public func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
		// remove location if user presses clear or removes text
		if searchText.isEmpty {
			location = nil
		}
	}
