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
2009-10-28 13:59:14
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
2009-10-28 16:00:55
Glad it worked. What difference did changing the method to `regionDidChangeAnimated` make? Was it a timing thing?
nevan
2009-10-28 22:25:49
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
2010-01-29 02:07:51
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
2010-01-29 03:08:18
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
2010-02-03 04:40:12