@abi-software/flatmap-viewer 2.3.2-b.3 → 2.3.3-b.1
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 +1 -1
- package/src/annotation.js +2 -0
- package/src/controls/controls.js +67 -0
- package/src/interactions.js +11 -2
- package/src/pathways.js +8 -0
- package/src/styling.js +7 -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.3.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.3.3-b.1``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
package/src/annotation.js
CHANGED
|
@@ -475,6 +475,8 @@ export class Annotator
|
|
|
475
475
|
let label = '';
|
|
476
476
|
if (feature.properties.models) {
|
|
477
477
|
label = ` -- ${feature.properties.label.split('\n')[0]} (${feature.properties.models})`;
|
|
478
|
+
} else if (feature.properties.label) {
|
|
479
|
+
label = ` -- ${feature.properties.label.split('\n')[0]}`;
|
|
478
480
|
}
|
|
479
481
|
featureList.push(`<option value="${feature.id}" ${selected}>${annotated ? '*' : ' '} ${feature.properties.id} -- ${feature.properties.kind}${label}</option>`);
|
|
480
482
|
featureProperties.set(+feature.id, feature.properties);
|
package/src/controls/controls.js
CHANGED
|
@@ -526,6 +526,73 @@ export class NerveControl
|
|
|
526
526
|
|
|
527
527
|
//==============================================================================
|
|
528
528
|
|
|
529
|
+
export class AnnotatedControl
|
|
530
|
+
{
|
|
531
|
+
constructor(ui, options={excludeAnnotated: false})
|
|
532
|
+
{
|
|
533
|
+
this.__ui = ui;
|
|
534
|
+
this.__map = undefined;
|
|
535
|
+
this.__exclude = options.excludeAnnotated || false;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
getDefaultPosition()
|
|
539
|
+
//==================
|
|
540
|
+
{
|
|
541
|
+
return 'top-right';
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
onAdd(map)
|
|
545
|
+
//========
|
|
546
|
+
{
|
|
547
|
+
this.__map = map;
|
|
548
|
+
this.__container = document.createElement('div');
|
|
549
|
+
this.__container.className = 'maplibregl-ctrl';
|
|
550
|
+
|
|
551
|
+
this.__button = document.createElement('button');
|
|
552
|
+
this.__button.id = 'map-annotated-button';
|
|
553
|
+
this.__button.className = 'control-button text-button';
|
|
554
|
+
this.__button.setAttribute('type', 'button');
|
|
555
|
+
this.__button.setAttribute('aria-label', 'Show/hide annotated paths');
|
|
556
|
+
this.__button.textContent = 'UNANN';
|
|
557
|
+
this.__button.title = 'Show/hide annotated paths';
|
|
558
|
+
this.__container.appendChild(this.__button);
|
|
559
|
+
|
|
560
|
+
this.__container.addEventListener('click', this.onClick_.bind(this));
|
|
561
|
+
this.__setBackground();
|
|
562
|
+
return this.__container;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
__setBackground()
|
|
566
|
+
//===============
|
|
567
|
+
{
|
|
568
|
+
if (this.__exclude) {
|
|
569
|
+
this.__button.setAttribute('style', 'background: red');
|
|
570
|
+
} else {
|
|
571
|
+
this.__button.removeAttribute('style');
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
onRemove()
|
|
576
|
+
//========
|
|
577
|
+
{
|
|
578
|
+
this.__container.parentNode.removeChild(this.__container);
|
|
579
|
+
this.__map = undefined;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
onClick_(event)
|
|
583
|
+
//=============
|
|
584
|
+
{
|
|
585
|
+
if (event.target.id === 'map-annotated-button') {
|
|
586
|
+
this.__exclude = !this.__exclude;
|
|
587
|
+
this.__setBackground();
|
|
588
|
+
this.__ui.excludeAnnotated(this.__exclude);
|
|
589
|
+
}
|
|
590
|
+
event.stopPropagation();
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
//==============================================================================
|
|
595
|
+
|
|
529
596
|
export class BackgroundControl
|
|
530
597
|
{
|
|
531
598
|
constructor(flatmap)
|
package/src/interactions.js
CHANGED
|
@@ -40,7 +40,7 @@ import {VECTOR_TILES_SOURCE} from './styling';
|
|
|
40
40
|
import {SystemsManager} from './systems';
|
|
41
41
|
|
|
42
42
|
import {displayedProperties, InfoControl} from './controls/info';
|
|
43
|
-
import {BackgroundControl, LayerControl, NerveControl,
|
|
43
|
+
import {AnnotatedControl, BackgroundControl, LayerControl, NerveControl,
|
|
44
44
|
SCKANControl} from './controls/controls';
|
|
45
45
|
import {PathControl} from './controls/paths';
|
|
46
46
|
import {SearchControl} from './controls/search';
|
|
@@ -146,6 +146,9 @@ export class UserInteractions
|
|
|
146
146
|
for (const path of mapPathTypes) {
|
|
147
147
|
this.__pathManager.enablePathsByType(path.type, path.enabled, true);
|
|
148
148
|
}
|
|
149
|
+
if (this.__pathManager.haveCentrelines) {
|
|
150
|
+
this.enableCentrelines(this.__pathManager.enabledCentrelines, true);
|
|
151
|
+
}
|
|
149
152
|
|
|
150
153
|
// Add annotation capability
|
|
151
154
|
if (flatmap.options.annotator) {
|
|
@@ -180,13 +183,13 @@ export class UserInteractions
|
|
|
180
183
|
// Add a control for nerve centrelines if they are present
|
|
181
184
|
if (this.__pathManager.haveCentrelines) {
|
|
182
185
|
this._map.addControl(new NerveControl(flatmap, this._layerManager, {showCentrelines: false}));
|
|
183
|
-
this.enableCentrelines(false, true);
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
// SCKAN path and SYSTEMS controls for FC maps
|
|
187
189
|
if (flatmap.options.style === 'functional') {
|
|
188
190
|
this._map.addControl(new SystemsControl(flatmap, this.__systemsManager.systems));
|
|
189
191
|
this._map.addControl(new SCKANControl(flatmap, flatmap.options.layerOptions));
|
|
192
|
+
this._map.addControl(new AnnotatedControl(this, flatmap.options.layerOptions));
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
|
|
@@ -1094,6 +1097,12 @@ export class UserInteractions
|
|
|
1094
1097
|
this._layerManager.enableSckanPaths(sckanState, enable);
|
|
1095
1098
|
}
|
|
1096
1099
|
|
|
1100
|
+
excludeAnnotated(exclude=false)
|
|
1101
|
+
//=============================
|
|
1102
|
+
{
|
|
1103
|
+
this._layerManager.setPaint({excludeAnnotated: exclude});
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1097
1106
|
//==============================================================================
|
|
1098
1107
|
|
|
1099
1108
|
// Marker handling
|
package/src/pathways.js
CHANGED
|
@@ -126,6 +126,7 @@ export class PathManager
|
|
|
126
126
|
|
|
127
127
|
// Nerve centrelines are a special case with their own controls
|
|
128
128
|
this.__haveCentrelines = false;
|
|
129
|
+
this.__enabledCentrelines = false;
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
get haveCentrelines()
|
|
@@ -134,6 +135,12 @@ export class PathManager
|
|
|
134
135
|
return this.__haveCentrelines;
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
get enabledCentrelines()
|
|
139
|
+
//======================
|
|
140
|
+
{
|
|
141
|
+
return this.__enabledCentrelines;
|
|
142
|
+
}
|
|
143
|
+
|
|
137
144
|
__assignPathTypes()
|
|
138
145
|
//=================
|
|
139
146
|
{
|
|
@@ -153,6 +160,7 @@ export class PathManager
|
|
|
153
160
|
&& this.__pathsByType[pathTypeDefn.type].length > 0) {
|
|
154
161
|
if (pathTypeDefn.type === 'centreline') {
|
|
155
162
|
this.__haveCentrelines = true;
|
|
163
|
+
this.__enabledCentrelines = this.__pathtypeEnabled[pathTypeDefn.type];
|
|
156
164
|
} else {
|
|
157
165
|
pathTypes.push({
|
|
158
166
|
...pathTypeDefn,
|
package/src/styling.js
CHANGED
|
@@ -418,23 +418,24 @@ export class AnnotatedPathLayer extends VectorStyleLayer
|
|
|
418
418
|
|
|
419
419
|
paintStyle(options={}, changes=false)
|
|
420
420
|
{
|
|
421
|
-
const
|
|
421
|
+
const exclude = 'excludeAnnotated' in options && options.excludeAnnotated;
|
|
422
422
|
const paintStyle = {
|
|
423
423
|
'line-color': COLOUR_ANNOTATED,
|
|
424
424
|
'line-dasharray': [5, 0.5, 3, 0.5],
|
|
425
425
|
'line-opacity': [
|
|
426
426
|
'case',
|
|
427
427
|
['boolean', ['feature-state', 'hidden'], false], 0.05,
|
|
428
|
-
|
|
429
|
-
(
|
|
428
|
+
['boolean', ['feature-state', 'annotated'], false],
|
|
429
|
+
(exclude ? 0.05 : 0.8),
|
|
430
430
|
0.6
|
|
431
431
|
],
|
|
432
432
|
'line-width': [
|
|
433
433
|
'let',
|
|
434
434
|
'width',
|
|
435
435
|
['case',
|
|
436
|
+
['boolean', ['feature-state', 'hidden'], false], 0.0,
|
|
436
437
|
['boolean', ['feature-state', 'annotated'], false],
|
|
437
|
-
['*', 1.2, ['case', ['has', 'stroke-width'], ['get', 'stroke-width'], 1.0]],
|
|
438
|
+
exclude ? 0.0 : (['*', 1.2, ['case', ['has', 'stroke-width'], ['get', 'stroke-width'], 1.0]]),
|
|
438
439
|
0.0
|
|
439
440
|
],
|
|
440
441
|
STROKE_INTERPOLATION
|
|
@@ -498,6 +499,7 @@ export class PathLineLayer extends VectorStyleLayer
|
|
|
498
499
|
paintStyle(options={}, changes=false)
|
|
499
500
|
{
|
|
500
501
|
const dimmed = 'dimmed' in options && options.dimmed;
|
|
502
|
+
const exclude = 'excludeAnnotated' in options && options.excludeAnnotated;
|
|
501
503
|
const paintStyle = {
|
|
502
504
|
'line-color': [
|
|
503
505
|
'case',
|
|
@@ -544,6 +546,7 @@ export class PathLineLayer extends VectorStyleLayer
|
|
|
544
546
|
['boolean', ['feature-state', 'active'], false], 0.0,
|
|
545
547
|
0.6
|
|
546
548
|
],
|
|
549
|
+
['case', ['boolean', ['feature-state', 'annotated'], false], (exclude ? 0.0 : 1.0), 1.0],
|
|
547
550
|
['case', ['has', 'stroke-width'], ['get', 'stroke-width'], 1.0]
|
|
548
551
|
],
|
|
549
552
|
STROKE_INTERPOLATION
|