 
     // MARK: Implementation
 
+    fileprivate var hasSearch: Bool {
+        return !preparedSearchQuery.isEmpty
+    }
+    fileprivate var preparedSearchQuery: String {
+        return searchController.searchBar.text?.trimmingCharacters(in: .whitespaces) ?? ""
+    }
     fileprivate var removableAnnotations: [MKAnnotation] {
         return mapView.annotations.filter(isNonSelectedPlacemark)
     }


    open func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
        searchBar.resignFirstResponder()
        guard let query = preparedSearchQuery, !query.isEmpty else { return }
        shouldDebounceNextSearch = false
        searchQuery = query
    }

    open func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {


extension MapViewController: UISearchResultsUpdating {

    open func updateSearchResults(for searchController: UISearchController) {
        guard hasSearch else {
            mapView.removeAnnotations(removableAnnotations)
            return
        }
        searchQuery = preparedSearchQuery
    }

}
