@abi-software/flatmap-viewer 2.2.1-beta.4 → 2.2.1-beta.5

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.4``
41
+ * ``npm install @abi-software/flatmap-viewer@2.2.1-beta.5``
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.4",
3
+ "version": "2.2.1-beta.5",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
@@ -634,12 +634,21 @@ export class UserInteractions
634
634
  tooltipHtml_(properties, forceLabel=false)
635
635
  //========================================
636
636
  {
637
- if ('label' in properties
637
+ if (('label' in properties || 'hyperlink' in properties)
638
638
  && (forceLabel || !('tooltip' in properties) || properties.tooltip)
639
639
  && !('labelled' in properties)) {
640
- const label = properties.label;
641
- const capitalisedLabel = label.substr(0, 1).toUpperCase() + label.substr(1);
642
- return `<div class='flatmap-feature-label'>${capitalisedLabel.replaceAll("\n", "<br/>")}</div>`;
640
+ let tooltip = '';
641
+ if ('label' in properties) {
642
+ const label = properties.label;
643
+ tooltip = (label.substr(0, 1).toUpperCase() + label.substr(1)).replaceAll("\n", "<br/>");
644
+ } else {
645
+ tooltip = properties.hyperlink
646
+ }
647
+ if ('hyperlink' in properties) {
648
+ return `<div class='flatmap-feature-label'><a href='{properties.hyperlink}'>${tooltip}</a></div>`;
649
+ } else {
650
+ return `<div class='flatmap-feature-label'>${tooltip}</div>`;
651
+ }
643
652
  }
644
653
  return '';
645
654
  }
@@ -733,7 +742,8 @@ export class UserInteractions
733
742
  }
734
743
  }
735
744
  } else {
736
- let labelledFeatures = features.filter(feature => (('label' in feature.properties
745
+ let labelledFeatures = features.filter(feature => (('hyperlink' in feature.properties
746
+ || 'label' in feature.properties
737
747
  || 'node' in feature.properties)
738
748
  && (!('tooltip' in feature.properties)
739
749
  || feature.properties.tooltip)))
@@ -781,6 +791,9 @@ export class UserInteractions
781
791
  this.activateNerveFeatures_(feature.properties.nerveId);
782
792
  }
783
793
  }
794
+ if ('hyperlink' in feature.properties) {
795
+ this._map.getCanvas().style.cursor = 'pointer';
796
+ }
784
797
  }
785
798
  }
786
799
 
@@ -849,6 +862,9 @@ export class UserInteractions
849
862
  if (feature !== undefined) {
850
863
  this.__lastClickLngLat = event.lngLat;
851
864
  this.__featureEvent('click', feature);
865
+ if ('hyperlink' in feature.properties) {
866
+ window.open(feature.properties.hyperlink, '_blank');
867
+ }
852
868
  }
853
869
  }
854
870