@abi-software/flatmap-viewer 2.2.1-beta.8 → 2.2.2-beta.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/controls.js +42 -50
- package/src/flatmap-viewer.js +17 -2
- package/src/interactions.js +20 -9
- package/src/styling.js +3 -2
- package/static/flatmap-viewer.css +9 -3
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.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.2.2-beta.1``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
package/src/controls.js
CHANGED
|
@@ -75,7 +75,7 @@ export class NavigationControl
|
|
|
75
75
|
|
|
76
76
|
//==============================================================================
|
|
77
77
|
|
|
78
|
-
export class
|
|
78
|
+
export class PathControl
|
|
79
79
|
{
|
|
80
80
|
constructor(flatmap)
|
|
81
81
|
{
|
|
@@ -102,10 +102,13 @@ export class NerveKey
|
|
|
102
102
|
this._legend.className = 'flatmap-nerve-grid';
|
|
103
103
|
|
|
104
104
|
const innerHTML = [];
|
|
105
|
+
innerHTML.push(`<label for="path-all-paths">ALL PATHS:</label><input id="path-all-paths" type="checkbox" checked/><div class="nerve-line"></div>`);
|
|
105
106
|
for (const path of pathways.PATH_TYPES) {
|
|
106
|
-
innerHTML.push(`<
|
|
107
|
+
innerHTML.push(`<label for="path-${path.type}">${path.label}</label><input id="path-${path.type}" type="checkbox" checked/><div class="nerve-line nerve-${path.type}"></div>`);
|
|
107
108
|
}
|
|
108
109
|
this._legend.innerHTML = innerHTML.join('\n');
|
|
110
|
+
this.__checkedCount = pathways.PATH_TYPES.length;
|
|
111
|
+
this.__halfCount = Math.trunc(this.__checkedCount/2);
|
|
109
112
|
|
|
110
113
|
this._button = document.createElement('button');
|
|
111
114
|
this._button.id = 'nerve-key-button';
|
|
@@ -114,7 +117,7 @@ export class NerveKey
|
|
|
114
117
|
this._button.setAttribute('type', 'button');
|
|
115
118
|
this._button.setAttribute('aria-label', 'Nerve paths legend');
|
|
116
119
|
this._button.setAttribute('legend-visible', 'false');
|
|
117
|
-
this._button.textContent = '
|
|
120
|
+
this._button.textContent = 'PTH';
|
|
118
121
|
this._container.appendChild(this._button);
|
|
119
122
|
|
|
120
123
|
this._container.addEventListener('click', this.onClick_.bind(this));
|
|
@@ -140,10 +143,42 @@ export class NerveKey
|
|
|
140
143
|
this._legend = this._container.removeChild(this._legend);
|
|
141
144
|
this._button.setAttribute('legend-visible', 'false');
|
|
142
145
|
}
|
|
143
|
-
} else {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
} else if (event.target.tagName === 'INPUT') {
|
|
147
|
+
if (event.target.id === 'path-all-paths') {
|
|
148
|
+
if (event.target.indeterminate) {
|
|
149
|
+
event.target.checked = (this.__checkedCount >= this.__halfCount);
|
|
150
|
+
event.target.indeterminate = false;
|
|
151
|
+
}
|
|
152
|
+
if (event.target.checked) {
|
|
153
|
+
this.__checkedCount = pathways.PATH_TYPES.length;
|
|
154
|
+
} else {
|
|
155
|
+
this.__checkedCount = 0;
|
|
156
|
+
}
|
|
157
|
+
for (const path of pathways.PATH_TYPES) {
|
|
158
|
+
const pathCheckbox = document.getElementById(`path-${path.type}`);
|
|
159
|
+
if (pathCheckbox) {
|
|
160
|
+
pathCheckbox.checked = event.target.checked;
|
|
161
|
+
this._flatmap.enablePath(path.type, event.target.checked);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
} else if (event.target.id.startsWith('path-')) {
|
|
165
|
+
const pathType = event.target.id.substring(5);
|
|
166
|
+
this._flatmap.enablePath(pathType, event.target.checked);
|
|
167
|
+
if (event.target.checked) {
|
|
168
|
+
this.__checkedCount += 1;
|
|
169
|
+
} else {
|
|
170
|
+
this.__checkedCount -= 1;
|
|
171
|
+
}
|
|
172
|
+
const allPathsCheckbox = document.getElementById('path-all-paths');
|
|
173
|
+
if (this.__checkedCount === 0) {
|
|
174
|
+
allPathsCheckbox.checked = false;
|
|
175
|
+
allPathsCheckbox.indeterminate = false;
|
|
176
|
+
} else if (this.__checkedCount === pathways.PATH_TYPES.length) {
|
|
177
|
+
allPathsCheckbox.checked = true;
|
|
178
|
+
allPathsCheckbox.indeterminate = false;
|
|
179
|
+
} else {
|
|
180
|
+
allPathsCheckbox.indeterminate = true;
|
|
181
|
+
}
|
|
147
182
|
}
|
|
148
183
|
}
|
|
149
184
|
event.stopPropagation();
|
|
@@ -151,46 +186,3 @@ export class NerveKey
|
|
|
151
186
|
}
|
|
152
187
|
|
|
153
188
|
//==============================================================================
|
|
154
|
-
|
|
155
|
-
export class PathControl
|
|
156
|
-
{
|
|
157
|
-
constructor(flatmap)
|
|
158
|
-
{
|
|
159
|
-
this._flatmap = flatmap;
|
|
160
|
-
this._map = undefined;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
getDefaultPosition()
|
|
164
|
-
//==================
|
|
165
|
-
{
|
|
166
|
-
return 'top-right';
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
onAdd(map)
|
|
170
|
-
//========
|
|
171
|
-
{
|
|
172
|
-
this._map = map;
|
|
173
|
-
this._container = document.createElement('div');
|
|
174
|
-
this._container.className = 'maplibregl-ctrl';
|
|
175
|
-
this._container.id = 'flatmap-path-control';
|
|
176
|
-
this._container.innerHTML = `<button class="control-button" id="path-control-button"
|
|
177
|
-
type="button" title="Show/hide paths" aria-label="Show/hide paths">PTH</button>`;
|
|
178
|
-
this._container.onclick = this.onClick_.bind(this);
|
|
179
|
-
return this._container;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
onRemove()
|
|
183
|
-
//========
|
|
184
|
-
{
|
|
185
|
-
this._container.parentNode.removeChild(this._container);
|
|
186
|
-
this._map = undefined;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
onClick_(event)
|
|
190
|
-
//=============
|
|
191
|
-
{
|
|
192
|
-
this._flatmap.togglePaths();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
//==============================================================================
|
package/src/flatmap-viewer.js
CHANGED
|
@@ -283,12 +283,27 @@ class FlatMap
|
|
|
283
283
|
return pathways.PATH_TYPES;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Hide or show paths of a given type.
|
|
288
|
+
*
|
|
289
|
+
* @param {string} pathType The path type
|
|
290
|
+
* @param {boolean} [enable=true] If ``true`` then only show the paths
|
|
291
|
+
* of the type otherwise only hide the paths
|
|
292
|
+
*/
|
|
293
|
+
enablePath(pathType, enable=true)
|
|
294
|
+
//===============================
|
|
295
|
+
{
|
|
296
|
+
if (this._userInteractions !== null) {
|
|
297
|
+
this._userInteractions.enablePath(pathType, enable);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
286
301
|
/**
|
|
287
302
|
* Hide or show all paths except those of the given type.
|
|
288
303
|
*
|
|
289
304
|
* @param {string|Array.<string>} pathTypes The path type(s)
|
|
290
|
-
* @param {boolean} [enable=true] If ``true`` then only show the
|
|
291
|
-
* type(s) otherwise only hide the
|
|
305
|
+
* @param {boolean} [enable=true] If ``true`` then only show the paths
|
|
306
|
+
* of the type(s) otherwise only hide the paths
|
|
292
307
|
*/
|
|
293
308
|
showPaths(pathTypes, enable=true)
|
|
294
309
|
//===============================
|
package/src/interactions.js
CHANGED
|
@@ -37,7 +37,7 @@ import {displayedProperties} from './info.js';
|
|
|
37
37
|
import {InfoControl} from './info.js';
|
|
38
38
|
import {LayerManager} from './layers.js';
|
|
39
39
|
import {PATHWAYS_LAYER, Pathways} from './pathways.js';
|
|
40
|
-
import {
|
|
40
|
+
import {PathControl} from './controls.js';
|
|
41
41
|
import {SearchControl} from './search.js';
|
|
42
42
|
import {VECTOR_TILES_SOURCE} from './styling.js';
|
|
43
43
|
|
|
@@ -152,10 +152,6 @@ export class UserInteractions
|
|
|
152
152
|
// Add controls to manage our pathways
|
|
153
153
|
|
|
154
154
|
this._map.addControl(new PathControl(flatmap));
|
|
155
|
-
|
|
156
|
-
// Add a key showing nerve types
|
|
157
|
-
|
|
158
|
-
this._map.addControl(new NerveKey(flatmap));
|
|
159
155
|
}
|
|
160
156
|
|
|
161
157
|
// Manage our layers
|
|
@@ -649,7 +645,10 @@ export class UserInteractions
|
|
|
649
645
|
&& !('labelled' in properties)) {
|
|
650
646
|
let tooltip = '';
|
|
651
647
|
const label = properties.label;
|
|
652
|
-
|
|
648
|
+
const cleanLabel = (label.substr(0, 1).toUpperCase() + label.substr(1)).replaceAll("\n", "<br/>");
|
|
649
|
+
if (!tooltips.includes(cleanLabel)) {
|
|
650
|
+
tooltips.push(cleanLabel);
|
|
651
|
+
}
|
|
653
652
|
}
|
|
654
653
|
}
|
|
655
654
|
if (tooltips.length === 0) {
|
|
@@ -814,11 +813,17 @@ export class UserInteractions
|
|
|
814
813
|
}
|
|
815
814
|
info = `<div id="info-control-info">${htmlList.join('\n')}</div>`;
|
|
816
815
|
}
|
|
817
|
-
this.activateFeature_(feature);
|
|
818
816
|
if ('nerveId' in feature.properties) {
|
|
817
|
+
if (feature.properties.active) {
|
|
818
|
+
this.activateFeature_(feature);
|
|
819
|
+
} else {
|
|
820
|
+
tooltip = '';
|
|
821
|
+
}
|
|
819
822
|
if (feature.properties.nerveId !== feature.properties.featureId) {
|
|
820
823
|
this.activateNerveFeatures_(feature.properties.nerveId);
|
|
821
824
|
}
|
|
825
|
+
} else {
|
|
826
|
+
this.activateFeature_(feature);
|
|
822
827
|
}
|
|
823
828
|
if ('hyperlink' in feature.properties) {
|
|
824
829
|
this._map.getCanvas().style.cursor = 'pointer';
|
|
@@ -910,6 +915,12 @@ export class UserInteractions
|
|
|
910
915
|
}
|
|
911
916
|
}
|
|
912
917
|
|
|
918
|
+
enablePath(pathType, enable=true)
|
|
919
|
+
//===============================
|
|
920
|
+
{
|
|
921
|
+
this.enablePathFeatures_(enable, this._pathways.typeFeatureIds(pathType));
|
|
922
|
+
}
|
|
923
|
+
|
|
913
924
|
showPaths(pathTypes, enable=true)
|
|
914
925
|
//===============================
|
|
915
926
|
{
|
|
@@ -919,10 +930,10 @@ export class UserInteractions
|
|
|
919
930
|
|
|
920
931
|
if (Array.isArray(pathTypes)) {
|
|
921
932
|
for (const pathType of pathTypes) {
|
|
922
|
-
this.
|
|
933
|
+
this.enablePath(pathType, enable);
|
|
923
934
|
}
|
|
924
935
|
} else {
|
|
925
|
-
this.
|
|
936
|
+
this.enablePath(pathTypes, enable);
|
|
926
937
|
}
|
|
927
938
|
|
|
928
939
|
this._disabledPathFeatures = true;
|
package/src/styling.js
CHANGED
|
@@ -263,7 +263,7 @@ export class FeatureLineLayer extends VectorStyleLayer
|
|
|
263
263
|
'case',
|
|
264
264
|
['boolean', ['feature-state', 'selected'], false], '#0F0',
|
|
265
265
|
['has', 'colour'], ['get', 'colour'],
|
|
266
|
-
['boolean', ['feature-state', 'active'], false], coloured ? '#
|
|
266
|
+
['boolean', ['feature-state', 'active'], false], coloured ? '#888' : '#CCC',
|
|
267
267
|
['==', ['get', 'type'], 'network'], '#AFA202',
|
|
268
268
|
['has', 'centreline'], '#888',
|
|
269
269
|
('style' in options && options.style === 'authoring') ? '#C44' : '#444'
|
|
@@ -454,7 +454,8 @@ export class FeatureNerveLayer extends VectorStyleLayer
|
|
|
454
454
|
['boolean', ['feature-state', 'active'], false], '#222',
|
|
455
455
|
['boolean', ['feature-state', 'selected'], false], 'red',
|
|
456
456
|
['boolean', ['feature-state', 'hidden'], false], '#CCC',
|
|
457
|
-
'#888'
|
|
457
|
+
['boolean', ['get', 'active'], false], '#888',
|
|
458
|
+
'#FFF'
|
|
458
459
|
],
|
|
459
460
|
'line-opacity': [
|
|
460
461
|
'case',
|
|
@@ -176,7 +176,7 @@ li.flatmap-contextmenu-item:hover {
|
|
|
176
176
|
.flatmap-nerve-grid {
|
|
177
177
|
margin-top: 10px;
|
|
178
178
|
display: grid;
|
|
179
|
-
grid-template-columns:
|
|
179
|
+
grid-template-columns: 3fr 0.2fr 0.8fr;
|
|
180
180
|
column-gap: 10px;
|
|
181
181
|
row-gap: 0.2em;
|
|
182
182
|
width: 300px;
|
|
@@ -184,10 +184,16 @@ li.flatmap-contextmenu-item:hover {
|
|
|
184
184
|
cursor: pointer;
|
|
185
185
|
text-align: left;
|
|
186
186
|
}
|
|
187
|
-
.nerve-
|
|
188
|
-
|
|
187
|
+
.flatmap-nerve-grid input {
|
|
188
|
+
height: 1.1em;
|
|
189
|
+
}
|
|
190
|
+
.flatmap-nerve-grid .nerve-line {
|
|
191
|
+
margin: 8px 0;
|
|
189
192
|
height: 3px;
|
|
190
193
|
}
|
|
194
|
+
label[for=path-all-paths] {
|
|
195
|
+
font-weight: bold;
|
|
196
|
+
}
|
|
191
197
|
.nerve-cns {
|
|
192
198
|
background: #9B1FC1;
|
|
193
199
|
}
|