@abi-software/flatmap-viewer 2.5.4 → 2.5.6

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.4``
41
+ * ``npm install @abi-software/flatmap-viewer@2.5.6``
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.4",
3
+ "version": "2.5.6",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
@@ -21,7 +21,6 @@
21
21
  "@deck.gl/core": "^8.9.33",
22
22
  "@deck.gl/layers": "^8.9.33",
23
23
  "@deck.gl/mapbox": "^8.9.33",
24
- "@mapbox/mapbox-gl-draw": "^1.4.3",
25
24
  "@turf/area": "^6.5.0",
26
25
  "@turf/bbox": "^6.5.0",
27
26
  "@turf/helpers": "^6.5.0",
@@ -39,7 +38,7 @@
39
38
  "@babel/plugin-transform-runtime": "^7.5.5",
40
39
  "@babel/preset-env": "^7.10.4",
41
40
  "babel-loader": "^8.1.0",
42
- "browser-sync": "^2.26.7",
41
+ "browser-sync": "^3.0.2",
43
42
  "bs-fullscreen-message": "^1.1.0",
44
43
  "clean-webpack-plugin": "^3.0.0",
45
44
  "css-loader": "^6.7.3",
@@ -99,6 +99,9 @@ function expandBounds(bbox1, bbox2, padding)
99
99
 
100
100
  function labelPosition(feature)
101
101
  {
102
+ if (feature.geometry.type === 'Point') {
103
+ return feature.geometry.coordinates
104
+ }
102
105
  const polygon = feature.geometry.coordinates;
103
106
  // Rough heuristic. Area is in km^2; below appears to be good enough.
104
107
  const precision = ('area' in feature.properties)
@@ -255,6 +258,9 @@ export class UserInteractions
255
258
  }
256
259
  }
257
260
 
261
+ // Initialise map annotation
262
+ this.__setupAnnotation()
263
+
258
264
  // Add an initially hidden tool for drawing on the map.
259
265
  this.#annotationDrawControl = new AnnotationDrawControl(flatmap, false)
260
266
  this._map.addControl(this.#annotationDrawControl)
@@ -358,6 +364,34 @@ export class UserInteractions
358
364
  }
359
365
  }
360
366
 
367
+ __setupAnnotation()
368
+ //=================
369
+ {
370
+ // Relate external annotation identifiers to map (GeoJSON) ids
371
+ this.__featureIdToMapId = new Map([...this._flatmap.annotations.entries()]
372
+ .map(idAnn => [idAnn[1].id, idAnn[0]]))
373
+ // Flag features that have annotations
374
+ for (const mapId of this.__featureIdToMapId.values()) {
375
+ const feature = this.mapFeature(mapId)
376
+ if (feature !== undefined) {
377
+ this._map.setFeatureState(feature, { 'map-annotation': true })
378
+ }
379
+ }
380
+ }
381
+
382
+ setFeatureAnnotated(featureId)
383
+ //============================
384
+ {
385
+ // External feature id to map's GeoJSON id
386
+ const mapId = this.__featureIdToMapId.get(featureId)
387
+ if (mapId) {
388
+ const feature = this.mapFeature(mapId)
389
+ if (feature !== undefined) {
390
+ this._map.setFeatureState(feature, { 'annotated': true })
391
+ }
392
+ }
393
+ }
394
+
361
395
  #setPaint(options)
362
396
  //================
363
397
  {