Change the scope (scaling) for mapView Swift

I have a card, and I draw a destination between two pins, and I also always open one call.

My problem is that I want to zoom out a bit, but I tried to do this with this code, and it didn't work.

let span = MKCoordinateSpanMake(0.0275, 0.0275) let coodinate = self.meLocation! let region = MKCoordinateRegion(center: coodinate, span: span) self.mapView.setRegion(region, animated: true) 

I assume that creating a line for the destination makes the problem:

 func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer { let renderer = MKPolylineRenderer(overlay: overlay) renderer.strokeColor = UIColor(red: 2.0/255.0, green: 202.0/255.0, blue: 246.0/255.0, alpha: 1.0) renderer.lineWidth = 2.8 return renderer } 

So my question is how can I zoom out by default.

EDIT:

I followed this guide

+5
source share
2 answers

The zoom level depends on the range. Try changing these values:

 let span = MKCoordinateSpanMake(0.0275, 0.0275) 

Edit:

As with the discussion, the overlay works best for your card.

Try filling the edges as follows:

 self.mapView.setVisibleMapRect(self.mapView.visibleMapRect, edgePadding: UIEdgeInsetsMake(40.0, 20.0, 20, 20.0), animated: true) 

Change the values ​​for a better match.

Note. Call it after:

 self.mapView.setRegion(MKCoordinateRegionForMapRect(rect), animated: true) 
+5
source

You need setRegion which you want to increase. This link can help you set the region.

Thanks:)

0
source

Source: https://habr.com/ru/post/1260335/


All Articles