From 263929d9b86ea7b34d4ca29f54fae569d2b254dc Mon Sep 17 00:00:00 2001 From: Ihor Yakovenko Date: Wed, 5 Mar 2025 10:55:22 +0100 Subject: [PATCH] Restore mapTarget after zoom in --- Sources/Controllers/Map/OAMapViewController.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/Controllers/Map/OAMapViewController.mm b/Sources/Controllers/Map/OAMapViewController.mm index 829bf8fa3c..c6c51f4b26 100644 --- a/Sources/Controllers/Map/OAMapViewController.mm +++ b/Sources/Controllers/Map/OAMapViewController.mm @@ -234,6 +234,7 @@ @implementation OAMapViewController float _startZoom; BOOL _targetChanged; + BOOL _zoomInTargetChanged; OsmAnd::PointI _targetPixel; OsmAnd::PointI _carPlayScreenPoint; NSMutableArray *_moveTouchLocations; @@ -1011,9 +1012,10 @@ - (void) storeTargetPosition:(UIGestureRecognizer *)recognizer - (void) restorePreviousTarget { - if ([self isTargetChanged] && [self isLastMultiGesture]) + if ([self isTargetChanged] && ([self isLastMultiGesture] || _zoomInTargetChanged)) { _targetChanged = NO; + _zoomInTargetChanged = NO; // Restore previous target screen position after map gesture [_mapView resetMapTargetPixelCoordinates:_targetPixel]; @@ -1480,6 +1482,9 @@ - (void) zoomInGestureDetected:(UITapGestureRecognizer *)recognizer // Get base zoom delta float zoomDelta = [self currentZoomInDelta]; + _zoomInTargetChanged = YES; + [self storeTargetPosition:recognizer]; + // X/Y axis animation const CGPoint touchPoint = [self getTouchPoint:recognizer touchIndex:0]; const OATouchLocation *touchLocation = [self acquireMapTouchLocation:touchPoint]; @@ -1834,6 +1839,8 @@ - (void) changeZoomManually:(int)zoomStep adjustTiltAngle:(BOOL)adjustTiltAngle { if (!self.mapViewLoaded) return; + + [self restorePreviousTarget]; OAZoom *zoom = [[OAZoom alloc] initWitZoom:_mapView.zoom minZoom:_mapView.minZoom maxZoom:_mapView.maxZoom]; int previousZoom = [zoom getBaseZoom];