@abi-software/flatmap-viewer 2.2.1-beta.6 → 2.2.1-beta.8

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.6``
41
+ * ``npm install @abi-software/flatmap-viewer@2.2.1-beta.8``
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.6",
3
+ "version": "2.2.1-beta.8",
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
  {
@@ -648,7 +655,7 @@ export class UserInteractions
648
655
  if (tooltips.length === 0) {
649
656
  return '';
650
657
  }
651
- return tooltips.join('<hr/>');
658
+ return `<div class='flatmap-feature-label'>${tooltips.join('<hr/>')}</div>`;
652
659
  }
653
660
 
654
661
  tooltipHtml_(properties, forceLabel=false)
@@ -684,36 +691,37 @@ export class UserInteractions
684
691
  return false;
685
692
  }
686
693
 
687
- mouseMoveEvent_(event)
688
- //====================
694
+ __resetFeatureDisplay()
695
+ //=====================
689
696
  {
690
- // No tooltip when context menu is open
691
-
692
- if (this._modal) {
693
- return;
694
- }
695
-
696
697
  // Remove any existing tooltip
697
-
698
698
  this.removeTooltip_();
699
699
 
700
700
  // Reset cursor
701
-
702
701
  this._map.getCanvas().style.cursor = 'default';
703
702
 
704
703
  // Reset any active features
705
-
706
704
  this.resetActiveFeatures_();
705
+ }
707
706
 
708
- // Reset any info display
707
+ mouseMoveEvent_(event)
708
+ //====================
709
+ {
710
+ // No tooltip when context menu is open
711
+ if (this._modal) {
712
+ return;
713
+ }
714
+
715
+ // Remove tooltip, reset active features, etc
716
+ this.__resetFeatureDisplay();
709
717
 
718
+ // Reset any info display
710
719
  const displayInfo = (this._infoControl && this._infoControl.active);
711
720
  if (displayInfo) {
712
721
  this._infoControl.reset()
713
722
  }
714
723
 
715
724
  // Get all the features at the current point
716
-
717
725
  const features = this._map.queryRenderedFeatures(event.point);
718
726
  if (features.length === 0) {
719
727
  this._lastFeatureMouseEntered = null;
@@ -847,7 +855,7 @@ export class UserInteractions
847
855
  {
848
856
  const multipleSelect = event.ctrlKey || event.metaKey;
849
857
  if (!multipleSelect) {
850
- this.unselectFeatures_();
858
+ this.__unselectFeatures();
851
859
  }
852
860
  if (feature !== undefined) {
853
861
  const featureId = feature.id;
@@ -880,7 +888,12 @@ export class UserInteractions
880
888
  this.clearActiveMarker_();
881
889
  const feature = this._activeFeatures[0]
882
890
  this.selectionEvent_(event.originalEvent, feature);
883
- if (feature !== undefined) {
891
+ if (this._modal) {
892
+ // Remove tooltip, reset active features, etc
893
+ this.__resetFeatureDisplay();
894
+ this.__unselectFeatures();
895
+ this.__clearModal();
896
+ } else if (feature !== undefined) {
884
897
  this.__lastClickLngLat = event.lngLat;
885
898
  this.__featureEvent('click', feature);
886
899
  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',