Skip to content

Commit 03f8639

Browse files
committed
chore: add missing jsdocs #38
1 parent 1abf319 commit 03f8639

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

index.html

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,33 @@
9090
document.getElementById('select-feature').addEventListener('click', selectFeature)
9191
})
9292

93+
// Custom rendering functions
94+
const markerRender = (element, markerSize, feature) => {
95+
element.textContent = feature.properties.mag
96+
97+
buildCss(element, {
98+
'background-color': 'green',
99+
'border-radius': '100%',
100+
'justify-content': 'center',
101+
'align-items': 'center',
102+
'display': 'flex',
103+
'color': 'white',
104+
'width': `${markerSize}px`,
105+
'height': `${markerSize}px`,
106+
'cursor': 'pointer'
107+
});
108+
}
109+
110+
const pinMarkerRender = (coords, offset) => {
111+
return new maplibregl.Marker({
112+
scale: 1.3,
113+
color: '#f44336',
114+
anchor: 'bottom'
115+
})
116+
.setLngLat(coords)
117+
.setOffset(offset)
118+
}
119+
93120
const clusterRender = (element, props) => {
94121
element.innerHTML = props.point_count.toLocaleString();
95122

@@ -107,6 +134,7 @@
107134
});
108135
}
109136

137+
// Specific features showcase functions
110138
const loadData = async () => {
111139
const url = document.getElementById('custom-url').value
112140

@@ -131,32 +159,6 @@
131159
})
132160
}
133161

134-
const markerRender = (element, markerSize, feature) => {
135-
element.textContent = feature.properties.mag
136-
137-
buildCss(element, {
138-
'background-color': 'green',
139-
'border-radius': '100%',
140-
'justify-content': 'center',
141-
'align-items': 'center',
142-
'display': 'flex',
143-
'color': 'white',
144-
'width': `${markerSize}px`,
145-
'height': `${markerSize}px`,
146-
'cursor': 'pointer'
147-
});
148-
}
149-
150-
const pinMarkerRender = (coords, offset) => {
151-
return new maplibregl.Marker({
152-
scale: 1.3,
153-
color: '#f44336',
154-
anchor: 'bottom'
155-
})
156-
.setLngLat(coords)
157-
.setOffset(offset)
158-
}
159-
160162
const selectFeature = async () => {
161163
const id = document.getElementById('feature-id').value
162164

src/teritorio-cluster.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class TeritorioCluster extends EventTarget implements CustomLayerInterfac
3434
pinMarkerRender: pinMarkerRenderDefault,
3535
} satisfies TeritorioClusterOptions
3636

37-
// Internal map and layer configuration
37+
// Internal layer configuration
3838
private map: MapGL | null = null
3939
private readonly sourceId: string
4040
private source: GeoJSONSource | null = null
@@ -51,7 +51,7 @@ export class TeritorioCluster extends EventTarget implements CustomLayerInterfac
5151
private abortExec: number = 0
5252

5353
/**
54-
* Constructs a new TeritorioCluster.
54+
* Creates a new instance of the TeritorioCluster custom layer.
5555
* @param id - Unique ID for the layer.
5656
* @param sourceId - ID of the GeoJSON source.
5757
* @param options - Optional configuration overrides.
@@ -69,9 +69,9 @@ export class TeritorioCluster extends EventTarget implements CustomLayerInterfac
6969
}
7070

7171
/**
72-
* Called when the layer is added to the map.
72+
* Initializes the cluster layer when added to the map.
7373
*
74-
* @param map - The map instance to which the layer is being added.
74+
* @param map - The MapLibre GL map instance.
7575
*
7676
* @remarks
7777
* This method is called when the layer is first added to the map. It performs the following actions:
@@ -193,6 +193,12 @@ export class TeritorioCluster extends EventTarget implements CustomLayerInterfac
193193
}
194194
}
195195

196+
/**
197+
* Updates the fit bounds configuration used for clustering.
198+
*
199+
* @param options - The options to apply when fitting the bounds,
200+
* such as padding, maximum zoom level, and animation settings.
201+
*/
196202
public setBoundsOptions = (options: FitBoundsOptions): void => {
197203
this.opts.fitBoundsOptions = options
198204
}

0 commit comments

Comments
 (0)