Authored by Kenny Grant

Added default zoom behaviour on double tap

... ... @@ -439,6 +439,7 @@
-(void) setScale: (float) scale
{
[mercatorToScreenProjection setScale:scale];
[overlay correctPositionOfAllSublayers];
[tileLoader updateLoadedImages];
[renderer setNeedsDisplay];
}
... ... @@ -447,9 +448,12 @@
{
return [mercatorToTileProjection calculateZoomFromScale:[mercatorToScreenProjection scale]];
}
-(void) setZoom: (float) zoom
{
float scale = [mercatorToTileProjection calculateScaleFromZoom:zoom];
//limit the zoom to maxZoom and minZoom as specified by projection - why do we also store maxZoom?
float normalisedZoom = [mercatorToTileProjection normaliseZoom:zoom];
float scale = [mercatorToTileProjection calculateScaleFromZoom:normalisedZoom];
[self setScale:scale];
}
... ...
... ... @@ -57,6 +57,7 @@ typedef struct {
- (void)zoomByFactor: (float) zoomFactor near:(CGPoint) aPoint;
- (CGPoint)latLongToPixel:(CLLocationCoordinate2D)latlong;
- (CLLocationCoordinate2D)pixelToLatLong:(CGPoint)aPixel;
- (void)zoomInToNextNativeZoom;
- (void)setZoom:(int)zoomInt;
- (void)zoomWithLatLngBoundsNorthEast:(CLLocationCoordinate2D)ne SouthWest:(CLLocationCoordinate2D)se;
- (void)setZoomBounds:(float)aMinZoom maxZoom:(float)aMaxZoom;
... ...
... ... @@ -305,10 +305,11 @@
if (delegateHasDoubleTapOnMap) {
[delegate doubleTapOnMap: self At: lastGesture.center];
} else {
// TODO: default behaviour
// [contents zoomInToNextNativeZoom];
// Default behaviour matches built in maps.app
[self zoomInToNextNativeZoom];
}
}
if (touch.tapCount == 1)
{
... ... @@ -364,6 +365,20 @@
return [contents pixelToLatLong:pixel];
}
#pragma mark Auto Zoom
- (void)zoomInToNextNativeZoom
{
// Calculate rounded zoom
float newZoom = roundf([contents zoom] + 1);
[contents setZoom:newZoom];// Contents limits zooms which are too high
}
#pragma mark Manual Zoom
- (void)setZoom:(int)zoomInt
{
... ...