Skip to content

Commit 9a64cec

Browse files
Support TagFilterButton in PolyLine, AntPath and GeoJson (#1756)
* Add tags in Polyline to support TagFilterButton * Add tags in AntPath to support TagFilterButton * Add tags in GeoJson to support TagFilterButton * Revert "Add tags in Polyline to support TagFilterButton" This reverts commit 6fa0725. * Revert "Add tags in AntPath to support TagFilterButton" This reverts commit 2f0838d. * Revert " Add tags in GeoJson to support TagFilterButton" This reverts commit f4e4899. * tags in vector layers (like PolyLine) * GeoJson extra options (like tags) * specify usage in docstring --------- Co-authored-by: Frank <[email protected]>
1 parent 609880a commit 9a64cec

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

folium/features.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ class GeoJson(Layer):
498498
embedding is only supported if you provide a file link or URL.
499499
zoom_on_click: bool, default False
500500
Set to True to enable zooming in on a geometry when clicking on it.
501+
**kwargs
502+
Keyword arguments are passed to the geoJson object as extra options.
501503
502504
Examples
503505
--------
@@ -602,8 +604,11 @@ class GeoJson(Layer):
602604
style: {{ this.get_name() }}_styler,
603605
{%- endif %}
604606
{%- if this.marker %}
605-
pointToLayer: {{ this.get_name() }}_pointToLayer
607+
pointToLayer: {{ this.get_name() }}_pointToLayer,
606608
{%- endif %}
609+
{%- for key, value in this.options.items() %}
610+
{{ key }}: {{ value|tojson }},
611+
{%- endfor %}
607612
});
608613
609614
function {{ this.get_name() }}_add (data) {
@@ -636,6 +641,7 @@ def __init__(
636641
popup: Optional["GeoJsonPopup"] = None,
637642
zoom_on_click: bool = False,
638643
marker: Union[Circle, CircleMarker, Marker, None] = None,
644+
**kwargs: TypeJsonValue,
639645
):
640646
super().__init__(name=name, overlay=overlay, control=control, show=show)
641647
self._name = "GeoJson"
@@ -653,6 +659,7 @@ def __init__(
653659
"Only Marker, Circle, and CircleMarker are supported as GeoJson marker types."
654660
)
655661
self.marker = marker
662+
self.options = parse_options(**kwargs)
656663

657664
self.data = self.process_data(data)
658665

folium/plugins/tag_filter_button.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
class TagFilterButton(JSCSSMixin, MacroElement):
99
"""
10-
Creates a Tag Filter Button to filter markers based on criteria
10+
Creates a Tag Filter Button to filter elements based on criteria
1111
(https://github.com/maydemirx/leaflet-tag-filter-button)
1212
13+
This plugin works for multiple element types like Marker, GeoJson
14+
and vector layers like PolyLine.
15+
1316
Parameters
1417
----------
1518
data: list, of strings.

folium/vector_layers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def path_options(
9999
if gradient is not None:
100100
extra_options.update({"gradient": gradient})
101101

102+
if kwargs.get("tags"):
103+
extra_options["tags"] = kwargs.pop("tags")
104+
102105
default = {
103106
"stroke": kwargs.pop("stroke", True),
104107
"color": color,

0 commit comments

Comments
 (0)