VectorGrid plugin for folium
Project description
Folium-VectorGrid
VectorGrid.protobuf plugin for Folium
Report Bug
·
Request Feature
Table of Contents
About The Project
Now part of folium plugins as of v0.13.0.
This library fills a hole in foliums plugin eco-system. Wrapping Leaflet.VectorGrid into a folium plugin, users can now add vector tile layers (e.g. Mapbox, OpenMapTiles) to their folium maps.
Built With
Getting Started
Prerequisite
Install Poetry.
Installation
as dependency
poetry add git+https://github.com/iwpnd/folium-vectorgrid.git
pip install folium-vectorgrid
local development
- Clone and install
git clone https://github.com/iwpnd/folium-vectorgrid.git poetry install
- Test it!
poe test # or poetry run pytest .
Usage
from folium_vectorgrid import VectorGridProtobuf
import folium
url = "https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token={token}"
m = folium.Map()
options = {
"subdomain": "my_subdomain",
"token": "my_token",
"vectorTileLayerStyles": {
"my_layer":{
"fill": True,
"weight": 1,
"fillColor": 'green',
"color": 'black',
"fillOpacity":0.6,
"opacity":0.6
},
}
}
vc = VectorGridProtobuf(url, "folium_layer_name", options)
m.add_child(vc)
m
Or with conditional styling
import folium
from folium_vectorgrid import VectorGridProtobuf
m = folium.Map()
url = "https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token={token}"
options = '''{
"subdomain": "tilehosting",
"token": "af6P2G9dztAt1F75x7KYt0Hx2DJR052G",
"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
};
}
}
}
}'''
VectorGridProtobuf(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
Release history Release notifications | RSS feed
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
Close
Hashes for folium_vectorgrid-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8598a287df152f15ec8f81679155fb108106e09e25b34734c0a40f7b91e3ff6d |
|
MD5 | 468204337ba09eed51057861be1a9e52 |
|
BLAKE2b-256 | 09855ee00f2f2dcb39d9a4d698c028e7d70deeede0dd172b60cae857cd3f9113 |