Skip to content

Commit 57b78a5

Browse files
authored
Marker cluster api docs (#1151)
* Expose MarkerCluster API options to ipyleaflet * Update environment dependencies for docs * Update documentation for MarkerCluster * Clean up formatting
1 parent 4d3d6c1 commit 57b78a5

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

docs/build-environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ channels:
44
- conda-forge
55

66
dependencies:
7-
- yarn~=1.0
8-
- jupyterlab~=3.6.0
7+
- yarn~=3.0
8+
- jupyterlab~=4.0
99
- jupyter-packaging~=0.12
1010
- jupyter-sphinx
1111
- scipy
@@ -18,4 +18,4 @@ dependencies:
1818
- jupyterlite-sphinx
1919
- jupyterlite-xeus-python >=0.9.2,<0.10
2020
- pip:
21-
- ..
21+
- ..

ipyleaflet/leaflet.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,17 +1360,49 @@ class MarkerCluster(Layer):
13601360
----------
13611361
markers: list, default []
13621362
List of markers to include in the cluster.
1363+
show_coverage_on_hover: bool, default True
1364+
Mouse over a cluster to show the bounds of its markers.
1365+
zoom_to_bounds_on_click: bool, default True
1366+
Click a cluster to zoom in to its bounds.
1367+
spiderfy_on_max_zoom: bool, default True
1368+
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)
1369+
remove_outside_visible_bounds: bool, default True
1370+
Clusters and markers too far from the viewport are removed from the map for performance.
1371+
animate: bool, default True
1372+
Smoothly split / merge cluster children when zooming and spiderfying. If L.DomUtil.TRANSITION is false, this option has no effect (no animation is possible).
1373+
animate_adding_markers: bool, default False
1374+
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.
1375+
disable_clustering_at_zoom: int, default 18
1376+
Markers will not be clustered at or below this zoom level. Note: you may be interested in disabling ``spiderfyOnMaxZoom`` option when using ``disableClusteringAtZoom``.
1377+
max_cluster_radius: int, default 80
1378+
The maximum radius that a cluster will cover from the central marker (in pixels). Decreasing will make more, smaller clusters.
1379+
polygon_options: dict, default {}
1380+
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>`_.
1381+
spider_leg_polyline_options: dict, default {"weight": 1.5, "color": "#222", "opacity": 0.5}
1382+
Allows you to specify `PolylineOptions <https://leafletjs.com/reference.html#polyline>`_ to style spider legs.
1383+
spiderfy_distance_multiplier: int, default 1
1384+
Scale the distance away from the center that spiderfied markers are placed. Use if you are using big marker icons.
13631385
"""
13641386

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

13681390
markers = Tuple().tag(trait=Instance(Layer), sync=True, **widget_serialization)
1391+
13691392
# Options
1393+
show_coverage_on_hover = Bool(True).tag(sync=True, o=True)
1394+
zoom_to_bounds_on_click = Bool(True).tag(sync=True, o=True)
1395+
spiderfy_on_max_zoom = Bool(True).tag(sync=True, o=True)
1396+
remove_outside_visible_bounds = Bool(True).tag(sync=True, o=True)
1397+
animate = Bool(True).tag(sync=True, o=True)
1398+
animate_adding_markers = Bool(False).tag(sync=True, o=True)
13701399
disable_clustering_at_zoom = Int(18).tag(sync=True, o=True)
13711400
max_cluster_radius = Int(80).tag(sync=True, o=True)
1401+
polygon_options = Dict({}).tag(sync=True, o=True)
1402+
spider_leg_polyline_options = Dict({"weight": 1.5, "color": "#222", "opacity": 0.5}).tag(sync=True, o=True)
1403+
spiderfy_distance_multiplier = Int(1).tag(sync=True, o=True)
13721404

1373-
1405+
13741406
class LayerGroup(Layer):
13751407
"""LayerGroup class.
13761408

js/src/layers/MarkerCluster.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,26 @@ export class LeafletMarkerClusterModel extends layer.LeafletLayerModel {
1212
_view_name: 'LeafletMarkerClusterView',
1313
_model_name: 'LeafletMarkerClusterModel',
1414
markers: [],
15+
show_coverage_on_hover: true,
16+
zoom_to_bounds_on_click: true,
17+
spiderfy_on_max_zoom: true,
18+
remove_outside_visible_bounds: true,
19+
animate: true,
20+
animate_adding_markers: false,
1521
disableClusteringAtZoom: 18,
1622
maxClusterRadius: 80,
23+
single_marker_mode: false,
24+
spiderfy_distance_multiplier: 1,
25+
polygon_options: {},
26+
chunked_loading: false,
27+
chunk_interval: 200,
28+
chunk_delay: 50,
29+
30+
spider_leg_polyline_options: {
31+
weight: 1.5,
32+
color: '#333',
33+
opacity: 0.5,
34+
},
1735
};
1836
}
1937
}

0 commit comments

Comments
 (0)