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

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.3-b.1``
41
+ * ``npm install @abi-software/flatmap-viewer@2.3.3-b.3``
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.3-b.1",
3
+ "version": "2.3.3-b.3",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
@@ -194,8 +194,8 @@ export class InfoControl
194
194
  const featureIds = [];
195
195
  const displayFeatures = [];
196
196
  for (const feat of featureList) {
197
- if (featureIds.indexOf(feat['id']) < 0) {
198
- featureIds.push(feat['id']);
197
+ if (featureIds.indexOf(feat.id) < 0) {
198
+ featureIds.push(feat.id);
199
199
  const displayFeat = {};
200
200
  displayProperties.forEach(prop => {
201
201
  if (prop === 'properties') {
@@ -77,6 +77,7 @@ class FlatMap
77
77
  this.__datasetToFeatureIds = new Map();
78
78
  this.__modelToFeatureIds = new Map();
79
79
  this.__mapSourceToFeatureIds = new Map();
80
+
80
81
  for (const [featureId, annotation] of Object.entries(mapDescription.annotations)) {
81
82
  this.__addAnnotation(featureId, annotation);
82
83
  this.__searchIndex.indexMetadata(featureId, annotation);
@@ -655,10 +655,11 @@ export class UserInteractions
655
655
  this._currentPopup.remove();
656
656
  }
657
657
 
658
- // Highlight the feature
659
-
660
- this.unselectFeatures();
661
- this.selectFeature(featureId);
658
+ if (!(options && options.preserveSelection)) {
659
+ // Highlight the feature
660
+ this.unselectFeatures();
661
+ this.selectFeature(featureId);
662
+ }
662
663
 
663
664
  // Find the pop-up's postion
664
665
 
@@ -831,7 +832,7 @@ export class UserInteractions
831
832
  let info = '';
832
833
  let tooltip = '';
833
834
  if (displayInfo) {
834
- if (!'tooltip' in features[0].properties) {
835
+ if (!('tooltip' in features[0].properties)) {
835
836
  this.__activateFeature(features[0]);
836
837
  }
837
838
  info = this._infoControl.featureInformation(features, event.lngLat);
@@ -855,8 +856,7 @@ export class UserInteractions
855
856
  }
856
857
  } else {
857
858
  let labelledFeatures = features.filter(feature => (('hyperlink' in feature.properties
858
- || 'label' in feature.properties
859
- || 'node' in feature.properties)
859
+ || 'label' in feature.properties)
860
860
  && (!('tooltip' in feature.properties)
861
861
  || feature.properties.tooltip)))
862
862
  .sort((a, b) => (a.properties.area - b.properties.area));
@@ -896,7 +896,9 @@ export class UserInteractions
896
896
  //htmlList.push(`<span class="info-name">Scale:</span>`);
897
897
  //htmlList.push(`<span class="info-value">${feature.properties.scale}</span>`);
898
898
  }
899
- info = `<div id="info-control-info">${htmlList.join('\n')}</div>`;
899
+ if (!this._flatmap.options.debug) {
900
+ info = `<div id="info-control-info">${htmlList.join('\n')}</div>`;
901
+ }
900
902
  }
901
903
  this.__activateFeature(feature);
902
904
  this.__activateRelatedFeatures(feature);
@@ -906,7 +908,7 @@ export class UserInteractions
906
908
  }
907
909
  }
908
910
 
909
- if (displayInfo || this._flatmap.options.debug) {
911
+ if (info !== '') {
910
912
  this._infoControl.show(info);
911
913
  }
912
914
  this.__showToolTip(tooltip, event.lngLat, tooltipFeature);
@@ -1186,6 +1188,9 @@ export class UserInteractions
1186
1188
  this.__markerIdByMarker.set(marker, markerId);
1187
1189
  this.__markerIdByFeatureId.set(+featureId, markerId);
1188
1190
  this.__annotationByMarkerId.set(markerId, annotation);
1191
+ if (!this.__featureEnabled(this.mapFeature(+featureId))) {
1192
+ markerElement.style.visibility = 'hidden';
1193
+ }
1189
1194
  }
1190
1195
  }
1191
1196
  if (markerId === -1) {
package/src/layers.js CHANGED
@@ -123,7 +123,6 @@ class MapFeatureLayers extends MapStylingLayers
123
123
  this.__addStyleLayer(style.FeatureLineLayer);
124
124
  this.__addStyleLayer(style.FeatureBorderLayer);
125
125
  this.__addStyleLayer(style.CentrelineNodeFillLayer);
126
- this.__addStyleLayer(style.CentrelineNodeBorderLayer);
127
126
  }
128
127
  this.__addPathwayStyleLayers();
129
128
  if (vectorFeatures) {
package/src/styling.js CHANGED
@@ -35,7 +35,7 @@ const COLOUR_ANNOTATED = '#0F0';
35
35
  const COLOUR_SELECTED = '#0F0';
36
36
  const COLOUR_HIDDEN = '#D8D8D8';
37
37
 
38
- const CENTRELINE_ACTIVE = '#444';
38
+ const CENTRELINE_ACTIVE = '#888';
39
39
  const CENTRELINE_COLOUR = '#CCC';
40
40
 
41
41
  const FEATURE_SELECTED_BORDER = 'black';
@@ -161,7 +161,7 @@ export class FeatureFillLayer extends VectorStyleLayer
161
161
  'fill-opacity': [
162
162
  'case',
163
163
  ['boolean', ['feature-state', 'hidden'], false], 0.1,
164
- ['boolean', ['feature-state', 'selected'], false], 0.7,
164
+ ['boolean', ['feature-state', 'selected'], false], 0.5,
165
165
  ['has', 'opacity'], ['get', 'opacity'],
166
166
  ['has', 'colour'], 1.0,
167
167
  ['boolean', ['feature-state', 'active'], false], 0.7,
@@ -502,13 +502,17 @@ export class PathLineLayer extends VectorStyleLayer
502
502
  const exclude = 'excludeAnnotated' in options && options.excludeAnnotated;
503
503
  const paintStyle = {
504
504
  'line-color': [
505
- 'case',
506
- ['boolean', ['feature-state', 'selected'], false], COLOUR_SELECTED,
507
- ['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
508
- ['==', ['get', 'type'], 'bezier'], 'red',
509
- ['==', ['get', 'kind'], 'unknown'], '#888',
510
- ...PATH_STYLE_RULES,
511
- '#888'
505
+ 'let', 'active', ['to-number', ['feature-state', 'active'], 0],
506
+ [ 'case',
507
+ ['all',
508
+ ['==', ['var', 'active'], 0],
509
+ ['boolean', ['feature-state', 'selected'], false],
510
+ ], COLOUR_SELECTED,
511
+ ['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
512
+ ['==', ['get', 'type'], 'bezier'], 'red',
513
+ ...PATH_STYLE_RULES,
514
+ '#888'
515
+ ]
512
516
  ],
513
517
  'line-opacity': this.__highlight ? [
514
518
  'case',
@@ -625,7 +629,7 @@ class CentrelineLayer extends VectorStyleLayer
625
629
  ['boolean', ['feature-state', 'hidden'], false], 0.01,
626
630
  ['boolean', ['feature-state', 'selected'], false], 1.0,
627
631
  ['boolean', ['feature-state', 'active'], false], 1.0,
628
- 0.8
632
+ (this.__type == 'edge') ? 0.4 : 0.8
629
633
  ],
630
634
  'line-width': [
631
635
  'let',
@@ -651,7 +655,7 @@ class CentrelineLayer extends VectorStyleLayer
651
655
  ],
652
656
  'paint': this.paintStyle(options),
653
657
  'layout': {
654
- 'line-cap': 'square',
658
+ 'line-cap': 'round',
655
659
  'line-join': 'bevel'
656
660
  }
657
661
  };
@@ -691,8 +695,13 @@ export class CentrelineNodeFillLayer extends VectorStyleLayer
691
695
  {
692
696
  const showNodes = options.showCentrelines || false;
693
697
  const paintStyle = {
694
- 'fill-color': '#AFA202',
695
- 'fill-opacity': showNodes ? 0.7 : 0.01
698
+ 'fill-color': [
699
+ 'case',
700
+ ['boolean', ['feature-state', 'selected'], false], COLOUR_SELECTED,
701
+ ['boolean', ['feature-state', 'active'], false], CENTRELINE_ACTIVE,
702
+ CENTRELINE_COLOUR
703
+ ],
704
+ 'fill-opacity': showNodes ? 0.8 : 0.01
696
705
  }
697
706
  return super.changedPaintStyle(paintStyle, changes);
698
707
  }
@@ -726,9 +735,14 @@ export class CentrelineNodeBorderLayer extends VectorStyleLayer
726
735
  {
727
736
  const showNodes = options.showCentrelines || false;
728
737
  const paintStyle = {
729
- 'line-color': '#AFA202',
730
- 'line-opacity': showNodes ? 0.7 : 0.01,
731
- 'line-width': 0.5
738
+ 'line-color': '#000',
739
+ 'line-opacity': showNodes ? 0.1 : 0.01,
740
+ 'line-width': [
741
+ 'let',
742
+ 'width',
743
+ 0.2,
744
+ STROKE_INTERPOLATION
745
+ ]
732
746
  }
733
747
  return super.changedPaintStyle(paintStyle, changes);
734
748
  }
@@ -772,8 +786,8 @@ export class FeatureNerveLayer extends VectorStyleLayer
772
786
  'line-color': [
773
787
  'case',
774
788
  ['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
775
- ['boolean', ['feature-state', 'active'], false], NERVE_ACTIVE,
776
789
  ['boolean', ['feature-state', 'selected'], false], NERVE_SELECTED,
790
+ ['boolean', ['feature-state', 'active'], false], NERVE_ACTIVE,
777
791
  '#888'
778
792
  ],
779
793
  'line-opacity': [
@@ -855,7 +869,41 @@ export class NervePolygonFill extends VectorStyleLayer
855
869
  super(id, 'nerve-fill', sourceLayer);
856
870
  }
857
871
 
858
- style(options)
872
+ paintStyle(options={}, changes=false)
873
+ {
874
+ const dimmed = 'dimmed' in options && options.dimmed;
875
+ const paintStyle = {
876
+ 'fill-color': [
877
+ 'let', 'active', ['to-number', ['feature-state', 'active'], 0],
878
+ [ 'case',
879
+ ['all',
880
+ ['==', ['var', 'active'], 0],
881
+ ['==', ['get', 'type'], 'arrow'],
882
+ ['boolean', ['feature-state', 'selected'], false]
883
+ ], COLOUR_SELECTED,
884
+ ['==', ['get', 'kind'], 'bezier-end'], 'red',
885
+ ['==', ['get', 'kind'], 'bezier-control'], 'green',
886
+ ...PATH_STYLE_RULES,
887
+ 'white'
888
+ ]
889
+ ],
890
+ 'fill-opacity': [
891
+ 'case',
892
+ ['boolean', ['feature-state', 'hidden'], false], 0.01,
893
+ ['boolean', ['feature-state', 'selected'], false], 0.8,
894
+ ['boolean', ['feature-state', 'active'], false], 0.9,
895
+ ['==', ['get', 'type'], 'bezier'], 0.9,
896
+ ['any',
897
+ ['==', ['get', 'type'], 'arrow'],
898
+ ['==', ['get', 'type'], 'junction']
899
+ ], dimmed ? 0.1 : 0.5,
900
+ 0.01
901
+ ]
902
+ };
903
+ return super.changedPaintStyle(paintStyle, changes);
904
+ }
905
+
906
+ style(options={})
859
907
  {
860
908
  return {
861
909
  ...super.style(),
@@ -864,27 +912,14 @@ export class NervePolygonFill extends VectorStyleLayer
864
912
  'all',
865
913
  ['==', '$type', 'Polygon'],
866
914
  ['any',
915
+ ['==', 'type', 'arrow'],
867
916
  ['==', 'type', 'bezier'],
868
917
  ['==', 'type', 'junction'],
869
918
  ['==', 'type', 'nerve'],
870
919
  ['==', 'type', 'nerve-section']
871
920
  ]
872
921
  ],
873
- 'paint': {
874
- 'fill-color': [
875
- 'case',
876
- ['==', ['get', 'kind'], 'bezier-end'], 'red',
877
- ['==', ['get', 'kind'], 'bezier-control'], 'green',
878
- ...PATH_STYLE_RULES,
879
- 'white'
880
- ],
881
- 'fill-opacity': [
882
- 'case',
883
- ['==', ['get', 'type'], 'bezier'], 0.9,
884
- ['==', ['get', 'type'], 'junction'], 0.4,
885
- 0.01
886
- ]
887
- }
922
+ 'paint': this.paintStyle(options)
888
923
  };
889
924
  }
890
925
  }