Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TagFilterButton in PolyLine, AntPath and GeoJson #1756

Merged
9 changes: 8 additions & 1 deletion folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ class GeoJson(Layer):
embedding is only supported if you provide a file link or URL.
zoom_on_click: bool, default False
Set to True to enable zooming in on a geometry when clicking on it.
**kwargs
Keyword arguments are passed to the geoJson object as extra options.

Examples
--------
Expand Down Expand Up @@ -602,8 +604,11 @@ class GeoJson(Layer):
style: {{ this.get_name() }}_styler,
{%- endif %}
{%- if this.marker %}
pointToLayer: {{ this.get_name() }}_pointToLayer
pointToLayer: {{ this.get_name() }}_pointToLayer,
{%- endif %}
{%- for key, value in this.options.items() %}
{{ key }}: {{ value|tojson }},
{%- endfor %}
});

function {{ this.get_name() }}_add (data) {
Expand Down Expand Up @@ -636,6 +641,7 @@ def __init__(
popup: Optional["GeoJsonPopup"] = None,
zoom_on_click: bool = False,
marker: Union[Circle, CircleMarker, Marker, None] = None,
**kwargs: TypeJsonValue,
):
super().__init__(name=name, overlay=overlay, control=control, show=show)
self._name = "GeoJson"
Expand All @@ -653,6 +659,7 @@ def __init__(
"Only Marker, Circle, and CircleMarker are supported as GeoJson marker types."
)
self.marker = marker
self.options = parse_options(**kwargs)

self.data = self.process_data(data)

Expand Down
5 changes: 4 additions & 1 deletion folium/plugins/tag_filter_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

class TagFilterButton(JSCSSMixin, MacroElement):
"""
Creates a Tag Filter Button to filter markers based on criteria
Creates a Tag Filter Button to filter elements based on criteria
(https:/maydemirx/leaflet-tag-filter-button)

This plugin works for multiple element types like Marker, GeoJson
and vector layers like PolyLine.

Parameters
----------
data: list, of strings.
Expand Down
3 changes: 3 additions & 0 deletions folium/vector_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def path_options(
if gradient is not None:
extra_options.update({"gradient": gradient})

if kwargs.get("tags"):
extra_options["tags"] = kwargs.pop("tags")

default = {
"stroke": kwargs.pop("stroke", True),
"color": color,
Expand Down