Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore mapTarget after zoom in #4410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Sources/Controllers/Map/OAMapViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ @implementation OAMapViewController
float _startZoom;

BOOL _targetChanged;
BOOL _zoomInTargetChanged;
OsmAnd::PointI _targetPixel;
OsmAnd::PointI _carPlayScreenPoint;
NSMutableArray<OATouchLocation *> *_moveTouchLocations;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -1480,6 +1482,9 @@ - (void) zoomInGestureDetected:(UITapGestureRecognizer *)recognizer
// Get base zoom delta
float zoomDelta = [self currentZoomInDelta];

_zoomInTargetChanged = YES;
[self storeTargetPosition:recognizer];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems storeTargetPosition / restorePreviousTarget should be called in zoomInGestureDetected method depending on recognizer.state, like in moveGestureDetected (UIGestureRecognizerStateBegan / UIGestureRecognizerStateEnded / UIGestureRecognizerStateCancelled)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good, but I tested it, and it is not true in this case. moveGestureDetected is called when we touch and remove our finger from the screen and has different states. zoomInGestureDetected is called only once if we double-click and has the UIGestureRecognizerStateChanged state.


// X/Y axis animation
const CGPoint touchPoint = [self getTouchPoint:recognizer touchIndex:0];
const OATouchLocation *touchLocation = [self acquireMapTouchLocation:touchPoint];
Expand Down Expand Up @@ -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];
Expand Down