@abi-software/flatmap-viewer 2.2.1-beta.3 → 2.2.1-beta.6
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 +1 -1
- package/package.json +2 -1
- package/src/interactions.js +50 -13
- package/src/layers.js +6 -3
- package/src/styling.js +6 -4
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.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.2.1-beta.6``
|
|
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.
|
|
3
|
+
"version": "2.2.1-beta.6",
|
|
4
4
|
"description": "Flatmap viewer using Maplibre GL",
|
|
5
5
|
"repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"@turf/area": "^6.0.1",
|
|
22
22
|
"@turf/bbox": "^6.0.1",
|
|
23
23
|
"@turf/helpers": "^6.1.4",
|
|
24
|
+
"bezier-js": "^6.1.0",
|
|
24
25
|
"maplibre-gl": ">=1.15.3",
|
|
25
26
|
"minisearch": "^2.2.1",
|
|
26
27
|
"polylabel": "^1.1.0"
|
package/src/interactions.js
CHANGED
|
@@ -631,15 +631,44 @@ export class UserInteractions
|
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
633
|
|
|
634
|
+
lineTooltip_(lineFeatures)
|
|
635
|
+
//========================
|
|
636
|
+
{
|
|
637
|
+
const tooltips = [];
|
|
638
|
+
for (const lineFeature of lineFeatures) {
|
|
639
|
+
const properties = lineFeature.properties;
|
|
640
|
+
if ('label' in properties
|
|
641
|
+
&& (!('tooltip' in properties) || properties.tooltip)
|
|
642
|
+
&& !('labelled' in properties)) {
|
|
643
|
+
let tooltip = '';
|
|
644
|
+
const label = properties.label;
|
|
645
|
+
tooltips.push((label.substr(0, 1).toUpperCase() + label.substr(1)).replaceAll("\n", "<br/>"));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (tooltips.length === 0) {
|
|
649
|
+
return '';
|
|
650
|
+
}
|
|
651
|
+
return tooltips.join('<hr/>');
|
|
652
|
+
}
|
|
653
|
+
|
|
634
654
|
tooltipHtml_(properties, forceLabel=false)
|
|
635
655
|
//========================================
|
|
636
656
|
{
|
|
637
|
-
if ('label' in properties
|
|
657
|
+
if (('label' in properties || 'hyperlink' in properties)
|
|
638
658
|
&& (forceLabel || !('tooltip' in properties) || properties.tooltip)
|
|
639
659
|
&& !('labelled' in properties)) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
660
|
+
let tooltip = '';
|
|
661
|
+
if ('label' in properties) {
|
|
662
|
+
const label = properties.label;
|
|
663
|
+
tooltip = (label.substr(0, 1).toUpperCase() + label.substr(1)).replaceAll("\n", "<br/>");
|
|
664
|
+
} else {
|
|
665
|
+
tooltip = properties.hyperlink
|
|
666
|
+
}
|
|
667
|
+
if ('hyperlink' in properties) {
|
|
668
|
+
return `<div class='flatmap-feature-label'><a href='{properties.hyperlink}'>${tooltip}</a></div>`;
|
|
669
|
+
} else {
|
|
670
|
+
return `<div class='flatmap-feature-label'>${tooltip}</div>`;
|
|
671
|
+
}
|
|
643
672
|
}
|
|
644
673
|
return '';
|
|
645
674
|
}
|
|
@@ -722,18 +751,20 @@ export class UserInteractions
|
|
|
722
751
|
&& feature.properties.type.startsWith('line'))
|
|
723
752
|
|| 'centreline' in feature.properties));
|
|
724
753
|
if (lineFeatures.length > 0) {
|
|
725
|
-
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
754
|
+
tooltip = this.lineTooltip_(lineFeatures);
|
|
755
|
+
for (const lineFeature of lineFeatures) {
|
|
756
|
+
const lineFeatureId = +lineFeature.properties.featureId; // Ensure numeric
|
|
757
|
+
this.activateFeature_(lineFeature);
|
|
758
|
+
const lineIds = new Set(lineFeatures.map(f => f.properties.featureId));
|
|
759
|
+
for (const featureId of this._pathways.lineFeatureIds(lineIds)) {
|
|
760
|
+
if (+featureId !== lineFeatureId) {
|
|
761
|
+
this.activateFeature_(this.mapFeature_(featureId));
|
|
762
|
+
}
|
|
733
763
|
}
|
|
734
764
|
}
|
|
735
765
|
} else {
|
|
736
|
-
let labelledFeatures = features.filter(feature => (('
|
|
766
|
+
let labelledFeatures = features.filter(feature => (('hyperlink' in feature.properties
|
|
767
|
+
|| 'label' in feature.properties
|
|
737
768
|
|| 'node' in feature.properties)
|
|
738
769
|
&& (!('tooltip' in feature.properties)
|
|
739
770
|
|| feature.properties.tooltip)))
|
|
@@ -781,6 +812,9 @@ export class UserInteractions
|
|
|
781
812
|
this.activateNerveFeatures_(feature.properties.nerveId);
|
|
782
813
|
}
|
|
783
814
|
}
|
|
815
|
+
if ('hyperlink' in feature.properties) {
|
|
816
|
+
this._map.getCanvas().style.cursor = 'pointer';
|
|
817
|
+
}
|
|
784
818
|
}
|
|
785
819
|
}
|
|
786
820
|
|
|
@@ -849,6 +883,9 @@ export class UserInteractions
|
|
|
849
883
|
if (feature !== undefined) {
|
|
850
884
|
this.__lastClickLngLat = event.lngLat;
|
|
851
885
|
this.__featureEvent('click', feature);
|
|
886
|
+
if ('hyperlink' in feature.properties) {
|
|
887
|
+
window.open(feature.properties.hyperlink, '_blank');
|
|
888
|
+
}
|
|
852
889
|
}
|
|
853
890
|
}
|
|
854
891
|
|
package/src/layers.js
CHANGED
|
@@ -152,15 +152,18 @@ export class LayerManager
|
|
|
152
152
|
this.__activeLayers = [];
|
|
153
153
|
this.__activeLayerNames = [];
|
|
154
154
|
this.__rasterLayers = [];
|
|
155
|
+
const layerOptions = flatmap.options.layerOptions;
|
|
156
|
+
const fcDiagram = ('style' in layerOptions && layerOptions.style == 'fcdiagram');
|
|
155
157
|
const backgroundLayer = new style.BackgroundLayer();
|
|
156
|
-
if (
|
|
158
|
+
if (fcDiagram) {
|
|
159
|
+
this.__map.addLayer(backgroundLayer.style('black', 1));
|
|
160
|
+
}
|
|
161
|
+
else if ('background' in flatmap.options) {
|
|
157
162
|
this.__map.addLayer(backgroundLayer.style(flatmap.options.background));
|
|
158
163
|
} else {
|
|
159
164
|
this.__map.addLayer(backgroundLayer.style('white'));
|
|
160
165
|
}
|
|
161
166
|
// Add the map's layers
|
|
162
|
-
const layerOptions = flatmap.options.layerOptions;
|
|
163
|
-
const fcDiagram = ('style' in layerOptions && layerOptions.style == 'fcdiagram');
|
|
164
167
|
if (fcDiagram && flatmap.details['image_layer']) {
|
|
165
168
|
for (const layer of flatmap.layers) {
|
|
166
169
|
for (const raster_layer_id of layer['image-layers']) {
|
package/src/styling.js
CHANGED
|
@@ -117,9 +117,9 @@ export class FeatureFillLayer extends VectorStyleLayer
|
|
|
117
117
|
const paintStyle = {
|
|
118
118
|
'fill-color': [
|
|
119
119
|
'case',
|
|
120
|
+
['boolean', ['feature-state', 'selected'], false], '#0F0',
|
|
120
121
|
['has', 'colour'], ['get', 'colour'],
|
|
121
122
|
['boolean', ['feature-state', 'active'], false], coloured ? '#D88' : '#CCC',
|
|
122
|
-
['boolean', ['feature-state', 'selected'], false], '#0F0',
|
|
123
123
|
['any',
|
|
124
124
|
['==', ['get', 'kind'], 'scaffold']
|
|
125
125
|
], 'white',
|
|
@@ -260,15 +260,16 @@ export class FeatureLineLayer extends VectorStyleLayer
|
|
|
260
260
|
const paintStyle = {
|
|
261
261
|
'line-color': [
|
|
262
262
|
'case',
|
|
263
|
+
['boolean', ['feature-state', 'selected'], false], '#0F0',
|
|
263
264
|
['has', 'colour'], ['get', 'colour'],
|
|
264
265
|
['boolean', ['feature-state', 'active'], false], coloured ? '#D88' : '#CCC',
|
|
265
|
-
['boolean', ['feature-state', 'selected'], false], '#0F0',
|
|
266
266
|
['==', ['get', 'type'], 'network'], '#AFA202',
|
|
267
267
|
['has', 'centreline'], '#888',
|
|
268
268
|
('style' in options && options.style === 'authoring') ? '#C44' : '#444'
|
|
269
269
|
],
|
|
270
270
|
'line-opacity': [
|
|
271
271
|
'case',
|
|
272
|
+
['boolean', ['feature-state', 'selected'], false], 1.0,
|
|
272
273
|
['boolean', ['feature-state', 'active'], false], 1.0,
|
|
273
274
|
0.3
|
|
274
275
|
],
|
|
@@ -278,6 +279,7 @@ export class FeatureLineLayer extends VectorStyleLayer
|
|
|
278
279
|
'case',
|
|
279
280
|
['has', 'centreline'], 1.2,
|
|
280
281
|
['==', ['get', 'type'], 'network'], 1.2,
|
|
282
|
+
['boolean', ['feature-state', 'selected'], false], 1.2,
|
|
281
283
|
['boolean', ['feature-state', 'active'], false], 1.2,
|
|
282
284
|
('style' in options && options.style === 'authoring') ? 0.7 : 0.5
|
|
283
285
|
], [
|
|
@@ -674,14 +676,14 @@ export class BackgroundLayer
|
|
|
674
676
|
return this.__id;
|
|
675
677
|
}
|
|
676
678
|
|
|
677
|
-
style(backgroundColour)
|
|
679
|
+
style(backgroundColour, opacity=0.1)
|
|
678
680
|
{
|
|
679
681
|
return {
|
|
680
682
|
'id': this.__id,
|
|
681
683
|
'type': 'background',
|
|
682
684
|
'paint': {
|
|
683
685
|
'background-color': backgroundColour,
|
|
684
|
-
'background-opacity':
|
|
686
|
+
'background-opacity': opacity
|
|
685
687
|
}
|
|
686
688
|
};
|
|
687
689
|
}
|