Request Adding Leaflet.TileLayer.MBTiles Plugin Support
Nessuno ha ancora preso questa issue.
- #1341 di @and-viceversa — chiusa senza merge
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, python
- Ambito
- data-visualization, frontend
Direzione di ricerca
Inizia esaminando la struttura dei plugin esistente di Folium e l’override di TileLayer._template mostrato nell’issue, quindi confronta la pull request chiusa 1341. Il lavoro è completato quando Leaflet.TileLayer.MBTiles può essere utilizzato come plugin Folium senza eseguire manualmente l’override di TileLayer._template e il relativo codice lato client è disponibile tramite un link CDN funzionante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is your feature request related to a problem? Please describe.
No. This feature request adds support for displaying raster tile base maps in .mbtiles format.
Describe the solution you'd like
- Make Leaflet.TileLayer.MBTiles it's own Folium plugin.
- Put the above plugin on a CDN so users aren't forced to store it locally. The original author's CDN link is broken I think.
Currently, you can use Folium and Leaflet.TileLayer.MBTiles to display .mbtiles format, but it's a bit hacky.
I used roughly the following snippet to override TileLayer._template
# override defaults to use the plugin
folium.raster_layers.TileLayer._template = Template(u"""
{% macro script(this, kwargs) %}
var {{ this.get_name() }} = L.tileLayer.mbTiles( <--------
{{ this.tiles|tojson }},
{{ this.options|tojson }}
).addTo({{ this._parent.get_name() }});
{% endmacro %}
""")
# make a Map with .mbtile basemap
m = folium.Map(
location=[35.650787, -117.661728],
tiles='my_tiles.mbtiles',
attr=attr
)
# add open street map
layer = folium.TileLayer(
tiles='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
name='OpenStreetMap Online',
attr='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> '
'contributors',
overlay=True,
control=True,
show=False
).add_to(m)
# function to return _template back to default after the fact.
set_tile_layer_default(layer)
Even then, you have to override TileLayer._template back to it's default before m.save('index.html') for each additional (non-mbtiles) basemap you add.
It would be really nice to:
from folium.plugins import MBTiles
m = MBTiles.Map(
location = [14.0, 15.0],
tiles = 'your_tiles_url.mbtiles',
attr = 'attr text'
)
Describe alternatives you've considered
The only alternative I can see is something like the above snippet. There was some discussion in #351.
Additional context
For those unfamiliar, one open source way to make your own tiles is by using TileMill. TileMill exports the usual {z}{x}{y} directory structure, as well as the Mapbox raster .mbtiles format. Mbtiles are preferable in some cases, because you only have to manage 1 file instead of (no joke) millions of .png files.
Also, it's great when one open source project ties cleanly into another.
Implementation
folium is maintained by volunteers. Can you help make a PR if we want to implement this feature?
I would be happy to write this PR. I have working code which accomplishes the task, just not sure how to best turn it into a plugin.
If somebody could please comment:
- Is this idea acceptable and feasible?
- A general best practices and implementation list.
Thanks.
- Lingua principale
- Python
- Stelle
- 7.4k
- Fork
- 2.3k
- Merge medio
- 17h 22m
- PR unite (30g)
- 11
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-visualization/folium
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
python-visualization/folium#2092 · 5 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 67/100
python-visualization/folium#2278 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
python-visualization/folium#2259 ·
-
Map output from OSM returns blocked tiles, due to defective request or not following referer-policy Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
python-visualization/folium#2236 · 5 commenti · 1 reazione ·
-
Touch Screen often fails Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
python-visualization/folium#2219 · 2 commenti ·
Tutte le issue di python-visualization/folium
Issue simili
-
essnmx good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
-
[Feature] 奇物选择添加优先级 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Giskard-AI/giskard-oss#2840 · 1 commento ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Apertaarea: repo bug perceived difficulty: 2
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
yeti-platform/yeti#1380 ·