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

ptasior opened this Issue Dec 16, 2016 · 2 comments


None yet

2 participants

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)

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

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:
_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?



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

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