Skip to content

SiClusterSourceComponent documentation

selector
si-cluster-source

Adds a clustered GeoJSON source to a MapLibre map and renders interactive cluster markers.

Cluster markers display the number of contained points and their distribution by group. Status segments can be enabled for ungrouped points by providing statusProperty . Render individual, unclustered points separately with mgl-markers-for-clusters using the same source ID. Positive numeric groups always take precedence over status segments. Status segments apply only when the normalized group value is zero; points without a matching group or status use the ungrouped color.

Clicking a cluster frames all of its children and zooms in as far as possible while they stay visible, up to the zoom at which points stop being clustered. Clusters whose children stay within clusterRadius until then emit clusterClick instead, which opens a projected si-cluster-popover .

Example:

<mgl-map [mapStyle]="mapStyle()">
  <si-cluster-source
    sourceId="locations"
    statusProperty="status"
    [data]="locations"
    (clusterClick)="onClusterClick($event)"
  />

  <mgl-markers-for-clusters source="locations">
    <ng-template let-feature mglPoint>
      <si-status-marker
        [status]="feature.properties?.status"
      />
    </ng-template>
  </mgl-markers-for-clusters>
</mgl-map>

Input Properties

Name Type Default Description
clusterMaxZoom
number undefined Maximum zoom at which points are clustered.
clusterMinPoints
number 2 Minimum number of points required to form a cluster.
clusterRadius
number 50 Cluster radius in pixels.
data
FeatureCollection<Point, GeoJsonProperties> EMPTY_DATA Point feature collection to cluster.
groupColors
ClusterColors 'status' Built-in palette or exact colors indexed by group ID. The built-in 'status' palette contains four colors for numeric groups and is separate from status-based bucketing.
groupProperty
string 'group' Feature property containing the positive numeric group ID.
sourceId
Required
string ID used to register the generated GeoJSON source in MapLibre.
statusProperty
string undefined Top-level feature property containing a MarkerStatus value. Status bucketing is disabled by default and only applies when the normalized group value is zero. Missing or unsupported status values, and groups that do not match a configured bucket, use the ungrouped color. Built-in colors match SiStatusMarkerComponent , with default using accent and unknown using neutral.
See https://maplibre.org/maplibre-style-spec/sources/#clusterproperties
zoomMaxLevel
number undefined Highest zoom used to expand a cluster. Clusters whose children stay within clusterRadius up to this zoom emit clusterClick instead of zooming. Defaults to clusterMaxZoom , because points stop being clustered above it.
zoomOnClick
boolean false Frames the children of a clicked cluster and zooms in as far as possible while they stay visible. Clusters whose children cannot be pulled apart emit clusterClick instead.

Output Properties

Name Type Description
clusterClick
ClusterPoint Emits when a cluster marker is activated and the click did not expand the cluster, either because zoomOnClick is disabled or because the children cannot be pulled apart.

Attributes and Methods

Name Type Default Description
getClusterLeaves(...)
(clusterId: number, limit: number, offset: number) => Promise<ClusterPoint[]> Returns a page of original points belonging to a cluster.
See https://maplibre.org/maplibre-gl-js/docs/API/classes/GeoJSONSource/#getclusterleaves

Parameters

Types Documentation

imported from @types/geojson
import
imported from @types/geojson
imported from @types/geojson
("status" | "element" | Record<number, string>)
Built-in group palette or exact colors indexed by positive group ID. The 'status' palette is the four-color palette used for numeric groups; it is separate from status-based bucketing.
Status values supported by status markers and cluster status segments.
A point feature consumed by the clustered MapLibre source.
imported from @types/geojson
import
imported from @types/geojson
imported from @types/geojson
("success" | "info" | "warning" | "danger" | "caution" | "critical")

Except where otherwise noted, content on this site is licensed under MIT License.