Skip to main content

VectorGrid plugin for folium

Project description


Folium-VectorGrid

VectorGrid.protobuf plugin for Folium
Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact

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

  1. Clone and install
    git clone https://github.com/iwpnd/folium-vectorgrid.git
    poetry install
    
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

folium_vectorgrid_geojson-1.1.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

folium_vectorgrid_geojson-1.1.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file folium_vectorgrid_geojson-1.1.1.tar.gz.

File metadata

  • Download URL: folium_vectorgrid_geojson-1.1.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.4.0-136-generic

File hashes

Hashes for folium_vectorgrid_geojson-1.1.1.tar.gz
Algorithm Hash digest
SHA256 eaa631e790f3a1c50ffb7a2f56635e33f4d19168ff8023f1997925b540675c27
MD5 2e7bdc29cdb9b7d967c2b84e52e6cc5d
BLAKE2b-256 a2ba0fc54a6bc1e085e0767978fa12992a920b76f3e4011e8103bf574324ea27

See more details on using hashes here.

File details

Details for the file folium_vectorgrid_geojson-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for folium_vectorgrid_geojson-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64bf2bd355bec2394f08286132db0c8b20b77e70aa5b022a814e1889f4bc876a
MD5 1a7417ede60cc08353499a515f65f093
BLAKE2b-256 127ca0fd97a79185f4fbe59fe3e320a03ff65ea9bbf4af982490415ff4994d23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page