# SiClusterSourceComponent documentation

**Kind:** component

**Selector:** `si-cluster-source`

```
import { SiClusterSourceComponent } from '@siemens/element-ng/maplibre';
```

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:

Basic usage

```html
<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>
```

```
component SiClusterSourceComponent
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [clusterMaxZoom](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L134-L134>) | `number \| undefined` | `undefined` | Maximum zoom at which points are clustered. |
| [clusterMinPoints](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L139-L139>) | `number` | `2` | Minimum number of points required to form a cluster. |
| [clusterRadius](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L129-L129>) | `number` | `50` | Cluster radius in pixels. |
| [data](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L103-L103>) | `FeatureCollection<Point, GeoJsonProperties>` | `EMPTY_DATA` | Point feature collection to cluster. |
| [groupColors](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L114-L114>) | `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](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L108-L108>) | `string` | `'group'` | Feature property containing the positive numeric group ID. |
| [sourceId](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L98-L98>) (required) | `string` |  | ID used to register the generated GeoJSON source in MapLibre. |
| [statusProperty](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L124-L124>) | `string \| undefined` | `undefined` | Top-level feature property containing a [MarkerStatus](<../../types/MarkerStatus/index.html#t: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.<br><br>See: [https://maplibre.org/maplibre-style-spec/sources/\#clusterproperties](<https://maplibre.org/maplibre-style-spec/sources/#clusterproperties>) |
| [zoomMaxLevel](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L152-L152>) | `number \| undefined` | `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](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L145-L145>) | `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](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L157-L157>) | `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

##### getClusterLeaves

[Source for getClusterLeaves](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L173-L175>)

Returns a page of original points belonging to a cluster.

See: [https://maplibre.org/maplibre-gl-js/docs/API/classes/GeoJSONSource/\#getclusterleaves](<https://maplibre.org/maplibre-gl-js/docs/API/classes/GeoJSONSource/#getclusterleaves>)

```
getClusterLeaves(clusterId: number, limit: number, offset: number): Promise<ClusterPoint[]>
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [clusterId](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L173-L173>) | `number` |  |  |
| [limit](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L173-L173>) | `number` |  |  |
| [offset](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/si-cluster-source.component.ts#L173-L173>) | `number` |  |  |

**Returns:** [Promise](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise>)`<`[ClusterPoint](<index.html#t:ClusterPoint>)`[]>`

### Types Documentation

### [ClusterColors](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/cluster-types.ts#L12-L12>)

**Kind:** type alias

```
import type { ClusterColors } from '@siemens/element-ng/maplibre';
```

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.

```
type ClusterColors = 'status' | 'element' | Record<number, string>
```

### [ClusterPoint](<https://github.com/siemens/element/blob/main/projects/element-ng/maplibre/cluster-types.ts#L6-L6>)

**Kind:** type alias

```
import type { ClusterPoint } from '@siemens/element-ng/maplibre';
```

A point feature consumed by the clustered MapLibre source.

```
type ClusterPoint = GeoJSON.Feature<GeoJSON.Point, GeoJSON.GeoJsonProperties>
```
