I have an issue. My current location is displayed and centered in a map view however the map region doesn\'t get zoomed in to. I tried taking Rob\'s advice by taking span an
Swift 2.0:
Using Extension :
extension MKMapView{
func zoomInPinAnnotationLocation(targetMapViewName : MKMapView?, delta: Double)
{
var region: MKCoordinateRegion = targetMapViewName!.region
region.span.latitudeDelta /= delta
region.span.longitudeDelta /= delta
targetMapViewName!.region = region
}
func zoomOutPinAnnotationLocation(targetMapViewName : MKMapView?,delta: Double)
{
var region: MKCoordinateRegion = targetMapViewName!.region
region.span.latitudeDelta *= delta
region.span.longitudeDelta *= delta
targetMapViewName!.region = region
}
}
Usage:
var mapViewZoomStepperValue: Double = -1.0
@IBOutlet weak var mapViewZoomStepper: UIStepper!
@IBAction func mapViewZoomStepperValueChanged(sender: AnyObject) {
if (mapViewZoomStepper.value > mapViewZoomStepperValue)
{
mapViewZoomStepperValue = mapViewZoomStepperValue + 1.0
//Zoom In
detailMapView.zoomInPinAnnotationLocation(detailMapView, delta: 3.0)
}
else
{
mapViewZoomStepperValue = mapViewZoomStepper.value - 1.0
//Zoom Out
detailMapView.zoomOutPinAnnotationLocation(detailMapView, delta: 3.0)
}
}