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

Fix Marker position while zooming #7967

Merged
merged 2 commits into from
Feb 4, 2022

Conversation

Falke-Design
Copy link
Member

If a marker is set to a new latlng while zooming the marker jumps around. The problem is that the this._pixelOrigin (which is used for the calculation of the marker position) is only set after the zoom (_onZoomTransitionEnd), so while zooming the old pixelOrigin is used and the marker jumps.

I tried to create a test but it was not possible.

New src: link

marker_jumping_wrong

Fixed:
marker_jumping_fix

@@ -1697,6 +1700,12 @@ export var Map = Evented.extend({
noUpdate: noUpdate
});

if (!this._tempFireZoomEvent) {
this._tempFireZoomEvent = this._zoom !== this._animateToZoom;
Copy link
Member Author

Choose a reason for hiding this comment

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

we need to store if the zoom is different, to fire later the zoom event.

this._tempFireZoomEvent = this._zoom !== this._animateToZoom;
}

this._move(this._animateToCenter, this._animateToZoom, undefined, true);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the necessary call to set the _pixelOrigin but we need to prevent firing the zoom event (to keep the current behaviour)

Copy link
Member

@mourner mourner left a comment

Choose a reason for hiding this comment

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

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment