@delta10/atlas-sdk 0.1.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,7 +28,11 @@ const layers: LayerConfig[] = [
28
28
  features: [
29
29
  {
30
30
  type: 'Point',
31
- coordinates: [120000, 487000]
31
+ coordinates: [120000, 487000],
32
+ properties: {
33
+ id: '123482',
34
+ geplaatst: false
35
+ }
32
36
  }
33
37
  ],
34
38
  style: {
@@ -83,13 +87,17 @@ const onFeatureSelected = (event: any) => {
83
87
  console.log('Features selected:', event.selected)
84
88
  }
85
89
 
86
- const onFeatureDrawn = (event: any) => {
87
- console.log('Feature drawn:', event.feature)
88
- }
89
-
90
90
  const onFeatureModified = (event: any) => {
91
91
  console.log('Features modified:', event.features)
92
92
  }
93
+
94
+ const onModifyCancelled = (event: any) => {
95
+ console.log('Modification cancelled:', event.features)
96
+ }
97
+
98
+ const onMapClicked = (event: any) => {
99
+ console.log('Map clicked:', event.coordinate, event.pixel)
100
+ }
93
101
  </script>
94
102
 
95
103
  <template>
@@ -101,8 +109,9 @@ const onFeatureModified = (event: any) => {
101
109
  :baseLayers="baseLayers"
102
110
  :interactions="interactions"
103
111
  @featureSelected="onFeatureSelected"
104
- @featureDrawn="onFeatureDrawn"
105
112
  @featureModified="onFeatureModified"
113
+ @modifyCancelled="onModifyCancelled"
114
+ @mapClicked="onMapClicked"
106
115
  />
107
116
  </div>
108
117
  </template>
@@ -117,16 +126,16 @@ The `Map` component is the main component of the SDK, providing an interactive m
117
126
  - **`layers`** `LayerConfig[]` - Array of regular layers to display
118
127
  - **`baseLayers`** `LayerConfig[]` - Array of base layers (only one can be active)
119
128
  - **`toggleableLayers`** `LayerConfig[]` - Array of toggleable layers (users can show/hide)
120
- - **`interactions`** `InteractionsConfig` - Configuration for map interactions (select, draw, modify, snap)
129
+ - **`interactions`** `InteractionsConfig` - Configuration for map interactions (select, modify, snap)
121
130
  - **`zoom`** `number` (default: `10`) - Initial zoom level
122
131
  - **`center`** `[number, number]` (default: `[120000, 487000]`) - Initial center coordinates
123
132
 
124
133
  ### Events
125
134
 
126
135
  - **`@featureSelected`** - Emitted when features are selected. Payload: `{ selected: Feature[] }`
127
- - **`@featureDrawn`** - Emitted when a new feature is drawn. Payload: `{ feature: Feature }`
128
136
  - **`@featureModified`** - Emitted when features are modified. Payload: `{ features: Feature[] }`
129
- - **`@baseLayerChanged`** - Emitted when the active base layer changes. Payload: `layerId: string | null`
137
+ - **`@modifyCancelled`** - Emitted when a pending modification is cancelled. Payload: `{ features: Feature[] }`
138
+ - **`@mapClicked`** - Emitted when the map is clicked. Payload: `{ coordinate: [number, number]; pixel: [number, number] }`
130
139
 
131
140
  ### Methods
132
141
 
@@ -225,7 +234,11 @@ onMounted(() => {
225
234
  features: [
226
235
  {
227
236
  type: 'Point',
228
- coordinates: [120000, 487000]
237
+ coordinates: [120000, 487000],
238
+ properties: {
239
+ id: '123482',
240
+ geplaatst: false
241
+ }
229
242
  }
230
243
  ],
231
244
  style: {
@@ -303,13 +316,55 @@ This example checks if the `geplaatst` property equals `true`:
303
316
  - If true: circle fill color is `blue`
304
317
  - If false: circle fill color is `lightblue`
305
318
 
306
- You can use other comparison operators:
319
+ Supported expression operators:
320
+ - `'get'` - Read a feature property
321
+ - `'case'` - Choose a value based on conditions
307
322
  - `'=='` - Equal to
308
- - `'!='` - Not equal to
309
- - `'>'` - Greater than
310
- - `'<'` - Less than
311
- - `'>='` - Greater than or equal
312
- - `'<='` - Less than or equal
323
+ - `'coalesce'` - Use the first non-null value
324
+
325
+ ### OpenLayers Style Functions
326
+
327
+ For more control, vector layers can also use an OpenLayers style function. This is useful for resolution-dependent styling, feature labels, or logic that is easier to express in TypeScript:
328
+
329
+ ```typescript
330
+ import { Style, Stroke, Fill, Circle as CircleStyle, Text } from 'ol/style'
331
+
332
+ {
333
+ type: 'vector',
334
+ options: {
335
+ identifier: 'meetbouten',
336
+ title: 'Meetbouten',
337
+ features: meetboutenFeatures,
338
+ styleFunction: (feature, _currentStyle, resolution) => {
339
+ if (resolution > 0.2) {
340
+ return []
341
+ }
342
+
343
+ const properties = feature.getProperties()
344
+ const isGeplaatst = properties.geplaatst === true
345
+ const featureId = properties.id || ''
346
+
347
+ return [new Style({
348
+ image: new CircleStyle({
349
+ radius: 20,
350
+ fill: new Fill({ color: 'white' }),
351
+ stroke: new Stroke({
352
+ color: isGeplaatst ? 'green' : 'red',
353
+ width: 2
354
+ })
355
+ }),
356
+ text: featureId ? new Text({
357
+ text: String(featureId),
358
+ fill: new Fill({ color: '#000' }),
359
+ stroke: new Stroke({ color: '#fff', width: 2 })
360
+ }) : undefined
361
+ })]
362
+ }
363
+ }
364
+ }
365
+ ```
366
+
367
+ Returning an empty array hides the feature for that render pass.
313
368
 
314
369
  ## Interactions Configuration
315
370
 
@@ -330,31 +385,22 @@ Allow users to select features from specific layers:
330
385
  }
331
386
  ```
332
387
 
333
- ### Draw Interaction
334
- Allow users to draw new geometries:
335
- ```typescript
336
- {
337
- draw: {
338
- enabled: true,
339
- layer: 'meetbouten',
340
- type: 'Point' // 'Point' | 'LineString' | 'Polygon'
341
- }
342
- }
343
- ```
344
-
345
388
  ### Modify Interaction
346
389
  Allow users to edit existing geometries:
347
390
  ```typescript
348
391
  {
349
392
  modify: {
350
393
  enabled: true,
351
- layer: 'meetbouten'
394
+ layer: 'meetbouten',
395
+ labelProperty: 'meetboutnummer' // Optional: feature property shown in the confirm/cancel overlay
352
396
  }
353
397
  }
354
398
  ```
355
399
 
400
+ The `labelProperty` value is read from the selected feature's `properties`. For example, if a feature has `properties: { id: '123482' }`, use `labelProperty: 'id'` to show that value in the confirmation overlay.
401
+
356
402
  ### Snap Interaction
357
- Snap drawn/modified features to existing features:
403
+ Snap modified features to existing features:
358
404
  ```typescript
359
405
  {
360
406
  snap: {
@@ -382,14 +428,10 @@ const interactions: InteractionsConfig = {
382
428
  'circle-stroke-width': 2
383
429
  }
384
430
  },
385
- draw: {
386
- enabled: true,
387
- layer: 'meetbouten',
388
- type: 'Point'
389
- },
390
431
  modify: {
391
432
  enabled: true,
392
- layer: 'meetbouten'
433
+ layer: 'meetbouten',
434
+ labelProperty: 'meetboutnummer'
393
435
  },
394
436
  snap: {
395
437
  enabled: true,
@@ -398,6 +440,41 @@ const interactions: InteractionsConfig = {
398
440
  }
399
441
  ```
400
442
 
443
+ ## Reactive Data
444
+
445
+ Layer configuration can be reactive. Use `computed` when feature arrays are loaded or replaced after mount:
446
+
447
+ ```typescript
448
+ const pandenFeatures = ref<any[]>([])
449
+ const meetboutenFeatures = ref<any[]>([])
450
+
451
+ const layers = computed<LayerConfig[]>(() => [
452
+ {
453
+ type: 'vector',
454
+ options: {
455
+ identifier: 'panden',
456
+ title: 'Panden',
457
+ features: pandenFeatures.value
458
+ }
459
+ },
460
+ {
461
+ type: 'vector',
462
+ options: {
463
+ identifier: 'meetbouten',
464
+ title: 'Meetbouten',
465
+ features: meetboutenFeatures.value
466
+ }
467
+ }
468
+ ])
469
+
470
+ onMounted(() => {
471
+ pandenFeatures.value = loadedPandenFeatures
472
+ meetboutenFeatures.value = loadedMeetboutenFeatures
473
+
474
+ mapRef.value?.fitToFeatures(loadedPandenFeatures)
475
+ })
476
+ ```
477
+
401
478
  ## Development
402
479
 
403
480
  ### Install dependencies