Setting the zoom level for a MKMapView

后端 未结 15 2954
不知归路
不知归路 2020-12-02 05:46

I have a map which shows correctly, the only thing I want to do now is set the zoom level when it loads. Is there a way to do this?

Thanks

15条回答
  •  渐次进展
    2020-12-02 06:14

    I hope following code fragment would help you.

    - (void)handleZoomOutAction:(id)sender {
        MKCoordinateRegion newRegion=MKCoordinateRegionMake(mapView.region.center,MKCoordinateSpanMake(mapView.region.s       pan.latitudeDelta/0.5, mapView.region.span.longitudeDelta/0.5));
        [mapView setRegion:newRegion];
    }
    
    
    - (void)handleZoomInAction:(id)sender {
        MKCoordinateRegion newRegion=MKCoordinateRegionMake(mapView.region.center,MKCoordinateSpanMake(mapView.region.span.latitudeDelta*0.5, mapView.region.span.longitudeDelta*0.5));
        [mapView setRegion:newRegion];
    }
    

    You can choose any value in stead of 0.5 to reduce or increase zoom level. I have used these methods on click of two buttons.

提交回复
热议问题