folium: Vector tile does not render when zoom level greater than 14
Describe the bug The vector tile layer does not render when zoom level is great than 14. @iwpnd
To Reproduce https://nbviewer.org/github/python-visualization/folium/blob/main/examples/plugin-vector-tiles.ipynb
import folium
from folium.plugins import VectorGridProtobuf
url = "https://vectortiles3.geo.admin.ch/tiles/ch.swisstopo.leichte-basiskarte.vt/v1.0.0/{z}/{x}/{y}.pbf"
m = folium.Map(location=[46.8, 8.2], zoom_start=14)
options = {'maxNativeZoom': 20, 'maxZoom': 20}
# options = {'max_native_zoom': 20, 'max_zoom': 20} #not working either
vc = VectorGridProtobuf(url, "vector tile", options)
m.add_child(vc)
m
Expected behavior The vector tile layer should render in a zoom level much larger than 14 so that we can see the details of vector data.
Environment (please complete the following information):
- Python version: 3.9
- folium version: 0.13.0
Possible solutions
The leaflet VectorGrid.Protobuf
example appears to have the maxNativeZoom
parameter. I am not sure if the folium plugin can pass the maxNativeZoom
and maxZoom
parameters to VectorGrid.Protobuf
.
https://leaflet.github.io/Leaflet.VectorGrid/vectorgrid-api-docs.html
L.vectorGrid.protobuf("https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf.pict?key={key}", {
vectorTileLayerStyles: { ... },
subdomains: "0123",
key: 'abcdefghi01234567890',
maxNativeZoom: 14
}).addTo(map);
Relevant issues https://github.com/microsoft/PlanetaryComputer/discussions/175 @TomAugspurger
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 22 (20 by maintainers)
https://pypi.org/project/folium-vectortilelayer/
for whoever is interested.
thank you @jkuebart for the plugin and your input here 🙏
I didn’t follow this discussion too closely as I don’t know about
folium
, but there shouldn’t be much »trial and error« involved in setting the zoom parameters.If the server serves tiles for the full range of
max/minZoom
levels, there’s really no reason to use any of the other options. If the server lacks some zoom levels,Leaflet.VectorTileLayer
offers two possible solutions:max/minNativeZoom
, the tiles on zoom levels outside the given range are loaded from the specified zoom level and scaled up or down including line widths and marker sizes. The result looks the same as it would with raster tiles without the obvious artifacts.max/minDetailZoom
, the tiles on zoom levels outside the given range are loaded from the specified zoom level and drawn larger or smaller while keeping the same line widths and marker sizes. The result looks as if the tile with the target zoom level was available, but obviously the amount of detail remains the same.max/minZoom
andmax/minNativeZoom
work as documented forL.GridLayer
, to quote:maxZoom
The maximum zoom level up to which this layer will be displayed (inclusive).minZoom
The minimum zoom level down to which this layer will be displayed (inclusive).maxNativeZoom
Maximum zoom number the tile source has available. If it is specified, the tiles on all zoom levels higher thanmaxNativeZoom
will be loaded frommaxNativeZoom
level and auto-scaled.minNativeZoom
Minimum zoom number the tile source has available. If it is specified, the tiles on all zoom levels lower thanminNativeZoom
will be loaded fromminNativeZoom
level and auto-scaled.Leaflet.VectorTileLayer
addsmax/minDetailZoom
which is documented here.