@abi-software/flatmap-viewer 2.5.9 → 2.5.10

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.rst CHANGED
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
38
38
  Package Installation
39
39
  ====================
40
40
 
41
- * ``npm install @abi-software/flatmap-viewer@2.5.9``
41
+ * ``npm install @abi-software/flatmap-viewer@2.5.10``
42
42
 
43
43
  Documentation
44
44
  -------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmap-viewer",
3
- "version": "2.5.9",
3
+ "version": "2.5.10",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": {
6
6
  "type": "git",
@@ -101,6 +101,7 @@ export class AnnotationDrawControl
101
101
  map.on('draw.create', this.createdFeature.bind(this))
102
102
  map.on('draw.delete', this.deletedFeature.bind(this))
103
103
  map.on('draw.update', this.updatedFeature.bind(this))
104
+ map.on('draw.selectionchange', this.selectionChangedEvent.bind(this))
104
105
  this.show(this.__visible)
105
106
  return this.__container
106
107
  }
@@ -190,6 +191,8 @@ export class AnnotationDrawControl
190
191
  {
191
192
  const feature = this.#cleanFeature(event)
192
193
  if (feature) {
194
+ // specify updated callback type, either `move` or `change_coordinates`
195
+ feature.action = event.action
193
196
  if (this.__uncommittedFeatureIds.has(feature.id)) {
194
197
  // Ignore updates on an uncommitted create or update
195
198
  } else {
@@ -206,6 +209,13 @@ export class AnnotationDrawControl
206
209
  this.#sendEvent('modeChanged', event)
207
210
  }
208
211
 
212
+ selectionChangedEvent(event)
213
+ //==========================
214
+ {
215
+ // Used to indicate a feature is selected or deselected
216
+ this.#sendEvent('selectionChanged', event)
217
+ }
218
+
209
219
  inDrawingMode()
210
220
  //=============
211
221
  {
@@ -260,6 +270,12 @@ export class AnnotationDrawControl
260
270
  this.__draw.deleteAll()
261
271
  }
262
272
 
273
+ trashFeature()
274
+ //============
275
+ {
276
+ this.__draw.trash()
277
+ }
278
+
263
279
  addFeature(feature)
264
280
  //=================
265
281
  {
@@ -274,6 +290,13 @@ export class AnnotationDrawControl
274
290
  {
275
291
  return this.__draw.get(feature.id) || null
276
292
  }
293
+
294
+ changeMode(type)
295
+ //===============
296
+ {
297
+ // Change the mode directly without listening to modes callback
298
+ this.__draw.changeMode(type.mode, type.options)
299
+ }
277
300
  }
278
301
 
279
302
  //==============================================================================
@@ -1025,7 +1025,11 @@ class FlatMap
1025
1025
  'models',
1026
1026
  'source',
1027
1027
  'taxons',
1028
- 'hyperlinks'
1028
+ 'hyperlinks',
1029
+ 'completeness',
1030
+ 'missing-nodes',
1031
+ 'alert',
1032
+ 'biological-sex'
1029
1033
  ];
1030
1034
  const jsonProperties = [
1031
1035
  'hyperlinks'
@@ -1122,6 +1126,17 @@ class FlatMap
1122
1126
  }
1123
1127
  }
1124
1128
 
1129
+ /**
1130
+ * Fire trash to enter `updated` or `deleted` feature event.
1131
+ */
1132
+ trashAnnotationFeature()
1133
+ //======================
1134
+ {
1135
+ if (this._userInteractions) {
1136
+ this._userInteractions.trashAnnotationFeature()
1137
+ }
1138
+ }
1139
+
1125
1140
  /**
1126
1141
  * Add a drawn feature to the annotation drawing tool.
1127
1142
  *
@@ -1155,6 +1170,24 @@ class FlatMap
1155
1170
  }
1156
1171
  }
1157
1172
 
1173
+ /**
1174
+ * Changes draw to another mode. The mode argument must be one of the following:
1175
+ * `simple_select`, `direct_select`, `draw_line_string`,
1176
+ * `draw_polygon` or `draw_point`. Options is accepted in first three modes.
1177
+ * More details in mapbox-gl-draw github repository.
1178
+ *
1179
+ * @param type {Object} The object
1180
+ * @param type.mode {string} Either ``simple_select``, ``direct_select``, etc
1181
+ * @param type.options {Object} Feature id(s) object.
1182
+ */
1183
+ changeAnnotationDrawMode(type)
1184
+ //============================
1185
+ {
1186
+ if (this._userInteractions) {
1187
+ this._userInteractions.changeAnnotationDrawMode(type)
1188
+ }
1189
+ }
1190
+
1158
1191
  /**
1159
1192
  * Generate a callback as a result of some event with a flatmap feature.
1160
1193
  *
@@ -373,6 +373,14 @@ export class UserInteractions
373
373
  }
374
374
  }
375
375
 
376
+ trashAnnotationFeature()
377
+ //======================
378
+ {
379
+ if (this.#annotationDrawControl) {
380
+ this.#annotationDrawControl.trashFeature()
381
+ }
382
+ }
383
+
376
384
  addAnnotationFeature(feature)
377
385
  //===========================
378
386
  {
@@ -389,6 +397,14 @@ export class UserInteractions
389
397
  }
390
398
  }
391
399
 
400
+ changeAnnotationDrawMode(type)
401
+ //=============================
402
+ {
403
+ if (this.#annotationDrawControl) {
404
+ this.#annotationDrawControl.changeMode(type)
405
+ }
406
+ }
407
+
392
408
  __setupAnnotation()
393
409
  //=================
394
410
  {
package/src/main.js CHANGED
@@ -64,7 +64,7 @@ class DrawControl
64
64
  //================
65
65
  {
66
66
  console.log(event)
67
- if (this._idField) {
67
+ if (this._idField && event.type !== 'modeChanged' && event.type !== 'selectionChanged') {
68
68
  this._idField.innerText = `Annotation ${event.type}, Id: ${event.feature.id}`
69
69
  this._lastEvent = event
70
70
  }