Is there a difference between the actual zooming when using the setView and panTo methods in Leaflet?
map.setView([52, 13]);
map.panTo([52, 13]);
The zooming effect looks identical to me, or am I missing something? Are they the same unless you use the optional parameters?
Best Answer
There is no difference. In fact, have a look at Leaflet's source code for
panTo
:And
setView
:As you can see,
panTo()
just callssetView()
with the map's current zoom level, andsetView()
will also use the map's current zoom level if the second parameter isundefined
.