Request Adding Leaflet.TileLayer.MBTiles Plugin Support
Dieses Issue hat noch niemand übernommen.
- #1341 von @and-viceversa — ohne Merge geschlossen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, python
- Bereich
- data-visualization, frontend
Rechercherichtung
Beginne damit, die bestehende Plugin-Struktur von Folium und das im Issue gezeigte Überschreiben von TileLayer._template zu prüfen, und vergleiche anschließend den geschlossenen Pull Request 1341. Die Arbeit ist abgeschlossen, wenn Leaflet.TileLayer.MBTiles als Folium-Plugin verwendet werden kann, ohne TileLayer._template manuell zu überschreiben, und der clientseitige Code über einen funktionierenden CDN-Link verfügbar ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 7.4k
- Forks
- 2.3k
- Ø Merge
- 17 Std. 22 Min.
- Gemergte PRs (30 T.)
- 11
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-visualization/folium
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python-visualization/folium#2092 · 5 Kommentare ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 67/100
python-visualization/folium#2278 · 1 Kommentar ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
python-visualization/folium#2259 ·
-
Map output from OSM returns blocked tiles, due to defective request or not following referer-policy Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
python-visualization/folium#2236 · 5 Kommentare · 1 Reaktion ·
-
Touch Screen often fails Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 10/100
python-visualization/folium#2219 · 2 Kommentare ·
Alle Issues in python-visualization/folium
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
huggingface/Repo2RLEnv#163 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
NousResearch/hermes-agent#121143 ·