Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ipyleaflet/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,12 +1211,15 @@ class LayerGroup(Layer):
----------
layers: list, default []
List of layers to include in the group.
visible: bool, default True
the visibility of the layer on the map
"""

_view_name = Unicode('LeafletLayerGroupView').tag(sync=True)
_model_name = Unicode('LeafletLayerGroupModel').tag(sync=True)

layers = Tuple().tag(trait=Instance(Layer), sync=True, **widget_serialization)
visible = Bool(True).tag(sync=True)

_layer_ids = List()

Expand Down Expand Up @@ -1341,6 +1344,11 @@ def clear(self):
"""Remove all layers from the group."""
self.layers = ()

@observe("visible")
def toggle_markers(self, visible):
"""Switch the layers visibility according to the master LayerGroup."""
[setattr(layer, "visible", visible["new"]) for layer in self.layers]


class FeatureGroup(LayerGroup):
"""FeatureGroup abstract class."""
Expand Down