Sergey Zenchenko
Sergey Zenchenko

Reputation: 864

MapKit fix zoom

I have mapkit view and i need to fix zoom step. User must only increase or decrease by 4 times. How i can do it in MapKit?

Upvotes: 0

Views: 1961

Answers (1)

notnoop
notnoop

Reputation: 59299

The map doesn't provide a method to restrict the zoom increment. I should also say that the default implementation of the map view on the iPhone leads to better user experience I think. I personally dislike apps that limit my capabilities for no good reason.

To answer your question though, you can manually control your zooming, by disabling MKMapView.zoomEnabled property. Then you can expose a zoom buttons that change the shown map region, using setRegion:animated:.

Here is a sample code on how to zoom the map:

-(void)zoomMap:(MKMapView *)map withLevelMultiple:(void)levelMultiplier {
  MKCoordinateRegion region = map.region;
  region.span.latitudeDelta /= levelMultiplier;
  region.span.longitudeDelta /= levelMultiplier;
  [map setRegion:region animated:YES];
}

Upvotes: 3

Related Questions