Authored by Quazie

Fixing issue 71 with Vladimir's patch

@@ -139,10 +139,12 @@ enum { @@ -139,10 +139,12 @@ enum {
139 - (void)moveBy: (CGSize) delta; 139 - (void)moveBy: (CGSize) delta;
140 - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center; 140 - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center;
141 - (void)zoomInToNextNativeZoomAt:(CGPoint) pivot animated:(BOOL) animated; 141 - (void)zoomInToNextNativeZoomAt:(CGPoint) pivot animated:(BOOL) animated;
  142 +- (void)zoomOutToNextNativeZoomAt:(CGPoint) pivot animated:(BOOL) animated;
142 - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center animated:(BOOL) animated; 143 - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center animated:(BOOL) animated;
143 - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center animated:(BOOL) animated withCallback:(id<RMMapContentsAnimationCallback>)callback; 144 - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center animated:(BOOL) animated withCallback:(id<RMMapContentsAnimationCallback>)callback;
144 145
145 - (void)zoomInToNextNativeZoomAt:(CGPoint) pivot; 146 - (void)zoomInToNextNativeZoomAt:(CGPoint) pivot;
  147 +- (void)zoomOutToNextNativeZoomAt:(CGPoint) pivot;
146 - (float)adjustZoomForBoundingMask:(float)zoomFactor; 148 - (float)adjustZoomForBoundingMask:(float)zoomFactor;
147 - (void)adjustMapPlacementWithScale:(float)aScale; 149 - (void)adjustMapPlacementWithScale:(float)aScale;
148 - (void)setZoomBounds:(float)aMinZoom maxZoom:(float)aMaxZoom; 150 - (void)setZoomBounds:(float)aMinZoom maxZoom:(float)aMaxZoom;
@@ -414,6 +414,23 @@ @@ -414,6 +414,23 @@
414 } 414 }
415 } 415 }
416 416
  417 +- (void)zoomOutToNextNativeZoomAt:(CGPoint) pivot animated:(BOOL) animated {
  418 + // Calculate rounded zoom
  419 + float newZoom = roundf([self zoom] - 1);
  420 +
  421 + if (newZoom <= [self minZoom])
  422 + return;
  423 + else {
  424 + float factor = exp2f(newZoom - [self zoom]);
  425 + [self zoomByFactor:factor near:pivot animated:animated];
  426 + }
  427 +}
  428 +
  429 +- (void)zoomOutToNextNativeZoomAt:(CGPoint) pivot {
  430 + [self zoomOutToNextNativeZoomAt: pivot animated: FALSE];
  431 +}
  432 +
  433 +
417 - (void) drawRect: (CGRect) aRect 434 - (void) drawRect: (CGRect) aRect
418 { 435 {
419 [renderer drawRect:aRect]; 436 [renderer drawRect:aRect];