-
Is it possible to visualize PMTiles using folium or ipyleaflet? I saw the JavaScript example for visualizing PMTiles. It would be great to have some Python examples. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 13 replies
-
My understanding is that Folium and ipyleaflet both execute JavaScript in a browser environment (Leaflet), so the existing javascript client integration for Leaflet should work by writing a plugin: Folium plugins I don't think a python implementation is necessary beyond glue to call existing javascript libraries. |
Beta Was this translation helpful? Give feedback.
-
ipyleaflet can visualize vector tiles in mvt format, so it seems we need to serve PMTiles as mvt so that it can be used by ipyleaflet. pmtiles serve .
# serves at http://localhost:8077/FILENAME/{z}/{x}/{y}.mvt |
Beta Was this translation helpful? Give feedback.
-
Wanted to share that I created a folium plugin for pmtiles a while back that might be useful. https://github.com/jtmiclat/folium-pmtiles I did find it a bit challenging styling pmtiles without using maplibre as that would involve a lot of javascript code Here is a simple demo on it working https://github.dev/jtmiclat/folium-pmtiles/blob/master/example/pmtiles_vector_maplibre.ipynb |
Beta Was this translation helpful? Give feedback.
-
@jtmiclat Thank you for sharing the plugin. That's what I was looking for. I am interested in overlaying PMTiles on other data layers. How to turn off the gray background of the PMTiles layer? import folium
from folium_pmtiles.vector import PMTilesVectorBaseMap
m = folium.Map(location=[43.7798, 11.24148], zoom_start=12)
pmtiles_layer = PMTilesVectorBaseMap(
"https://pmtiles.jtmiclat.me/protomaps(vector)ODbL_firenze.pmtiles",
"PMtiles",
options={
"attribution": """<a href="https://protomaps.com">Protomaps</a> © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>'"""
},
overlay=True,
)
m.add_child(pmtiles_layer)
folium.LayerControl().add_to(m)
m |
Beta Was this translation helpful? Give feedback.
-
Is it possible to render PMTiles stored locally? I use import folium
from folium_pmtiles.vector import PMTilesVectorBaseMap
m = folium.Map(location=[43.7798, 11.24148], zoom_start=12)
pmtiles_layer = PMTilesVectorBaseMap(
"http://localhost:8000/protomaps%28vector%29ODbL_firenze.pmtiles",
"PMtiles",
options={
"attribution": """<a href="https://protomaps.com">Protomaps</a> © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>'"""
},
overlay=True,
)
m.add_child(pmtiles_layer)
folium.LayerControl().add_to(m)
m |
Beta Was this translation helpful? Give feedback.
Wanted to share that I created a folium plugin for pmtiles a while back that might be useful.
https://github.com/jtmiclat/folium-pmtiles
I did find it a bit challenging styling pmtiles without using maplibre as that would involve a lot of javascript code
Here is a simple demo on it working https://github.dev/jtmiclat/folium-pmtiles/blob/master/example/pmtiles_vector_maplibre.ipynb