Marker Cluster#
Example#
from ipyleaflet import Map, Marker, MarkerCluster
m = Map(center=(50, 0), zoom=5)
marker1 = Marker(location=(48, -2))
marker2 = Marker(location=(50, 0))
marker3 = Marker(location=(52, 2))
marker_cluster = MarkerCluster(
markers=(marker1, marker2, marker3)
)
m.add(marker_cluster);
m
Attributes#
- class ipyleaflet.leaflet.MarkerCluster(**kwargs: Any)[source]#
MarkerCluster class, with Layer as parent class.
A cluster of markers that you can put on the map like other layers.
- markers#
List of markers to include in the cluster.
- Type:
list, default []
- show_coverage_on_hover#
Mouse over a cluster to show the bounds of its markers.
- Type:
bool, default True
- zoom_to_bounds_on_click#
Click a cluster to zoom in to its bounds.
- Type:
bool, default True
- spiderfy_on_max_zoom#
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)- Type:
bool, default True
- remove_outside_visible_bounds#
Clusters and markers too far from the viewport are removed from the map for performance.
- Type:
bool, default True
- animate#
Smoothly split / merge cluster children when zooming and spiderfying. If L.DomUtil.TRANSITION is false, this option has no effect (no animation is possible).
- Type:
bool, default True
- animate_adding_markers#
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.
- Type:
bool, default False
- disable_clustering_at_zoom#
Markers will not be clustered at or below this zoom level. Note: you may be interested in disabling
spiderfyOnMaxZoom
option when usingdisableClusteringAtZoom
.- Type:
int, default 18
- max_cluster_radius#
The maximum radius that a cluster will cover from the central marker (in pixels). Decreasing will make more, smaller clusters.
- Type:
int, default 80
- polygon_options#
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.
- Type:
dict, default {}
- spider_leg_polyline_options#
Allows you to specify PolylineOptions to style spider legs.
- Type:
dict, default {“weight”: 1.5, “color”: “#222”, “opacity”: 0.5}
- spiderfy_distance_multiplier#
Scale the distance away from the center that spiderfied markers are placed. Use if you are using big marker icons.
- Type:
int, default 1