class
GpuClusterLayer
extends LayerBase
implements IClusterLayer
Point clustering layer using Grid++ algorithm. Clusters points at each zoom level, renders cluster circles with count labels using Canvas 2D. Supports theme presets and click-to-zoom.
Constructor
new GpuClusterLayer(options: GpuClusterLayerOptions) | Parameter | Type | Description | |
|---|---|---|---|
options | GpuClusterLayerOptions | required | Cluster layer configuration |
GpuClusterLayerOptions
| Field | Type | Description | |
|---|---|---|---|
id | string | optional | Layer ID |
source | IFeatureLayer | required | Source feature layer containing points |
clusterRadius | number | optional | Cluster radius in pixels Default: 60 |
clusterMinPoints | number | optional | Minimum points to form a cluster Default: 2 |
clusterMaxZoom | number | optional | Stop clustering above this zoom |
themePreset | 'ref-dark-cyan' | 'legacy-orange' | optional | Visual theme preset |
style | Partial<ClusterStyleConfig> | optional | Custom style overrides |
Properties
| Name | Type | Access | Description |
|---|---|---|---|
type | 'gpu-cluster' | readonly | Layer type discriminant |
sourceLayer | IFeatureLayer | read/write | Source feature layer |
pointCount | number | readonly | Total point count |
clusterRadius | number | read/write | Cluster radius (pixels) |
clusterMinPoints | number | read/write | Min points per cluster |
clusterStyle | ClusterStyleConfig | readonly | Current style config |
themePreset | ClusterThemePreset | readonly | Active theme preset |
Methods
setSource()
setSource(layer: IFeatureLayer): void Set a new source feature layer.
Returns
void setThemePreset()
setThemePreset(preset: ClusterThemePreset, style?: Partial<ClusterStyleConfig>): void Switch theme preset with optional overrides.
Returns
void setStyle()
setStyle(style: Partial<ClusterStyleConfig>): void Apply style overrides.
Returns
void handleClusterClick()
handleClusterClick(screenX: number, screenY: number): void Zoom to cluster bounds on click.
Returns
void attachView()
attachView(callbacks: ClusterViewCallbacks): void Attach view coordinate conversion callbacks.
Returns
void Example
const sourceLayer = new GeoJSONLayer({
url: '/data/earthquakes.geojson',
});
const clusters = new GpuClusterLayer({
source: sourceLayer,
clusterRadius: 80,
themePreset: 'ref-dark-cyan',
});
view.map.add(clusters);