diff --git a/MKMapView+ZoomLevel.h b/MKMapView+ZoomLevel.h index c6e485f..4dcba61 100644 --- a/MKMapView+ZoomLevel.h +++ b/MKMapView+ZoomLevel.h @@ -7,4 +7,6 @@ zoomLevel:(NSUInteger)zoomLevel animated:(BOOL)animated; +- (int) getZoomLevel; + @end diff --git a/MKMapView+ZoomLevel.m b/MKMapView+ZoomLevel.m index 2aa42a0..ca9bdd1 100644 --- a/MKMapView+ZoomLevel.m +++ b/MKMapView+ZoomLevel.m @@ -86,4 +86,9 @@ - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate [self setRegion:region animated:animated]; } +- (int) getZoomLevel +{ + return 21 - round(log2(self.region.span.longitudeDelta * MERCATOR_RADIUS * M_PI / (180.0 * self.bounds.size.width))); +} + @end