@abi-software/flatmap-viewer 2.2.1-beta.7 → 2.2.1-beta.9

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.2.1-beta.7``
41
+ * ``npm install @abi-software/flatmap-viewer@2.2.1-beta.9``
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.2.1-beta.7",
3
+ "version": "2.2.1-beta.9",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
@@ -1191,6 +1191,12 @@ export class MapManager
1191
1191
  mapOptions['pathControls'] = true;
1192
1192
  }
1193
1193
 
1194
+ // Mapmaker's changed the name of the field to indicate that indicates if
1195
+ // there are raster layers
1196
+ if (!('image-layers' in mapIndex) && ('image_layer' in mapIndex)) {
1197
+ mapIndex['image-layers'] = mapIndex['image_layer'];
1198
+ }
1199
+
1194
1200
  // Get details about the map's layers
1195
1201
 
1196
1202
  let mapLayers = [];
@@ -177,7 +177,7 @@ export class UserInteractions
177
177
  // Display a context menu on right-click
178
178
 
179
179
  this._lastContextTime = 0;
180
- this._contextMenu = new ContextMenu(flatmap, this.clearModal_.bind(this));
180
+ this._contextMenu = new ContextMenu(flatmap, this.__clearModal.bind(this));
181
181
  this._map.on('contextmenu', this.contextMenuEvent_.bind(this));
182
182
 
183
183
  // Display a context menu with a touch longer than 0.5 second
@@ -304,8 +304,8 @@ export class UserInteractions
304
304
  }
305
305
  }
306
306
 
307
- unselectFeatures_()
308
- //=================
307
+ __unselectFeatures()
308
+ //==================
309
309
  {
310
310
  for (const featureId of this._selectedFeatureIds.keys()) {
311
311
  const feature = this.mapFeature_(featureId);
@@ -421,8 +421,8 @@ export class UserInteractions
421
421
  this._modal = true;
422
422
  }
423
423
 
424
- clearModal_(event)
425
- //================
424
+ __clearModal(event)
425
+ //=================
426
426
  {
427
427
  this._modal = false;
428
428
  }
@@ -433,7 +433,7 @@ export class UserInteractions
433
433
  this._contextMenu.hide();
434
434
  const nodeId = event.target.getAttribute('featureId');
435
435
  this.enablePathFeatures_(enable, this._pathways.pathFeatureIds(nodeId));
436
- this.clearModal_();
436
+ this.__clearModal();
437
437
  }
438
438
 
439
439
  enablePathFeatures_(enable, featureIds)
@@ -464,9 +464,9 @@ export class UserInteractions
464
464
  reset()
465
465
  //=====
466
466
  {
467
- this.clearModal_();
467
+ this.__clearModal();
468
468
  this.clearActiveMarker_();
469
- this.unselectFeatures_();
469
+ this.__unselectFeatures();
470
470
  this.enablePathFeatures_(true, this._pathways.allFeatureIds());
471
471
  this._disabledPathFeatures = false;
472
472
  }
@@ -474,7 +474,7 @@ export class UserInteractions
474
474
  clearSearchResults(reset=true)
475
475
  //============================
476
476
  {
477
- this.unselectFeatures_();
477
+ this.__unselectFeatures();
478
478
  }
479
479
 
480
480
  /**
@@ -510,7 +510,7 @@ export class UserInteractions
510
510
  //========================
511
511
  {
512
512
  if (featureIds.length) {
513
- this.unselectFeatures_();
513
+ this.__unselectFeatures();
514
514
  for (const featureId of featureIds) {
515
515
  const annotation = this._flatmap.annotation(featureId);
516
516
  if (annotation) {
@@ -543,7 +543,7 @@ export class UserInteractions
543
543
  const padding = options.padding || 100;
544
544
  if (featureIds.length) {
545
545
  this.unhighlightFeatures_();
546
- if (select) this.unselectFeatures_();
546
+ if (select) this.__unselectFeatures();
547
547
  let bbox = null;
548
548
  for (const featureId of featureIds) {
549
549
  const annotation = this._flatmap.annotation(featureId);
@@ -590,7 +590,7 @@ export class UserInteractions
590
590
 
591
591
  // Highlight the feature
592
592
 
593
- this.unselectFeatures_();
593
+ this.__unselectFeatures();
594
594
  this.selectFeature_(featureId);
595
595
 
596
596
  // Find the pop-up's postion
@@ -612,7 +612,7 @@ export class UserInteractions
612
612
  }
613
613
  this.setModal_();
614
614
  this._currentPopup = new maplibre.Popup(options).addTo(this._map);
615
- this._currentPopup.on('close', this.clearModal_.bind(this));
615
+ this._currentPopup.on('close', this.__clearPopup.bind(this));
616
616
  this._currentPopup.setLngLat(location);
617
617
  if (typeof content === 'object') {
618
618
  this._currentPopup.setDOMContent(content);
@@ -622,6 +622,13 @@ export class UserInteractions
622
622
  }
623
623
  }
624
624
 
625
+ __clearPopup()
626
+ //============
627
+ {
628
+ this.__clearModal();
629
+ this.__unselectFeatures();
630
+ }
631
+
625
632
  removeTooltip_()
626
633
  //==============
627
634
  {
@@ -642,7 +649,10 @@ export class UserInteractions
642
649
  && !('labelled' in properties)) {
643
650
  let tooltip = '';
644
651
  const label = properties.label;
645
- tooltips.push((label.substr(0, 1).toUpperCase() + label.substr(1)).replaceAll("\n", "<br/>"));
652
+ const cleanLabel = (label.substr(0, 1).toUpperCase() + label.substr(1)).replaceAll("\n", "<br/>");
653
+ if (!tooltips.includes(cleanLabel)) {
654
+ tooltips.push(cleanLabel);
655
+ }
646
656
  }
647
657
  }
648
658
  if (tooltips.length === 0) {
@@ -684,36 +694,37 @@ export class UserInteractions
684
694
  return false;
685
695
  }
686
696
 
687
- mouseMoveEvent_(event)
688
- //====================
697
+ __resetFeatureDisplay()
698
+ //=====================
689
699
  {
690
- // No tooltip when context menu is open
691
-
692
- if (this._modal) {
693
- return;
694
- }
695
-
696
700
  // Remove any existing tooltip
697
-
698
701
  this.removeTooltip_();
699
702
 
700
703
  // Reset cursor
701
-
702
704
  this._map.getCanvas().style.cursor = 'default';
703
705
 
704
706
  // Reset any active features
705
-
706
707
  this.resetActiveFeatures_();
708
+ }
707
709
 
708
- // Reset any info display
710
+ mouseMoveEvent_(event)
711
+ //====================
712
+ {
713
+ // No tooltip when context menu is open
714
+ if (this._modal) {
715
+ return;
716
+ }
709
717
 
718
+ // Remove tooltip, reset active features, etc
719
+ this.__resetFeatureDisplay();
720
+
721
+ // Reset any info display
710
722
  const displayInfo = (this._infoControl && this._infoControl.active);
711
723
  if (displayInfo) {
712
724
  this._infoControl.reset()
713
725
  }
714
726
 
715
727
  // Get all the features at the current point
716
-
717
728
  const features = this._map.queryRenderedFeatures(event.point);
718
729
  if (features.length === 0) {
719
730
  this._lastFeatureMouseEntered = null;
@@ -806,11 +817,17 @@ export class UserInteractions
806
817
  }
807
818
  info = `<div id="info-control-info">${htmlList.join('\n')}</div>`;
808
819
  }
809
- this.activateFeature_(feature);
810
820
  if ('nerveId' in feature.properties) {
821
+ if (feature.properties.active) {
822
+ this.activateFeature_(feature);
823
+ } else {
824
+ tooltip = '';
825
+ }
811
826
  if (feature.properties.nerveId !== feature.properties.featureId) {
812
827
  this.activateNerveFeatures_(feature.properties.nerveId);
813
828
  }
829
+ } else {
830
+ this.activateFeature_(feature);
814
831
  }
815
832
  if ('hyperlink' in feature.properties) {
816
833
  this._map.getCanvas().style.cursor = 'pointer';
@@ -847,7 +864,7 @@ export class UserInteractions
847
864
  {
848
865
  const multipleSelect = event.ctrlKey || event.metaKey;
849
866
  if (!multipleSelect) {
850
- this.unselectFeatures_();
867
+ this.__unselectFeatures();
851
868
  }
852
869
  if (feature !== undefined) {
853
870
  const featureId = feature.id;
@@ -880,7 +897,12 @@ export class UserInteractions
880
897
  this.clearActiveMarker_();
881
898
  const feature = this._activeFeatures[0]
882
899
  this.selectionEvent_(event.originalEvent, feature);
883
- if (feature !== undefined) {
900
+ if (this._modal) {
901
+ // Remove tooltip, reset active features, etc
902
+ this.__resetFeatureDisplay();
903
+ this.__unselectFeatures();
904
+ this.__clearModal();
905
+ } else if (feature !== undefined) {
884
906
  this.__lastClickLngLat = event.lngLat;
885
907
  this.__featureEvent('click', feature);
886
908
  if ('hyperlink' in feature.properties) {
package/src/layers.js CHANGED
@@ -53,7 +53,7 @@ class MapFeatureLayer
53
53
  if (vectorFeatures) {
54
54
  this.__addStyleLayer(style.BodyLayer, layerOptions);
55
55
  }
56
- if (flatmap.details['image_layer']) {
56
+ if (flatmap.details['image-layers']) {
57
57
  for (const raster_layer_id of layer['image-layers']) {
58
58
  this.__addRasterLayer(raster_layer_id, layerOptions);
59
59
  }
@@ -164,7 +164,7 @@ export class LayerManager
164
164
  this.__map.addLayer(backgroundLayer.style('white'));
165
165
  }
166
166
  // Add the map's layers
167
- if (fcDiagram && flatmap.details['image_layer']) {
167
+ if (fcDiagram && flatmap.details['image-layers']) {
168
168
  for (const layer of flatmap.layers) {
169
169
  for (const raster_layer_id of layer['image-layers']) {
170
170
  const rasterLayer = new style.RasterLayer(raster_layer_id);
package/src/styling.js CHANGED
@@ -239,7 +239,7 @@ export class FeatureLineLayer extends VectorStyleLayer
239
239
  constructor(id, sourceLayer, dashed=false)
240
240
  {
241
241
  const filterType = dashed ? 'line-dash' : 'line';
242
- super(id, `divider-${filterType}`, sourceLayer);
242
+ super(id, `feature-${filterType}`, sourceLayer);
243
243
  this.__filter = dashed ?
244
244
  [
245
245
  'any',
@@ -248,6 +248,7 @@ export class FeatureLineLayer extends VectorStyleLayer
248
248
  :
249
249
  [
250
250
  'any',
251
+ ['has', 'centreline'],
251
252
  ['==', 'type', 'bezier'],
252
253
  ['==', 'type', `line`]
253
254
  ];
@@ -333,7 +334,7 @@ export class PathLineLayer extends VectorStyleLayer
333
334
  constructor(id, sourceLayer, dashed=false)
334
335
  {
335
336
  const filterType = dashed ? 'line-dash' : 'line';
336
- super(id, filterType, sourceLayer);
337
+ super(id, `path-${filterType}`, sourceLayer);
337
338
  this.__filter = dashed ?
338
339
  [
339
340
  'any',
@@ -453,7 +454,8 @@ export class FeatureNerveLayer extends VectorStyleLayer
453
454
  ['boolean', ['feature-state', 'active'], false], '#222',
454
455
  ['boolean', ['feature-state', 'selected'], false], 'red',
455
456
  ['boolean', ['feature-state', 'hidden'], false], '#CCC',
456
- '#888'
457
+ ['boolean', ['get', 'active'], false], '#888',
458
+ '#FFF'
457
459
  ],
458
460
  'line-opacity': [
459
461
  'case',