class ViewController: UIViewController { @IBOutlet weak var mapView: MKMapView! @IBOutlet weak var slidingView: UIView! @IBOutlet weak var slidingViewHeight: NSLayoutConstraint! override func viewDidLoad() { super.viewDidLoad() self.reloadMap() let pan = UIPanGestureRecognizer(target: self, action: "viewDidPan:") self.slidingView.addGestureRecognizer(pan) } func reloadMap() { let coordinate = CLLocationCoordinate2D(latitude: 37.332363, longitude: -122.030805) let height = Double(self.mapView.frame.size.height) let regionDistance = 0.3 * height * height
To customize the views, place the map and UIView in your view controller. Use autorun to snap the map to the left, top, and right sides of the screen. Then attach the bottom of the map to the top of the UIView . Then connect the left, bottom, and right sides of the UIView with the add-in. Finally, set the height limit on the UIView to what you want to initialize. This height value will be changed when the user drags the view. This allows UIView to grow as we like, and at the same time remove autostart.
Add @IBOutlet to the view controller for the map view, limiting the length of the UIView and UIView , as in the code above. The regionDistance property is what does the magic of scaling here. This is an exponential equation (which I did randomly) that will calculate the area for a larger or smaller size depending on the height of the map display. reloadMap() uses this to update map scaling. Binding all of this is the UIPanGestureRecognizer on the UIView , which controls the height of the UIView , causing the map to scale.
Pitfall: This forces the map to update the region faster than loading the region, which makes it very nervous. There are probably ways around this. Create an ad.
The coordinate that I used in the example is Apple headquarters.

source share