views:

619

answers:

1

Hello all, the question is - is there a way to limit maximum zoom level for MKMapView? Or is there a way to track when user zooms to the level where there's no map image available?

+1  A: 

You could use the mapView:regionWillChangeAnimated: delegate method to listen for region change events, and if the region is wider than your maximum region, set it back to the max region with setRegion:animated: to indicate to your user that they can't zoom out that far. Here's the methods:

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
nevan
Thank you. It seems to work ok for me, It just appeared that its better to do this in regionDidChangeAnimated method instead of regionDidChangeAnimated
Vladimir
Glad it worked. What difference did changing the method to `regionDidChangeAnimated` make? Was it a timing thing?
nevan
Can you provide the code you used inside of regionDidAnimate? Every time I call [mapView setRegion] from inside of regionDidAnimate I enter an infinite loop.
devinfoley
Hi flashcards. It would probably be easier to open a new question with your problem. You could explain it more fully with a code sample.
nevan
I had exactly the same problem as flashcards. I would argue that the question hasn't been answered sufficiently - could someone post some working source code that does NOT create an infinite loop?
IQpierce