python-visualization / folium

Python Data. Leaflet.js Maps.
https://python-visualization.github.io/folium/
MIT License
6.93k stars 2.23k forks source link

repair max_zoom and max_native_zoom #1952

Closed Conengmo closed 6 months ago

Conengmo commented 6 months ago

Fix https://github.com/python-visualization/folium/issues/1859

When we introduced xyzservices, we changed the way we handle the max_zoom and max_native_zoom arguments of TileLayer (and Map). In this PR, restore how it worked before that change, but keep using the values from xyzservices.

To do that, make min_zoom and max_zoom optional arguments with default values None. That way, when a user doesn't provide them, we can use the value from xyzservices.

When a user does provide explicit values for e.g. max_zoom, honor that value and don't overwrite it from xyzservices. This allows zooming past the highest native zoom level.

Fill the max_native_zoom option from xyzservices, unless a user provides an explicit value.

I opted to keep the defaults of 0 and 18, because those are the defaults set by Leaflet as well. This way, we make them explicit to our users.

Conengmo commented 6 months ago

Thanks for the review Hans!