@abi-software/flatmap-viewer 2.3.2-b.4 → 2.3.3-b.1

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.3.2-b.4``
41
+ * ``npm install @abi-software/flatmap-viewer@2.3.3-b.1``
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.3.2-b.4",
3
+ "version": "2.3.3-b.1",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
package/src/annotation.js CHANGED
@@ -475,6 +475,8 @@ export class Annotator
475
475
  let label = '';
476
476
  if (feature.properties.models) {
477
477
  label = ` -- ${feature.properties.label.split('\n')[0]} (${feature.properties.models})`;
478
+ } else if (feature.properties.label) {
479
+ label = ` -- ${feature.properties.label.split('\n')[0]}`;
478
480
  }
479
481
  featureList.push(`<option value="${feature.id}" ${selected}>${annotated ? '*' : '&nbsp;'} ${feature.properties.id} -- ${feature.properties.kind}${label}</option>`);
480
482
  featureProperties.set(+feature.id, feature.properties);
@@ -526,6 +526,73 @@ export class NerveControl
526
526
 
527
527
  //==============================================================================
528
528
 
529
+ export class AnnotatedControl
530
+ {
531
+ constructor(ui, options={excludeAnnotated: false})
532
+ {
533
+ this.__ui = ui;
534
+ this.__map = undefined;
535
+ this.__exclude = options.excludeAnnotated || false;
536
+ }
537
+
538
+ getDefaultPosition()
539
+ //==================
540
+ {
541
+ return 'top-right';
542
+ }
543
+
544
+ onAdd(map)
545
+ //========
546
+ {
547
+ this.__map = map;
548
+ this.__container = document.createElement('div');
549
+ this.__container.className = 'maplibregl-ctrl';
550
+
551
+ this.__button = document.createElement('button');
552
+ this.__button.id = 'map-annotated-button';
553
+ this.__button.className = 'control-button text-button';
554
+ this.__button.setAttribute('type', 'button');
555
+ this.__button.setAttribute('aria-label', 'Show/hide annotated paths');
556
+ this.__button.textContent = 'UNANN';
557
+ this.__button.title = 'Show/hide annotated paths';
558
+ this.__container.appendChild(this.__button);
559
+
560
+ this.__container.addEventListener('click', this.onClick_.bind(this));
561
+ this.__setBackground();
562
+ return this.__container;
563
+ }
564
+
565
+ __setBackground()
566
+ //===============
567
+ {
568
+ if (this.__exclude) {
569
+ this.__button.setAttribute('style', 'background: red');
570
+ } else {
571
+ this.__button.removeAttribute('style');
572
+ }
573
+ }
574
+
575
+ onRemove()
576
+ //========
577
+ {
578
+ this.__container.parentNode.removeChild(this.__container);
579
+ this.__map = undefined;
580
+ }
581
+
582
+ onClick_(event)
583
+ //=============
584
+ {
585
+ if (event.target.id === 'map-annotated-button') {
586
+ this.__exclude = !this.__exclude;
587
+ this.__setBackground();
588
+ this.__ui.excludeAnnotated(this.__exclude);
589
+ }
590
+ event.stopPropagation();
591
+ }
592
+ }
593
+
594
+ //==============================================================================
595
+
529
596
  export class BackgroundControl
530
597
  {
531
598
  constructor(flatmap)
@@ -40,7 +40,7 @@ import {VECTOR_TILES_SOURCE} from './styling';
40
40
  import {SystemsManager} from './systems';
41
41
 
42
42
  import {displayedProperties, InfoControl} from './controls/info';
43
- import {BackgroundControl, LayerControl, NerveControl,
43
+ import {AnnotatedControl, BackgroundControl, LayerControl, NerveControl,
44
44
  SCKANControl} from './controls/controls';
45
45
  import {PathControl} from './controls/paths';
46
46
  import {SearchControl} from './controls/search';
@@ -189,6 +189,7 @@ export class UserInteractions
189
189
  if (flatmap.options.style === 'functional') {
190
190
  this._map.addControl(new SystemsControl(flatmap, this.__systemsManager.systems));
191
191
  this._map.addControl(new SCKANControl(flatmap, flatmap.options.layerOptions));
192
+ this._map.addControl(new AnnotatedControl(this, flatmap.options.layerOptions));
192
193
  }
193
194
  }
194
195
 
@@ -1096,6 +1097,12 @@ export class UserInteractions
1096
1097
  this._layerManager.enableSckanPaths(sckanState, enable);
1097
1098
  }
1098
1099
 
1100
+ excludeAnnotated(exclude=false)
1101
+ //=============================
1102
+ {
1103
+ this._layerManager.setPaint({excludeAnnotated: exclude});
1104
+ }
1105
+
1099
1106
  //==============================================================================
1100
1107
 
1101
1108
  // Marker handling
package/src/styling.js CHANGED
@@ -418,23 +418,24 @@ export class AnnotatedPathLayer extends VectorStyleLayer
418
418
 
419
419
  paintStyle(options={}, changes=false)
420
420
  {
421
- const dimmed = 'dimmed' in options && options.dimmed;
421
+ const exclude = 'excludeAnnotated' in options && options.excludeAnnotated;
422
422
  const paintStyle = {
423
423
  'line-color': COLOUR_ANNOTATED,
424
424
  'line-dasharray': [5, 0.5, 3, 0.5],
425
425
  'line-opacity': [
426
426
  'case',
427
427
  ['boolean', ['feature-state', 'hidden'], false], 0.05,
428
- ['boolean', ['feature-state', 'annotated'], false],
429
- (dimmed ? 0.1 : 0.8),
428
+ ['boolean', ['feature-state', 'annotated'], false],
429
+ (exclude ? 0.05 : 0.8),
430
430
  0.6
431
431
  ],
432
432
  'line-width': [
433
433
  'let',
434
434
  'width',
435
435
  ['case',
436
+ ['boolean', ['feature-state', 'hidden'], false], 0.0,
436
437
  ['boolean', ['feature-state', 'annotated'], false],
437
- ['*', 1.2, ['case', ['has', 'stroke-width'], ['get', 'stroke-width'], 1.0]],
438
+ exclude ? 0.0 : (['*', 1.2, ['case', ['has', 'stroke-width'], ['get', 'stroke-width'], 1.0]]),
438
439
  0.0
439
440
  ],
440
441
  STROKE_INTERPOLATION
@@ -498,6 +499,7 @@ export class PathLineLayer extends VectorStyleLayer
498
499
  paintStyle(options={}, changes=false)
499
500
  {
500
501
  const dimmed = 'dimmed' in options && options.dimmed;
502
+ const exclude = 'excludeAnnotated' in options && options.excludeAnnotated;
501
503
  const paintStyle = {
502
504
  'line-color': [
503
505
  'case',
@@ -544,6 +546,7 @@ export class PathLineLayer extends VectorStyleLayer
544
546
  ['boolean', ['feature-state', 'active'], false], 0.0,
545
547
  0.6
546
548
  ],
549
+ ['case', ['boolean', ['feature-state', 'annotated'], false], (exclude ? 0.0 : 1.0), 1.0],
547
550
  ['case', ['has', 'stroke-width'], ['get', 'stroke-width'], 1.0]
548
551
  ],
549
552
  STROKE_INTERPOLATION