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

feat: add visible trait to MarkerCluster #1109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions ipyleaflet/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,16 +1191,26 @@ class MarkerCluster(Layer):
----------
markers: list, default []
List of markers to include in the cluster.
visible: bool, default True
the visibility of the layer on the map
"""

_view_name = Unicode('LeafletMarkerClusterView').tag(sync=True)
_model_name = Unicode('LeafletMarkerClusterModel').tag(sync=True)

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

# Options
disable_clustering_at_zoom = Int(18).tag(sync=True, o=True)
max_cluster_radius = Int(80).tag(sync=True, o=True)

@observe("visible")
def toggle_markers(self, visible):
"""Switch the markers visibility according to the master cluster."""
for marker in self.markers:
marker.visible = visible["new"]


class LayerGroup(Layer):
"""LayerGroup class.
Expand Down