@abi-software/flatmap-viewer 2.2.10-devel → 2.2.10-devel.2
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/package.json +1 -1
- package/src/controls.js +1 -1
- package/src/flatmap-viewer.js +12 -15
- package/src/interactions.js +6 -1
- package/src/layers.js +39 -22
- package/src/main.js +4 -2
- package/src/styling.js +19 -10
- package/src/utils.js +1 -1
package/package.json
CHANGED
package/src/controls.js
CHANGED
package/src/flatmap-viewer.js
CHANGED
|
@@ -658,7 +658,10 @@ class FlatMap
|
|
|
658
658
|
setColour(options=null)
|
|
659
659
|
//=====================
|
|
660
660
|
{
|
|
661
|
-
options = utils.
|
|
661
|
+
options = utils.setDefaults(options, {
|
|
662
|
+
colour: true,
|
|
663
|
+
outline: true
|
|
664
|
+
});
|
|
662
665
|
if (this._userInteractions !== null) {
|
|
663
666
|
this._userInteractions.setColour(options);
|
|
664
667
|
}
|
|
@@ -696,6 +699,8 @@ class FlatMap
|
|
|
696
699
|
setBackgroundColour(colour)
|
|
697
700
|
//=========================
|
|
698
701
|
{
|
|
702
|
+
localStorage.setItem('flatmap-background-colour', colour);
|
|
703
|
+
|
|
699
704
|
this._map.setPaintProperty('background', 'background-color', colour);
|
|
700
705
|
|
|
701
706
|
if (this._minimap) {
|
|
@@ -1023,7 +1028,11 @@ class FlatMap
|
|
|
1023
1028
|
zoomToFeatures(externalIds, options=null)
|
|
1024
1029
|
//=======================================
|
|
1025
1030
|
{
|
|
1026
|
-
options = utils.
|
|
1031
|
+
options = utils.setDefaults(options, {
|
|
1032
|
+
select: true,
|
|
1033
|
+
highlight: false,
|
|
1034
|
+
padding:100
|
|
1035
|
+
});
|
|
1027
1036
|
if (this._userInteractions !== null) {
|
|
1028
1037
|
const featureIds = this.modelFeatureIdList(externalIds);
|
|
1029
1038
|
this._userInteractions.zoomToFeatures(featureIds, options);
|
|
@@ -1216,19 +1225,7 @@ export class MapManager
|
|
|
1216
1225
|
mapOptions['bounds'] = mapIndex['bounds'];
|
|
1217
1226
|
}
|
|
1218
1227
|
|
|
1219
|
-
//
|
|
1220
|
-
|
|
1221
|
-
if (!('pathControls' in mapOptions)) {
|
|
1222
|
-
mapOptions['pathControls'] = true;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
// Default is to show layer controls
|
|
1226
|
-
|
|
1227
|
-
if (!('layerControl' in mapOptions)) {
|
|
1228
|
-
mapOptions['layerControl'] = true;
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
// Mapmaker's changed the name of the field to indicate that indicates if
|
|
1228
|
+
// Mapmaker has changed the name of the field to indicate that indicates if
|
|
1232
1229
|
// there are raster layers
|
|
1233
1230
|
if (!('image-layers' in mapIndex) && ('image_layer' in mapIndex)) {
|
|
1234
1231
|
mapIndex['image-layers'] = mapIndex['image_layer'];
|
package/src/interactions.js
CHANGED
|
@@ -529,7 +529,12 @@ export class UserInteractions
|
|
|
529
529
|
zoomToFeatures(featureIds, options=null)
|
|
530
530
|
//======================================
|
|
531
531
|
{
|
|
532
|
-
options = utils.
|
|
532
|
+
options = utils.setDefaults(options, {
|
|
533
|
+
select: true,
|
|
534
|
+
highlight:
|
|
535
|
+
false, noZoomIn:
|
|
536
|
+
false, padding:10
|
|
537
|
+
});
|
|
533
538
|
const select = (options.select === true);
|
|
534
539
|
const highlight = (options.highlight === true);
|
|
535
540
|
if (featureIds.length) {
|
package/src/layers.js
CHANGED
|
@@ -27,20 +27,21 @@ import {PATHWAYS_LAYER} from './pathways.js';
|
|
|
27
27
|
import * as style from './styling.js';
|
|
28
28
|
import * as utils from './utils.js';
|
|
29
29
|
|
|
30
|
-
const FEATURES_LAYER = 'features'
|
|
31
|
-
const RASTER_LAYERS_NAME = 'Background image layer'
|
|
30
|
+
const FEATURES_LAYER = 'features';
|
|
31
|
+
const RASTER_LAYERS_NAME = 'Background image layer';
|
|
32
|
+
const RASTER_LAYERS_ID = 'background-image-layer';
|
|
32
33
|
|
|
33
34
|
//==============================================================================
|
|
34
35
|
|
|
35
36
|
class MapStylingLayers
|
|
36
37
|
{
|
|
37
|
-
constructor(flatmap, layerId)
|
|
38
|
+
constructor(flatmap, layerId, options)
|
|
38
39
|
{
|
|
39
40
|
this.__map = flatmap.map;
|
|
40
41
|
this.__id = layerId;
|
|
41
42
|
this.__layers = [];
|
|
42
43
|
this.__active = true;
|
|
43
|
-
this.__layerOptions =
|
|
44
|
+
this.__layerOptions = options;
|
|
44
45
|
this.__separateLayers = flatmap.options.separateLayers;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -90,9 +91,9 @@ class MapStylingLayers
|
|
|
90
91
|
|
|
91
92
|
class MapFeatureLayers extends MapStylingLayers
|
|
92
93
|
{
|
|
93
|
-
constructor(flatmap, layer)
|
|
94
|
+
constructor(flatmap, layer, options)
|
|
94
95
|
{
|
|
95
|
-
super(flatmap, layer.id);
|
|
96
|
+
super(flatmap, layer.id, options);
|
|
96
97
|
const vectorTileSource = this.__map.getSource('vector-tiles');
|
|
97
98
|
const haveVectorLayers = (typeof vectorTileSource !== 'undefined');
|
|
98
99
|
|
|
@@ -161,9 +162,9 @@ class MapFeatureLayers extends MapStylingLayers
|
|
|
161
162
|
|
|
162
163
|
class MapRasterLayers extends MapStylingLayers
|
|
163
164
|
{
|
|
164
|
-
constructor(flatmap, bodyLayerId=null)
|
|
165
|
+
constructor(flatmap, options, bodyLayerId=null)
|
|
165
166
|
{
|
|
166
|
-
super(flatmap,
|
|
167
|
+
super(flatmap, RASTER_LAYERS_ID, options);
|
|
167
168
|
if (bodyLayerId !== null) {
|
|
168
169
|
const layerId = `${bodyLayerId}_${FEATURES_LAYER}`;
|
|
169
170
|
const source = flatmap.options.separateLayers ? layerId : FEATURES_LAYER;
|
|
@@ -210,7 +211,10 @@ export class LayerManager
|
|
|
210
211
|
this.__map = flatmap.map;
|
|
211
212
|
this.__layers = new Map;
|
|
212
213
|
this.__mapLayers = new Map;
|
|
213
|
-
|
|
214
|
+
this.__layerOptions = utils.setDefaults(flatmap.options.layerOptions, {
|
|
215
|
+
colour: true,
|
|
216
|
+
outline: true
|
|
217
|
+
});;
|
|
214
218
|
const backgroundLayer = new style.BackgroundLayer();
|
|
215
219
|
if ('background' in flatmap.options) {
|
|
216
220
|
this.__map.addLayer(backgroundLayer.style(flatmap.options.background));
|
|
@@ -220,20 +224,23 @@ export class LayerManager
|
|
|
220
224
|
|
|
221
225
|
// Add the map's layers
|
|
222
226
|
if (flatmap.details['image-layers']) {
|
|
223
|
-
|
|
227
|
+
this.__layerOptions.activeRasterLayer = true;
|
|
224
228
|
|
|
229
|
+
// Image layers are below all feature layers
|
|
225
230
|
const bodyLayer = flatmap.layers[0];
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
const rasterLayers = new MapRasterLayers(this.__flatmap,
|
|
232
|
+
this.__layerOptions,
|
|
233
|
+
bodyLayer.id); // body layer if not FC??
|
|
229
234
|
for (const layer of flatmap.layers) {
|
|
230
235
|
rasterLayers.addLayer(layer);
|
|
231
236
|
}
|
|
232
|
-
this.__layers.set(
|
|
233
|
-
id:
|
|
237
|
+
this.__layers.set(RASTER_LAYERS_ID, {
|
|
238
|
+
id: RASTER_LAYERS_ID,
|
|
234
239
|
description: RASTER_LAYERS_NAME
|
|
235
240
|
});
|
|
236
|
-
this.__mapLayers.set(
|
|
241
|
+
this.__mapLayers.set(RASTER_LAYERS_ID, rasterLayers);
|
|
242
|
+
} else {
|
|
243
|
+
this.__layerOptions.activeRasterLayer = false;
|
|
237
244
|
}
|
|
238
245
|
for (const layer of flatmap.layers) {
|
|
239
246
|
this.__addFeatureLayer(layer);
|
|
@@ -256,7 +263,9 @@ export class LayerManager
|
|
|
256
263
|
//======================
|
|
257
264
|
{
|
|
258
265
|
this.__layers.set(layer.id, layer);
|
|
259
|
-
this.__mapLayers.set(layer.id, new MapFeatureLayers(this.__flatmap,
|
|
266
|
+
this.__mapLayers.set(layer.id, new MapFeatureLayers(this.__flatmap,
|
|
267
|
+
layer,
|
|
268
|
+
this.__layerOptions));
|
|
260
269
|
}
|
|
261
270
|
|
|
262
271
|
get layers()
|
|
@@ -268,18 +277,26 @@ export class LayerManager
|
|
|
268
277
|
activate(layerId, enable=true)
|
|
269
278
|
//============================
|
|
270
279
|
{
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
|
|
280
|
+
const layer = this.__mapLayers.get(layerId);
|
|
281
|
+
if (layer !== undefined) {
|
|
282
|
+
layer.activate(enable);
|
|
283
|
+
if (layer.id === RASTER_LAYERS_ID) {
|
|
284
|
+
this.__layerOptions.activeRasterLayer = enable;
|
|
285
|
+
for (const mapLayer of this.__mapLayers.values()) {
|
|
286
|
+
if (mapLayer.id !== RASTER_LAYERS_ID) {
|
|
287
|
+
mapLayer.setColour(this.__layerOptions);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
274
291
|
}
|
|
275
292
|
}
|
|
276
293
|
|
|
277
294
|
setColour(options=null)
|
|
278
295
|
//=====================
|
|
279
296
|
{
|
|
280
|
-
|
|
297
|
+
this.__layerOptions = utils.setDefaults(options, this.__layerOptions);
|
|
281
298
|
for (const mapLayer of this.__mapLayers.values()) {
|
|
282
|
-
mapLayer.setColour(
|
|
299
|
+
mapLayer.setColour(this.__layerOptions);
|
|
283
300
|
}
|
|
284
301
|
}
|
|
285
302
|
}
|
package/src/main.js
CHANGED
|
@@ -52,7 +52,7 @@ export async function standaloneViewer(map_endpoint=null, options={})
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
let currentMap = null;
|
|
55
|
-
let defaultBackground = 'black';
|
|
55
|
+
let defaultBackground = localStorage.getItem('flatmap-background-colour') || 'black';
|
|
56
56
|
|
|
57
57
|
const mapOptions = Object.assign({
|
|
58
58
|
tooltips: true,
|
|
@@ -62,7 +62,9 @@ export async function standaloneViewer(map_endpoint=null, options={})
|
|
|
62
62
|
minimap: false,
|
|
63
63
|
searchable: true,
|
|
64
64
|
featureInfo: true,
|
|
65
|
-
showPosition: false
|
|
65
|
+
showPosition: false,
|
|
66
|
+
pathControls: true,
|
|
67
|
+
layerControl: true
|
|
66
68
|
}, options);
|
|
67
69
|
|
|
68
70
|
function loadMap(id, taxon, sex)
|
package/src/styling.js
CHANGED
|
@@ -114,6 +114,7 @@ export class FeatureFillLayer extends VectorStyleLayer
|
|
|
114
114
|
{
|
|
115
115
|
const coloured = !('colour' in options) || options.colour;
|
|
116
116
|
const dimmed = 'dimmed' in options && options.dimmed;
|
|
117
|
+
const activeRasterLayer = 'activeRasterLayer' in options && options.activeRasterLayer;
|
|
117
118
|
const paintStyle = {
|
|
118
119
|
'fill-color': [
|
|
119
120
|
'case',
|
|
@@ -128,15 +129,15 @@ export class FeatureFillLayer extends VectorStyleLayer
|
|
|
128
129
|
],
|
|
129
130
|
'fill-opacity': [
|
|
130
131
|
'case',
|
|
132
|
+
['boolean', ['feature-state', 'selected'], false], 0.7,
|
|
133
|
+
['has', 'colour'], activeRasterLayer ? 0.008 : 1.0,
|
|
134
|
+
['boolean', ['feature-state', 'active'], false], 0.7,
|
|
135
|
+
['has', 'node'], 0.3,
|
|
131
136
|
['any',
|
|
132
137
|
['==', ['get', 'kind'], 'scaffold'],
|
|
133
138
|
['==', ['get', 'kind'], 'tissue'],
|
|
134
139
|
['==', ['get', 'kind'], 'cell-type'],
|
|
135
140
|
], 0.1,
|
|
136
|
-
['has', 'node'], 0.3,
|
|
137
|
-
['boolean', ['feature-state', 'active'], false], 0.8,
|
|
138
|
-
['boolean', ['feature-state', 'selected'], false], 0.01,
|
|
139
|
-
['has', 'colour'], 0.008,
|
|
140
141
|
(coloured && !dimmed) ? 0.01 : 0.1
|
|
141
142
|
]
|
|
142
143
|
};
|
|
@@ -175,6 +176,7 @@ export class FeatureBorderLayer extends VectorStyleLayer
|
|
|
175
176
|
const coloured = !('colour' in options) || options.colour;
|
|
176
177
|
const outlined = !('outline' in options) || options.outline;
|
|
177
178
|
const dimmed = 'dimmed' in options && options.dimmed;
|
|
179
|
+
const activeRasterLayer = 'activeRasterLayer' in options && options.activeRasterLayer;
|
|
178
180
|
const lineColour = [ 'case' ];
|
|
179
181
|
lineColour.push(['boolean', ['feature-state', 'selected'], false]);
|
|
180
182
|
lineColour.push('red');
|
|
@@ -183,7 +185,7 @@ export class FeatureBorderLayer extends VectorStyleLayer
|
|
|
183
185
|
lineColour.push('blue');
|
|
184
186
|
}
|
|
185
187
|
lineColour.push(['has', 'colour']);
|
|
186
|
-
lineColour.push(
|
|
188
|
+
lineColour.push('#000');
|
|
187
189
|
lineColour.push(['has', 'node']);
|
|
188
190
|
lineColour.push('#AFA202');
|
|
189
191
|
lineColour.push('#444');
|
|
@@ -198,7 +200,11 @@ export class FeatureBorderLayer extends VectorStyleLayer
|
|
|
198
200
|
}
|
|
199
201
|
lineOpacity.push(['boolean', ['feature-state', 'selected'], false]);
|
|
200
202
|
lineOpacity.push(0.9);
|
|
201
|
-
|
|
203
|
+
if (activeRasterLayer) {
|
|
204
|
+
lineOpacity.push((outlined && !dimmed) ? 0.3 : 0.1);
|
|
205
|
+
} else {
|
|
206
|
+
lineOpacity.push(0.5);
|
|
207
|
+
}
|
|
202
208
|
|
|
203
209
|
const lineWidth = [
|
|
204
210
|
'case',
|
|
@@ -208,8 +214,10 @@ export class FeatureBorderLayer extends VectorStyleLayer
|
|
|
208
214
|
lineWidth.push(2.5);
|
|
209
215
|
if (coloured && outlined) {
|
|
210
216
|
lineWidth.push(['boolean', ['feature-state', 'active'], false]);
|
|
211
|
-
lineWidth.push(1);
|
|
217
|
+
lineWidth.push(1.5);
|
|
212
218
|
}
|
|
219
|
+
lineWidth.push(['has', 'colour']);
|
|
220
|
+
lineWidth.push(0.7);
|
|
213
221
|
lineWidth.push((coloured && outlined) ? 0.5 : 0.1);
|
|
214
222
|
|
|
215
223
|
return super.changedPaintStyle({
|
|
@@ -271,8 +279,9 @@ export class FeatureLineLayer extends VectorStyleLayer
|
|
|
271
279
|
],
|
|
272
280
|
'line-opacity': [
|
|
273
281
|
'case',
|
|
274
|
-
|
|
275
|
-
|
|
282
|
+
['boolean', ['feature-state', 'selected'], false], 1.0,
|
|
283
|
+
['has', 'colour'], 1.0,
|
|
284
|
+
['boolean', ['feature-state', 'active'], false], 1.0,
|
|
276
285
|
0.3
|
|
277
286
|
],
|
|
278
287
|
'line-width': [
|
|
@@ -360,7 +369,7 @@ export class PathLineLayer extends VectorStyleLayer
|
|
|
360
369
|
['boolean', ['feature-state', 'hidden'], false], '#CCC',
|
|
361
370
|
['==', ['get', 'type'], 'bezier'], 'red',
|
|
362
371
|
['==', ['get', 'kind'], 'error'], '#FFFE0E',
|
|
363
|
-
['==', ['get', 'kind'], 'unknown'], '#
|
|
372
|
+
['==', ['get', 'kind'], 'unknown'], '#888',
|
|
364
373
|
['==', ['get', 'kind'], 'cns'], '#9B1FC1',
|
|
365
374
|
['==', ['get', 'kind'], 'lcn'], '#F19E38',
|
|
366
375
|
['==', ['get', 'kind'], 'para-post'], '#3F8F4A',
|
package/src/utils.js
CHANGED
|
@@ -110,7 +110,7 @@ export function normaliseId(id)
|
|
|
110
110
|
|
|
111
111
|
//==============================================================================
|
|
112
112
|
|
|
113
|
-
export function
|
|
113
|
+
export function setDefaults(options, defaultOptions)
|
|
114
114
|
{
|
|
115
115
|
if (options === undefined || options === null) {
|
|
116
116
|
return defaultOptions;
|