geohierarchy.maps.folium.legend¶
Zoom-aware legend rendering: one small fixed-position box per configured layer.
Only the legend belonging to whichever level's zoom range contains the
current map zoom is shown, mirroring the vector-tile visibility rule (each
level's tiles only render within their own [minZoom, maxZoom]).
HierarchyLegend(entries, position='bottom-right')
¶
Bases: MacroElement
A branca MacroElement rendering one fixed-position legend box per level.
Each box is toggled via a map.on('zoomend', ...) listener so only
the box whose level's [min_zoom, max_zoom] contains the current
zoom is visible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entries
|
List[Tuple[str, str, Tuple[int, int]]]
|
List of |
required |
position
|
str
|
CSS corner: "bottom-right", "bottom-left", "top-right", or "top-left". |
'bottom-right'
|
build_legend(layers, resolutions, gdfs=None)
¶
Build a :class:HierarchyLegend from a mapping of level name -> MapLayer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
Dict[str, 'object']
|
Mapping of level name to :class: |
required |
resolutions
|
Dict[str, Tuple[int, int]]
|
Zoom-range assignment per level, from :func: |
required |
gdfs
|
Optional[Dict]
|
Optional mapping of level name to its GeoDataFrame, used to
infer a |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
Optional[HierarchyLegend]
|
class: |
Optional[HierarchyLegend]
|
content (no |