         return view
     }
 }
+
+protocol MapViewControllerDelegate {
+    func mapViewController(_ controller: MapViewController, didUpdateVisibleZones zones: [Zone])
+}

    @IBOutlet var mapView: MKMapView!
    
    private let mapMaxAltitude: CLLocationDistance = 500.0
    
    var zones: [Zone] = [] {
        didSet {

            pulley.setDrawerPosition(position: .collapsed)
        }
    }
    
    func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
        // Figure out which zones are now visible
        let visibleMapRect = mapView.visibleMapRect
        let paddedMapRect = mapView.mapRectThatFits(visibleMapRect, edgePadding: UIEdgeInsets(top: 50.0, left: 50.0, bottom: 50.0, right: 50.0))
        
        let annotations = mapView.annotations(in: paddedMapRect)
        let overlays = mapView.overlays.filter({ overlay in
            return MKMapRectIntersectsRect(overlay.boundingMapRect, paddedMapRect)
        })
                
        let zones = annotations.flatMap({ ($0 as? Annotation)?.zone }) + overlays.flatMap({ ($0 as? Annotation)?.zone })
        let uniqueZones = zones.reduce([]) { $0.contains($1) ? $0 : $0 + [$1] }
        
        // Sort the zones based on distance from the center (unless we are inside of them, in which case the distance is equivalent to 0)
        let coordinate = mapView.userLocation.coordinate
        let sorted = uniqueZones.sorted { (a, b) -> Bool in
            guard a.isPoint && b.isPoint else {
                return a.contains(coordinate: coordinate) && !b.contains(coordinate: coordinate)
            }
            
            return a.distance(from: coordinate) < b.distance(from: coordinate)
        }
        
        self.delegate?.mapViewController(self, didUpdateVisibleZones: sorted)
    }

    func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) {
        // Ignore if we are not to follow user
        guard self.trackUserLocation else {
            return
        }
        
        // Update camera (if altitude is higher than expected)
        let existingCamera = mapView.camera
        let altitude = min(existingCamera.altitude, self.mapMaxAltitude)
