Skip to content

Commit 67cfd42

Browse files
authored
Interact docs updated (#200)
1 parent 1da4d39 commit 67cfd42

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

docs/plugins/interact.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Array of map layer configurations that are selectable. Each entry specifies whic
7171

7272
```js
7373
layers: [
74-
{ layerId: 'my-polygons', idProperty: 'id' },
74+
{ layerId: 'my-polygons', idProperty: 'guid' },
7575
{ layerId: 'my-lines' }
7676
]
7777
```
@@ -90,11 +90,11 @@ layers: [
9090

9191
What to use as `layerId` depends on how your data is added to the map — these are the layers the plugin will enable for feature selection:
9292

93-
- **MapLibre directly** — use the layer IDs defined in your style or added via `map.addLayer()`
93+
- **Map provider directly** — use the layer IDs defined in your style or added via your map provider's layer API
9494
- **Datasets plugin** — use the dataset ID, or the sublayer ID for datasets with sublayers
95-
- **Draw plugin** — uses generated layer IDs such as `fill-inactive.cold` and `stroke-inactive.cold`
95+
- **Draw plugin** — uses generated layer IDs; inspect the map at runtime to find them (e.g. `fill-inactive.cold`, `stroke-inactive.cold` when using MapLibre)
9696

97-
If you're unsure of the layer IDs available at runtime, set `debug: true` in the map config — this lets you query the map and inspect layer names in the browser console.
97+
If you're unsure of the layer IDs available at runtime, set `debug: true` in the interact plugin options — this lets you query the map and inspect layer names in the browser console.
9898

9999
---
100100

@@ -118,7 +118,7 @@ When `true`, only features that touch or overlap the existing selection can be a
118118
**Type:** `boolean`
119119
**Default:** `false`
120120

121-
When `true`, clicking outside any selectable layer clears the current selection.
121+
When `true`, clicking outside any selectable feature clears the current selection.
122122

123123
---
124124

@@ -265,12 +265,15 @@ Emitted when the user confirms their selection (clicks "Done").
265265
**Payload:**
266266
```js
267267
{
268-
// If a marker was placed:
268+
// If a location marker was placed:
269269
coords: [lng, lat],
270270

271271
// If features were selected:
272272
selectedFeatures: [...],
273-
selectionBounds: [west, south, east, north]
273+
selectionBounds: [west, south, east, north],
274+
275+
// If markers were selected:
276+
selectedMarkers: ['...']
274277
}
275278
```
276279

@@ -282,6 +285,9 @@ interactiveMap.on('interact:done', (e) => {
282285
if (e.selectedFeatures) {
283286
console.log('Features selected:', e.selectedFeatures)
284287
}
288+
if (e.selectedMarkers) {
289+
console.log('Markers selected:', e.selectedMarkers)
290+
}
285291
})
286292
```
287293

@@ -303,14 +309,15 @@ interactiveMap.on('interact:cancel', () => {
303309

304310
### `interact:selectionchange`
305311

306-
Emitted whenever the feature selection changes.
312+
Emitted whenever the selected features or selected markers change.
307313

308314
**Payload:**
309315
```js
310316
{
311317
selectedFeatures: [
312318
{ featureId: '...', layerId: '...', properties: {...}, geometry: {...} }
313319
],
320+
selectedMarkers: ['...'], // array of selected marker IDs
314321
selectionBounds: [west, south, east, north] | null,
315322
canMerge: boolean, // true when all selected features are contiguous
316323
canSplit: boolean // true when exactly one Polygon or MultiPolygon is selected

0 commit comments

Comments
 (0)