VectorTileLayer plugin for folium
Project description
Folium-VectorTileLayer
VectorTileLayer plugin for Folium
Report Bug
·
Request Feature
Table of Contents
About The Project
Follow up on folium-vectorgrid that wraps Leaflet.VectorTileLayer to render Mapbox vector tiles in folium maps.
Other than Leaflet.VectorGrid, Leaflet.VectorTileLayer allows to "overzoom" and "underzoom". Even if the tiling provider only provides map tiles for zoom level 5 through 12, Leaflet.VectorTileLayer utilizes data from these upper and lower bounds to render tiles beyond zoom level 12 and 5 respectively.
Built With
Getting Started
Prerequisite
Install Poetry.
Installation
as dependency
poetry add git+https://github.com/iwpnd/folium-vectortilelayer.git
pip install folium-vectortilelayer
local development
- Clone and install
git clone https://github.com/iwpnd/folium-vectortilelayer.git poetry install
- Test it!
poe test # or poetry run pytest .
Usage
from folium_vectortilelayer import VectorTileLayer
import folium
url = "https://free.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token=my_token"
m = folium.Map()
options = {
"layers": ["my_layer"], # define layer to be shown
# min zoom of your map,
# if minZoom < minDetailZoom features in minDetailZoom level are used
# for minDetailZoom to minZoom
"minZoom": 8,
# max zoom of your map,
# if maxZoom > maxDetailZoom features in maxDetailZoom level are used
# for maxDetailZoom to maxZoom
"maxZoom": 18,
# min zoom level provided by source
"minDetailZoom": 10,
# max zoom level provided by source
"maxDetailZoom": 13,
"vectorTileLayerStyles": {
"my_layer":{
"fill": True,
"weight": 1,
"fillColor": 'green',
"color": 'black',
"fillOpacity":0.6,
"opacity":0.6
},
}
}
vc = VectorTileLayer(url, "folium_layer_name", options)
m.add_child(vc)
m
Or with conditional styling
import folium
from folium_vectortilelayer import VectorTileLayer
m = folium.Map()
url = "https://free.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token=my_token"
options = '''{
"layers": ["my_layer"],
"vectorTileLayerStyles": {
"my_layer": function(f) {
if (f.type === 'parks') {
return {
"fill": true,
"weight": 1,
"fillColor": 'green',
"color": 'black',
"fillOpacity":0.6,
"opacity":0.6
};
}
if (f.type === 'water') {
return {
"fill": true,
"weight": 1,
"fillColor": 'purple',
"color": 'black',
"fillOpacity":0.6,
"opacity":0.6
};
}
}
}
}'''
VectorTileLayer(url,"layer_name",options).add_to(m)
m
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Benjamin Ramser - @imwithpanda - ahoi@iwpnd.pw
Project Link: https://github.com/iwpnd/folium-vector
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file folium_vectortilelayer-0.2.4.tar.gz
.
File metadata
- Download URL: folium_vectortilelayer-0.2.4.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d9ceb4f399fa36ee193c168dc56e130fc77e374bd0a56fc3d2f8892cdf960ee |
|
MD5 | ad690aa84c9bf64889fc87e561473f16 |
|
BLAKE2b-256 | 8eb2a47b7f844601c241873620a9d265138d211b2255e387a1c32a9f4dfd70ea |
File details
Details for the file folium_vectortilelayer-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: folium_vectortilelayer-0.2.4-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33f177c44112ca5ebf0a5022488c528e86d5be1d04916ed09a321ec241cd8d4d |
|
MD5 | 369b02884263a17dd1f03bc85d9d87d0 |
|
BLAKE2b-256 | ca5fc22c9a65e9a7a872cd2224cfce1c7d319087543d5422c3b2a75d2ce58a53 |