Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max zoom level no longer working from 0.14.0 to 0.15.1 (defaults to 18) #1859

Closed
Stephaneke opened this issue Jan 9, 2024 · 7 comments · Fixed by #1952
Closed

Max zoom level no longer working from 0.14.0 to 0.15.1 (defaults to 18) #1859

Stephaneke opened this issue Jan 9, 2024 · 7 comments · Fixed by #1952
Labels
bug An issue describing unexpected or malicious behaviour

Comments

@Stephaneke
Copy link

Describe the bug
Since the update from 0.14.0 to 0.15.1, the max zoom level function does no longer work and defaults to 18?

To Reproduce

[ Include a code snippet that produces your bug. Make it standalone, we should be able to run it. ]

import folium
m = folium.Map(location=[51.505492, -0.075408], zoom_start=12, max_zoom=25)
# add a circle marker of 5 radius at scale at the center of the map
folium.CircleMarker(location=[51.505492, -0.075408], radius=5, color='#3186cc', fill=True, fill_color='#3186cc').add_to(m)
m.save('interactive_map_0.14.0.html')

[ Include a data sample or link to your data if necessary to run the code ]

Expected behavior
I expect the maximum zoom level to be 25 instead of 18

Environment (please complete the following information):

maps.zip

Possible solutions
List any solutions you may have come up with.

folium is maintained by volunteers. Can you help making a fix for this issue?

@Conengmo Conengmo added the bug An issue describing unexpected or malicious behaviour label Jan 21, 2024
@Conengmo
Copy link
Member

Can confirm. In the TileLayer class we now default to the max_zoom that's defined in the xyzservices.TileProvider object if available.

Also note how this works in tandem with max_native_zoom.

We should fix this and improve documentation.

@Stephaneke
Copy link
Author

So there is still a possibility to increase the zoom level? Or is it disabled in the newest updates? If you are working on a small scale (e.g. meters), this is almost a necessity.

@hansthen
Copy link
Collaborator

hansthen commented May 8, 2024

@Stephaneke The maximum zoom is defined by the tile provider. You can play around with different tile layers to see how that affects the max zoom level. E.g. folium.TileLayer('CartoDB Positron').add_to(m) gives me a maximum zoom level of 20. OpenStreetMap (the default) goes to 19.

Our documentation is off as the max_zoom and max_native_zoom parameters seem to be ignored.

@hansthen
Copy link
Collaborator

hansthen commented May 8, 2024

@Stephaneke I did a quick experiment with a different provider. This one goes to level 22, which is the best I could find. It does require an api key. Parts in angle brackets need to be replaced.

See https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js for other providers.

folium.TileLayer(
     'https://tile.jawg.io/<variant, e.g. jawg-dark>/{z}/{x}/{y}{r}.png?access-token=<get your own>',
      attr="<attribution>",
      max_zoom=22,
      max_native_zoom=22,
  ).add_to(m)

@Conengmo
Copy link
Member

Conengmo commented May 8, 2024

This probably broke when we adopted xyzservices. This probably needs more than just a documentation change. Ideally we restore the previous behavior as described in the rasterlayer docstring. But now the ‘max_native_zoom’ value comes from xyzservices? And ‘max_zoom’ allows further zooming? Something like that.

@hansthen
Copy link
Collaborator

hansthen commented May 8, 2024

I did a few tests. max_zoom on Map does not seem to be honored at all and leaflet seems to be taking the max zoom level from the tile layers. max_native_zoom on TileLayer seems to do nothing (probably because it comes from xyzservice). max_zoom on TileLayer does seem to limit how far you can zoom in for that TileLayer. Leaflet will fall back to the default TileLayer if you zoom in beyond that.

My feeling is that max_zoom on Map should just limit how far one can zoom if it is less than the maximum zoom level of the associated layers. Perhaps we can give a warning if the user sets a too high max_zoom level?

@Conengmo
Copy link
Member

I made a PR to bring back the behavior we had before, while keeping the values we get from xyzservices: #1952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing unexpected or malicious behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants