Fahim Parkar Fahim Parkar - 4 months ago 12
iOS Question

iOS : zoom in and zoom out effect on map

I have created map as show on this link and its working perfectly.

But the problem is, It only zoom in one way (it get bigger only). How could I make it working on either way?

May be like we have on google map (plus - minus stick on the left side).

Answer

For ZoomIn

-(void)zoomIn
{
    region.span.latitudeDelta = region.span.latitudeDelta/4 ;
    region.span.longitudeDelta = region.span.longitudeDelta/4;



    region.center.latitude = mapView.centerCoordinate.latitude ;
    region.center.longitude = mapView.centerCoordinate.longitude ;
    [mapView setRegion:region animated:YES];
}

For ZoomOut

-(void)zoomOut
{
    region.span.latitudeDelta = region.span.latitudeDelta*4 ;
    region.span.longitudeDelta = region.span.longitudeDelta*4;



    region.center.latitude = mapView.centerCoordinate.latitude ;
    region.center.longitude = mapView.centerCoordinate.longitude ;
    [mapView setRegion:region animated:YES];
}

You use the delta values in this structure to indicate the desired zoom level of the map, with smaller delta values corresponding to a higher zoom level.

Please refer this link for more.