Authored by Joseph G

Fixed zooming so it zooms in on where you tap.

... ... @@ -106,6 +106,8 @@ enum {
- (void)moveBy: (CGSize) delta;
- (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center;
- (void)zoomInToNextNativeZoomAt:(CGPoint) pivot;
- (float)adjustZoomForBoundingMask:(float)zoomFactor;
- (void)adjustMapPlacementWithScale:(float)aScale;
- (void)setZoomBounds:(float)aMinZoom maxZoom:(float)aMaxZoom;
... ...
... ... @@ -281,6 +281,20 @@
}
}
- (void)zoomInToNextNativeZoomAt:(CGPoint) pivot
{
// Calculate rounded zoom
float newZoom = roundf([self zoom] + 1);
NSLog(@"zoom %f -> %f", [self zoom], newZoom);
if (newZoom >= [self maxZoom])
return;
else
{
float factor = exp2f(newZoom - [self zoom]);
[self zoomByFactor:factor near:pivot];
}
}
- (void) drawRect: (CGRect) aRect
{
[renderer drawRect:aRect];
... ...
... ... @@ -57,7 +57,7 @@ typedef struct {
- (void)zoomByFactor: (float) zoomFactor near:(CGPoint) aPoint;
- (CGPoint)latLongToPixel:(CLLocationCoordinate2D)latlong;
- (CLLocationCoordinate2D)pixelToLatLong:(CGPoint)aPixel;
- (void)zoomInToNextNativeZoom;
- (void)zoomInToNextNativeZoomAt:(CGPoint) pivot;
- (void)setZoom:(int)zoomInt;
- (void)zoomWithLatLngBoundsNorthEast:(CLLocationCoordinate2D)ne SouthWest:(CLLocationCoordinate2D)se;
- (void)setZoomBounds:(float)aMinZoom maxZoom:(float)aMaxZoom;
... ...
... ... @@ -288,12 +288,10 @@
}
}
// Calculate the gesture.
lastGesture = [self getGestureDetails:[event allTouches]];
// NSLog(@"touchesEnded %d ... lastgesture at %f, %f", [[event allTouches] count], lastGesture.center.x, lastGesture.center.y);
// NSLog(@"Assemble.");
// If there are no more fingers on the screen, resume any slow operations.
if (lastGesture.numTouches == 0)
{
[self unRegisterPausedDraggingDispatcher];
... ... @@ -303,13 +301,11 @@
if (touch.tapCount == 2)
{
// [contents printDebuggingInformation];
if (delegateHasDoubleTapOnMap) {
[delegate doubleTapOnMap: self At: lastGesture.center];
} else {
// Default behaviour matches built in maps.app
[self zoomInToNextNativeZoom];
[self zoomInToNextNativeZoomAt: [touch locationInView:self]];
}
}
... ... @@ -374,13 +370,9 @@
#pragma mark Auto Zoom
- (void)zoomInToNextNativeZoom
- (void)zoomInToNextNativeZoomAt: (CGPoint) point
{
// Calculate rounded zoom
float newZoom = roundf([contents zoom] + 1);
[contents setZoom:newZoom];// Contents limits zooms which are too high
[contents zoomInToNextNativeZoomAt:point];
}
... ...