Add vector tile layers based on https://github.com/Leaflet/Leaflet.VectorGrid. Parameters ---------- url: str url to tile provider e.g. https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token={token} name: str, optional Name of the layer that will
| 6 | |
| 7 | |
| 8 | class VectorGridProtobuf(JSCSSMixin, Layer): |
| 9 | """ |
| 10 | Add vector tile layers based on https://github.com/Leaflet/Leaflet.VectorGrid. |
| 11 | |
| 12 | Parameters |
| 13 | ---------- |
| 14 | url: str |
| 15 | url to tile provider |
| 16 | e.g. https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token={token} |
| 17 | name: str, optional |
| 18 | Name of the layer that will be displayed in LayerControl |
| 19 | options: dict or str, optional |
| 20 | VectorGrid.protobuf options, which you can pass as python dictionary or string. |
| 21 | Strings allow plain JavaScript to be passed, therefore allow for conditional styling (see examples). |
| 22 | |
| 23 | Additionally the url might contain any string literals like {token}, or {key} |
| 24 | that can be passed as attribute to the options dict and will be substituted. |
| 25 | |
| 26 | Every layer inside the tile layer has to be styled separately. |
| 27 | overlay : bool, default True |
| 28 | Whether your layer will be an overlay (ticked with a check box in |
| 29 | LayerControls) or a base layer (ticked with a radio button). |
| 30 | control: bool, default True |
| 31 | Whether the layer will be included in LayerControls. |
| 32 | show: bool, default True |
| 33 | Whether the layer will be shown on opening. |
| 34 | |
| 35 | Examples |
| 36 | -------- |
| 37 | |
| 38 | Options as dict: |
| 39 | |
| 40 | >>> m = folium.Map() |
| 41 | >>> url = "https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token={token}" |
| 42 | >>> options = { |
| 43 | ... "subdomain": "tilehosting", |
| 44 | ... "token": "af6P2G9dztAt1F75x7KYt0Hx2DJR052G", |
| 45 | ... "vectorTileLayerStyles": { |
| 46 | ... "layer_name_one": { |
| 47 | ... "fill": True, |
| 48 | ... "weight": 1, |
| 49 | ... "fillColor": "green", |
| 50 | ... "color": "black", |
| 51 | ... "fillOpacity": 0.6, |
| 52 | ... "opacity": 0.6, |
| 53 | ... }, |
| 54 | ... "layer_name_two": { |
| 55 | ... "fill": True, |
| 56 | ... "weight": 1, |
| 57 | ... "fillColor": "red", |
| 58 | ... "color": "black", |
| 59 | ... "fillOpacity": 0.6, |
| 60 | ... "opacity": 0.6, |
| 61 | ... }, |
| 62 | ... }, |
| 63 | ... } |
| 64 | |
| 65 | >>> VectorGridProtobuf(url, "layer_name", options).add_to(m) |
searching dependent graphs…