panTo() fails when _mapPane position set to non 0 #5198

Open
ptasior opened this Issue Dec 16, 2016 · 2 comments

Projects

None yet

2 participants

@ptasior
ptasior commented Dec 16, 2016

Hi all,

I'm still on leaflet 0.7 but the code seems to be unchanged in 1.*
Browser: QWebkitWidget (Qt 5.3)
Other plugins: Leaflet.D3SvgOverlay (which I guess changes the position of _mapPane)

Issue:
When calling panTo(position) periodically with small distance changes the center of a map drifts from given coordinates.

Analysis:
In function _getCenterLayerPoint a call to this.containerPointToLayerPoint() substracts _getMapPanePos() from getSize()/2 while _getMapPanePos() apparently should be divided by 2 as well.

My solution:
In
_getCenterLayerPoint: function() {
Change return value to:
return L.point(this.getSize()._divideBy(2)).subtract(this._getMapPanePos()._divideBy(2));
Simply moving ._divideBy(2) outside containerPointToLayerPoint() reverts the direction of drift rather than fixing it...

Am I missing something or have I found a bug?

Thanks

@IvanSanchez
Member

Can you publish a fiddle/codepen/playground that displays this behaviour?

@ptasior
ptasior commented Dec 16, 2016

I'll try to but Monday or Tuesday is the earlies possible time for me.

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