You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid Zoom for TileLayer in version 0.19.0 #2043
I'm using a tiling endpoint based of TiTiler to serve map tiles on Folium. Since the upgrade last night, the tiles no longer render, and my tiling endpoint gives me this error: "Invalid ZOOM level 0", and the tile request is showing as "tiles/WebMercatorQuad/0/0/0"
geom = shape(AOI)
centroid = geom.centroid
m = folium.Map(location=[centroid.y, centroid.x], zoom_start=12)
# Initialize Tile Layer and add to map
TileLayer(
tiles=tilejson["tiles"][0],
opacity=1,
min_zoom=8,
max_zoom=14,
attr="Sentinel-2 COG",
).add_to(m)
folium.GeoJson(AOI).add_to(m)
m
Typically, the folium map generates tile at whatever x, y, z are visible on the map. Only this single 0,0,0 tile is being requested.
Environment is in a Databricks notebook with Folium 0.19.0
I have got a similar issue, the following is the reproducible codes that people can test on folium 0.18.0 and 0.19.0.
importfolium# Esri_WorldTopoMaparcgis='https://server.arcgisonline.com/ArcGIS/rest/services'esri= {'Esri_WorldTopoMap': 'World_Topo_Map'}
tile='MapServer/tile/{z}/{y}/{x}'tile_esri=dict(zip(esri.keys(), ['/'.join([arcgis, v, tile]) forvinesri.values()]))
# GOOGLE online maptile_google= {
'Maps': 'https://mt1.google.com/vt/lyrs=r&x={x}&y={y}&z={z}',
'Satellite': 'http://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}',
'Roads': 'https://mt1.google.com/vt/lyrs=h&x={x}&y={y}&z={z}',
}
m=folium.Map(
location=(-45.54, 169.74),
tiles=None,
zoom_start=9,
zoom_control=False,
attributionControl=False,
)
# Add 'Esri_WorldTopoMap' as 'Esri_WorldTopoMap'folium.raster_layers.TileLayer(
tiles=tile_esri['Esri_WorldTopoMap'],
attr='Esri_WorldTopoMap',
name='World Topographic Map (ESRI)',
overlay=False, # As an optional overlay (True) or the base layer (False)control=True, # Whether the Layer will be included in LayerControlsshow=True,
).add_to(m)
# Add Google Mapsfolium.raster_layers.TileLayer(
tiles='http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
attr='Google',
name='Google Maps',
subdomains=['mt0', 'mt1', 'mt2', 'mt3'],
overlay=False,
control=True,
show=False,
).add_to(m)
# Add Google Satellitefolium.raster_layers.TileLayer(
tiles='http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',
attr='Google',
name='Google Satellite',
subdomains=['mt0', 'mt1', 'mt2', 'mt3'],
overlay=False,
control=True,
show=False,
).add_to(m)
# Add Google Roads layer (optional)folium.raster_layers.TileLayer(
tiles=tile_google['Roads'],
attr='Google',
name='Google Roads',
overlay=True,
control=True,
show=False,
).add_to(m)
folium.LayerControl(position='bottomright', collapsed=False).add_to(m)
m
The folium map can be shown properly in jupyter notebook when using 0.18.0. However, you will have a map with some possible render issue when using 0.19.0
Thanks @lux-orc for the reproducible example, very useful. The issue seems to be with the maxNativeZoom parameter which is set to null. This is likely caused by #2029.
Before we used a parse_options function, which discarded option values that were None. This check isn't applied in the new to_javascript filter. I'll make a PR with a possible fix.
Thanks @lux-orc for the reproducible example, very useful. The issue seems to be with the maxNativeZoom parameter which is set to null. This is likely caused by #2029.
Before we used a parse_options function, which discarded option values that were None. This check isn't applied in the new to_javascript filter. I'll make a PR with a possible fix.
Thank you for working on this @Conengmo. Looking forward to having the fix :)
Activity
lux-orc commentedon Dec 10, 2024
I have got a similar issue, the following is the reproducible codes that people can test on folium 0.18.0 and 0.19.0.
The folium map can be shown properly in jupyter notebook when using 0.18.0. However, you will have a map with some possible render issue when using 0.19.0
Hopefully, the issue is clearly illustrated.
hansthen commentedon Dec 11, 2024
I will have a look one of these days to see what can be the issue.
Conengmo commentedon Dec 11, 2024
Thanks @lux-orc for the reproducible example, very useful. The issue seems to be with the
maxNativeZoomparameter which is set to null. This is likely caused by #2029.Before we used a
parse_optionsfunction, which discarded option values that were None. This check isn't applied in the newto_javascriptfilter. I'll make a PR with a possible fix.lux-orc commentedon Dec 11, 2024
Thank you for working on this @Conengmo. Looking forward to having the fix :)
Conengmo commentedon Dec 12, 2024
Just released v0.19.1 with a fix for this issue, hopefully that solves it for you. Thanks again for the bug report!
lux-orc commentedon Dec 12, 2024
I just installed Folium 0.19.1 using
pip—it works! Thank you so much for your time on this quick fix!