Let's try to center and zoom a map on the greenwich observatory ...
map.setZoom(0); map.panTo(0,0);
(start at a known coord/zoom level)map.panTo([51.4768, 0.0006])
to center map at greenwich observatory (in theory)map.setZoom(16)
to zoom inThis is confirmed by map.getCenter().toString()
=> LatLng(51.61802, 0)
Duplicate of #426. panTo
works correctly, the problem is that it pans it on zoom 0 with rounding to pixels, and then you zoom by 16 zoom levels. So it's a rounding problem.
Sorry, for commenting here, but this seems like a very accurate description of what I'm seeing.
I've made this jsbin: https://jsbin.com/putezoyido/edit?js,console,output
When you click "Go to new location" we call
map.panTo([41.142937, -8.534538]);
however, moveend
is triggered and if we check the map's center there we get
41.14293584388727
-8.534536957740785
Is this something expected or a bug?
So what's the solution? :S I'm trying to pan but it pans me nowhere near the coordinates I'm giving it.. Been trying to find a solution for the last hour but none of them works. Why can't the panTo just work like it's supposed to?
Hi @chrillewoodz, great to hear that you find Leaflet useful!
Instead of commenting an old and closed ticket, and if you are _really_ sure that this is a bug in Leaflet, please open a new issue.
Please provide an effective bug report, and in particular all the information requested in the issue template (provided when you create a new issue), so that we can effectively investigate.
Most helpful comment
Sorry, for commenting here, but this seems like a very accurate description of what I'm seeing.
I've made this jsbin: https://jsbin.com/putezoyido/edit?js,console,output
When you click "Go to new location" we call
however,
moveend
is triggered and if we check the map's center there we getIs this something expected or a bug?