Added default zoom behaviour on double tap
Showing
3 changed files
with
23 additions
and
3 deletions
@@ -439,6 +439,7 @@ | @@ -439,6 +439,7 @@ | ||
439 | -(void) setScale: (float) scale | 439 | -(void) setScale: (float) scale |
440 | { | 440 | { |
441 | [mercatorToScreenProjection setScale:scale]; | 441 | [mercatorToScreenProjection setScale:scale]; |
442 | + [overlay correctPositionOfAllSublayers]; | ||
442 | [tileLoader updateLoadedImages]; | 443 | [tileLoader updateLoadedImages]; |
443 | [renderer setNeedsDisplay]; | 444 | [renderer setNeedsDisplay]; |
444 | } | 445 | } |
@@ -447,9 +448,12 @@ | @@ -447,9 +448,12 @@ | ||
447 | { | 448 | { |
448 | return [mercatorToTileProjection calculateZoomFromScale:[mercatorToScreenProjection scale]]; | 449 | return [mercatorToTileProjection calculateZoomFromScale:[mercatorToScreenProjection scale]]; |
449 | } | 450 | } |
451 | + | ||
450 | -(void) setZoom: (float) zoom | 452 | -(void) setZoom: (float) zoom |
451 | { | 453 | { |
452 | - float scale = [mercatorToTileProjection calculateScaleFromZoom:zoom]; | 454 | + //limit the zoom to maxZoom and minZoom as specified by projection - why do we also store maxZoom? |
455 | + float normalisedZoom = [mercatorToTileProjection normaliseZoom:zoom]; | ||
456 | + float scale = [mercatorToTileProjection calculateScaleFromZoom:normalisedZoom]; | ||
453 | [self setScale:scale]; | 457 | [self setScale:scale]; |
454 | } | 458 | } |
455 | 459 |
@@ -57,6 +57,7 @@ typedef struct { | @@ -57,6 +57,7 @@ typedef struct { | ||
57 | - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) aPoint; | 57 | - (void)zoomByFactor: (float) zoomFactor near:(CGPoint) aPoint; |
58 | - (CGPoint)latLongToPixel:(CLLocationCoordinate2D)latlong; | 58 | - (CGPoint)latLongToPixel:(CLLocationCoordinate2D)latlong; |
59 | - (CLLocationCoordinate2D)pixelToLatLong:(CGPoint)aPixel; | 59 | - (CLLocationCoordinate2D)pixelToLatLong:(CGPoint)aPixel; |
60 | +- (void)zoomInToNextNativeZoom; | ||
60 | - (void)setZoom:(int)zoomInt; | 61 | - (void)setZoom:(int)zoomInt; |
61 | - (void)zoomWithLatLngBoundsNorthEast:(CLLocationCoordinate2D)ne SouthWest:(CLLocationCoordinate2D)se; | 62 | - (void)zoomWithLatLngBoundsNorthEast:(CLLocationCoordinate2D)ne SouthWest:(CLLocationCoordinate2D)se; |
62 | - (void)setZoomBounds:(float)aMinZoom maxZoom:(float)aMaxZoom; | 63 | - (void)setZoomBounds:(float)aMinZoom maxZoom:(float)aMaxZoom; |
@@ -305,10 +305,11 @@ | @@ -305,10 +305,11 @@ | ||
305 | if (delegateHasDoubleTapOnMap) { | 305 | if (delegateHasDoubleTapOnMap) { |
306 | [delegate doubleTapOnMap: self At: lastGesture.center]; | 306 | [delegate doubleTapOnMap: self At: lastGesture.center]; |
307 | } else { | 307 | } else { |
308 | - // TODO: default behaviour | ||
309 | - // [contents zoomInToNextNativeZoom]; | 308 | + // Default behaviour matches built in maps.app |
309 | + [self zoomInToNextNativeZoom]; | ||
310 | } | 310 | } |
311 | } | 311 | } |
312 | + | ||
312 | 313 | ||
313 | if (touch.tapCount == 1) | 314 | if (touch.tapCount == 1) |
314 | { | 315 | { |
@@ -364,6 +365,20 @@ | @@ -364,6 +365,20 @@ | ||
364 | return [contents pixelToLatLong:pixel]; | 365 | return [contents pixelToLatLong:pixel]; |
365 | } | 366 | } |
366 | 367 | ||
368 | + | ||
369 | + | ||
370 | +#pragma mark Auto Zoom | ||
371 | + | ||
372 | + | ||
373 | +- (void)zoomInToNextNativeZoom | ||
374 | +{ | ||
375 | + | ||
376 | + // Calculate rounded zoom | ||
377 | + float newZoom = roundf([contents zoom] + 1); | ||
378 | + [contents setZoom:newZoom];// Contents limits zooms which are too high | ||
379 | +} | ||
380 | + | ||
381 | + | ||
367 | #pragma mark Manual Zoom | 382 | #pragma mark Manual Zoom |
368 | - (void)setZoom:(int)zoomInt | 383 | - (void)setZoom:(int)zoomInt |
369 | { | 384 | { |
-
Please register or login to post a comment