Authored by Justin R. Miller

adjust map min zoom scale properly based on boundingMask

@@ -68,6 +68,8 @@ @@ -68,6 +68,8 @@
68 - (void)correctPositionOfAllAnnotations; 68 - (void)correctPositionOfAllAnnotations;
69 - (void)correctPositionOfAllAnnotationsIncludingInvisibles:(BOOL)correctAllLayers wasZoom:(BOOL)wasZoom; 69 - (void)correctPositionOfAllAnnotationsIncludingInvisibles:(BOOL)correctAllLayers wasZoom:(BOOL)wasZoom;
70 70
  71 +- (void)correctMinZoomScaleForBoundingMask;
  72 +
71 @end 73 @end
72 74
73 #pragma mark - 75 #pragma mark -
@@ -535,6 +537,28 @@ @@ -535,6 +537,28 @@
535 #pragma mark - 537 #pragma mark -
536 #pragma mark Zoom 538 #pragma mark Zoom
537 539
  540 +- (void)setBoundingMask:(NSUInteger)mask
  541 +{
  542 + boundingMask = mask;
  543 +
  544 + [self correctMinZoomScaleForBoundingMask];
  545 +}
  546 +
  547 +- (void)correctMinZoomScaleForBoundingMask
  548 +{
  549 + if (self.boundingMask != RMMapNoMinBound)
  550 + {
  551 + CGFloat newMinZoomScale = (self.boundingMask == RMMapMinWidthBound ? self.bounds.size.width : self.bounds.size.height) / ((CATiledLayer *)tiledLayerView.layer).tileSize.width;
  552 +
  553 + if (mapScrollView.minimumZoomScale > 0 && newMinZoomScale > mapScrollView.minimumZoomScale)
  554 + {
  555 + RMLog(@"clamping min zoom of %f to %f due to %@", log2f(mapScrollView.minimumZoomScale), log2f(newMinZoomScale), (self.boundingMask == RMMapMinWidthBound ? @"RMMapMinWidthBound" : @"RMMapMinHeightBound"));
  556 +
  557 + mapScrollView.minimumZoomScale = newMinZoomScale;
  558 + }
  559 + }
  560 +}
  561 +
538 - (RMProjectedRect)projectedBounds 562 - (RMProjectedRect)projectedBounds
539 { 563 {
540 CGPoint bottomLeft = CGPointMake(mapScrollView.contentOffset.x, mapScrollView.contentSize.height - (mapScrollView.contentOffset.y + mapScrollView.bounds.size.height)); 564 CGPoint bottomLeft = CGPointMake(mapScrollView.contentOffset.x, mapScrollView.contentSize.height - (mapScrollView.contentOffset.y + mapScrollView.bounds.size.height));
@@ -1277,6 +1301,8 @@ @@ -1277,6 +1301,8 @@
1277 // RMLog(@"New minZoom:%f", newMinZoom); 1301 // RMLog(@"New minZoom:%f", newMinZoom);
1278 1302
1279 mapScrollView.minimumZoomScale = exp2f(newMinZoom); 1303 mapScrollView.minimumZoomScale = exp2f(newMinZoom);
  1304 +
  1305 + [self correctMinZoomScaleForBoundingMask];
1280 } 1306 }
1281 1307
1282 - (void)setMaxZoom:(float)newMaxZoom 1308 - (void)setMaxZoom:(float)newMaxZoom