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

Marker cluster api docs #1151

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions docs/build-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ channels:
- conda-forge

dependencies:
- yarn~=1.0
- jupyterlab~=3.6.0
- yarn~=3.0
- jupyterlab~=4.0
- jupyter-packaging~=0.12
- jupyter-sphinx
- scipy
Expand All @@ -18,4 +18,4 @@ dependencies:
- jupyterlite-sphinx
- jupyterlite-xeus-python >=0.9.2,<0.10
- pip:
- ..
- ..
34 changes: 33 additions & 1 deletion ipyleaflet/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,17 +1360,49 @@ class MarkerCluster(Layer):
----------
markers: list, default []
List of markers to include in the cluster.
show_coverage_on_hover: bool, default True
Mouse over a cluster to show the bounds of its markers.
zoom_to_bounds_on_click: bool, default True
Click a cluster to zoom in to its bounds.
spiderfy_on_max_zoom: bool, default True
When you click a cluster at the bottom zoom level, spiderfy it so you can see all of its markers. (Note: the spiderfy occurs at the current zoom level if all items within the cluster are still clustered at the maximum zoom level or at zoom specified by ``disableClusteringAtZoom`` option)
remove_outside_visible_bounds: bool, default True
Clusters and markers too far from the viewport are removed from the map for performance.
animate: bool, default True
Smoothly split / merge cluster children when zooming and spiderfying. If L.DomUtil.TRANSITION is false, this option has no effect (no animation is possible).
animate_adding_markers: bool, default False
If set to true (and animate option is also true) then adding individual markers to the MarkerClusterGroup after it has been added to the map will add the marker and animate it into the cluster. Defaults to false as this gives better performance when bulk adding markers.
disable_clustering_at_zoom: int, default 18
Markers will not be clustered at or below this zoom level. Note: you may be interested in disabling ``spiderfyOnMaxZoom`` option when using ``disableClusteringAtZoom``.
max_cluster_radius: int, default 80
The maximum radius that a cluster will cover from the central marker (in pixels). Decreasing will make more, smaller clusters.
polygon_options: dict, default {}
Options to pass when creating the L.Polygon(points, options) to show the bounds of a cluster. Defaults to empty, which lets Leaflet use the default `Path options <https://leafletjs.com/reference.html#path>`_.
spider_leg_polyline_options: dict, default {"weight": 1.5, "color": "#222", "opacity": 0.5}
Allows you to specify `PolylineOptions <https://leafletjs.com/reference.html#polyline>`_ to style spider legs.
spiderfy_distance_multiplier: int, default 1
Scale the distance away from the center that spiderfied markers are placed. Use if you are using big marker icons.
"""

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

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

# Options
show_coverage_on_hover = Bool(True).tag(sync=True, o=True)
zoom_to_bounds_on_click = Bool(True).tag(sync=True, o=True)
spiderfy_on_max_zoom = Bool(True).tag(sync=True, o=True)
remove_outside_visible_bounds = Bool(True).tag(sync=True, o=True)
animate = Bool(True).tag(sync=True, o=True)
animate_adding_markers = Bool(False).tag(sync=True, o=True)
disable_clustering_at_zoom = Int(18).tag(sync=True, o=True)
max_cluster_radius = Int(80).tag(sync=True, o=True)
polygon_options = Dict({}).tag(sync=True, o=True)
spider_leg_polyline_options = Dict({"weight": 1.5, "color": "#222", "opacity": 0.5}).tag(sync=True, o=True)
spiderfy_distance_multiplier = Int(1).tag(sync=True, o=True)


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

Expand Down
18 changes: 18 additions & 0 deletions js/src/layers/MarkerCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,26 @@ export class LeafletMarkerClusterModel extends layer.LeafletLayerModel {
_view_name: 'LeafletMarkerClusterView',
_model_name: 'LeafletMarkerClusterModel',
markers: [],
show_coverage_on_hover: true,
zoom_to_bounds_on_click: true,
spiderfy_on_max_zoom: true,
remove_outside_visible_bounds: true,
animate: true,
animate_adding_markers: false,
disableClusteringAtZoom: 18,
maxClusterRadius: 80,
single_marker_mode: false,
spiderfy_distance_multiplier: 1,
polygon_options: {},
chunked_loading: false,
chunk_interval: 200,
chunk_delay: 50,

spider_leg_polyline_options: {
weight: 1.5,
color: '#333',
opacity: 0.5,
},
};
}
}
Expand Down
Loading