@abi-software/flatmap-viewer 2.2.1-beta.2 → 2.2.1-beta.3
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 +2 -2
- package/package.json +1 -1
- package/src/flatmap-viewer.js +7 -1
- package/src/interactions.js +0 -28
- package/src/layers.js +38 -19
- package/src/styling.js +2 -2
package/README.rst
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Flatmap Viewer
|
|
3
3
|
==============
|
|
4
4
|
|
|
5
|
-
A viewer for anatomical flatmaps generated by `flatmap-maker <https://github.com/
|
|
5
|
+
A viewer for anatomical flatmaps generated by `flatmap-maker <https://github.com/AnatomicMaps/flatmap-maker>`_. The viewer is intended to be a component of a larger Javascript web application, although may be used standalone for local flatmap development and testing. Flatmap content is obtained from a `flatmap-server <https://github.com/AnatomicMaps/flatmap-server>`_.
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Standalone Use
|
|
@@ -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.3``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
package/src/flatmap-viewer.js
CHANGED
|
@@ -1259,7 +1259,13 @@ export class MapManager
|
|
|
1259
1259
|
outline: true
|
|
1260
1260
|
};
|
|
1261
1261
|
}
|
|
1262
|
-
|
|
1262
|
+
if ('authoring' in mapIndex) {
|
|
1263
|
+
mapOptions.layerOptions.style == 'authoring'
|
|
1264
|
+
} else if ('style' in mapIndex) {
|
|
1265
|
+
mapOptions.layerOptions.style = mapIndex.style;
|
|
1266
|
+
} else {
|
|
1267
|
+
mapOptions.layerOptions.style = 'flatmap';
|
|
1268
|
+
}
|
|
1263
1269
|
|
|
1264
1270
|
// Are features in separate vector tile source layers?
|
|
1265
1271
|
|
package/src/interactions.js
CHANGED
|
@@ -162,34 +162,6 @@ export class UserInteractions
|
|
|
162
162
|
|
|
163
163
|
this._layerManager = new LayerManager(flatmap);
|
|
164
164
|
|
|
165
|
-
// Add the map's layers
|
|
166
|
-
|
|
167
|
-
// Layers have an id, either layer-N or an assigned name
|
|
168
|
-
// Some layers might have a description. These are the selectable layers,
|
|
169
|
-
// unless they are flagged as `no-select`
|
|
170
|
-
// Selectable layers have opacity 0 unless active, in which case they have opacity 1.
|
|
171
|
-
// `no-select` layers have opacity 0.5
|
|
172
|
-
// Background layer has opacity 0.2
|
|
173
|
-
|
|
174
|
-
const layersById = new Map();
|
|
175
|
-
const layerBackgroundIds = [];
|
|
176
|
-
for (const layer of flatmap.layers) {
|
|
177
|
-
layer.backgroundLayers = [];
|
|
178
|
-
layersById.set(layer.id, layer);
|
|
179
|
-
}
|
|
180
|
-
for (const layer of flatmap.layers) {
|
|
181
|
-
if (layer.background_for) {
|
|
182
|
-
const l = layersById.get(layer.background_for);
|
|
183
|
-
l.backgroundLayers.push(layer);
|
|
184
|
-
layerBackgroundIds.push(layer.id);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
for (const layer of flatmap.layers) {
|
|
188
|
-
if (layerBackgroundIds.indexOf(layer.id) < 0) {
|
|
189
|
-
this._layerManager.addLayer(layer, flatmap.options.layerOptions);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
165
|
// Flag features that have annotations
|
|
194
166
|
// Also flag those features that are models of something
|
|
195
167
|
|
package/src/layers.js
CHANGED
|
@@ -33,7 +33,7 @@ const FEATURES_LAYER = 'features'
|
|
|
33
33
|
|
|
34
34
|
class MapFeatureLayer
|
|
35
35
|
{
|
|
36
|
-
constructor(flatmap, layer,
|
|
36
|
+
constructor(flatmap, layer, background_layers=true)
|
|
37
37
|
{
|
|
38
38
|
this.__map = flatmap.map;
|
|
39
39
|
this.__separateLayers = flatmap.options.separateLayers;
|
|
@@ -41,6 +41,7 @@ class MapFeatureLayer
|
|
|
41
41
|
this.__rasterLayers = [];
|
|
42
42
|
this.__styleLayers = [];
|
|
43
43
|
|
|
44
|
+
const layerOptions = flatmap.options.layerOptions;
|
|
44
45
|
const vectorTileSource = this.__map.getSource('vector-tiles');
|
|
45
46
|
const haveVectorLayers = (typeof vectorTileSource !== 'undefined');
|
|
46
47
|
const featuresVectorLayerId = this.__separateLayers
|
|
@@ -48,34 +49,36 @@ class MapFeatureLayer
|
|
|
48
49
|
: FEATURES_LAYER;
|
|
49
50
|
const vectorFeatures = haveVectorLayers
|
|
50
51
|
&& vectorTileSource.vectorLayerIds.indexOf(featuresVectorLayerId) >= 0;
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
52
|
+
if (background_layers) {
|
|
53
|
+
if (vectorFeatures) {
|
|
54
|
+
this.__addStyleLayer(style.BodyLayer, layerOptions);
|
|
55
|
+
}
|
|
56
|
+
if (flatmap.details['image_layer']) {
|
|
57
|
+
for (const raster_layer_id of layer['image-layers']) {
|
|
58
|
+
this.__addRasterLayer(raster_layer_id, layerOptions);
|
|
59
|
+
}
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
// if no image layers then make feature borders (and lines?) more visible...??
|
|
60
63
|
if (haveVectorLayers) {
|
|
61
64
|
if (vectorFeatures) {
|
|
62
|
-
this.__addStyleLayer(style.FeatureFillLayer,
|
|
63
|
-
this.__addStyleLayer(style.FeatureDashLineLayer,
|
|
64
|
-
this.__addStyleLayer(style.FeatureLineLayer,
|
|
65
|
-
this.__addStyleLayer(style.FeatureBorderLayer,
|
|
65
|
+
this.__addStyleLayer(style.FeatureFillLayer, layerOptions);
|
|
66
|
+
this.__addStyleLayer(style.FeatureDashLineLayer, layerOptions);
|
|
67
|
+
this.__addStyleLayer(style.FeatureLineLayer, layerOptions);
|
|
68
|
+
this.__addStyleLayer(style.FeatureBorderLayer, layerOptions);
|
|
66
69
|
}
|
|
67
|
-
this.__addPathwayStyleLayers(
|
|
70
|
+
this.__addPathwayStyleLayers(layerOptions);
|
|
68
71
|
if (vectorFeatures) {
|
|
69
|
-
this.__addStyleLayer(style.FeatureLargeSymbolLayer,
|
|
72
|
+
this.__addStyleLayer(style.FeatureLargeSymbolLayer, layerOptions);
|
|
70
73
|
if (!flatmap.options.tooltips) {
|
|
71
|
-
this.__addStyleLayer(style.FeatureSmallSymbolLayer,
|
|
74
|
+
this.__addStyleLayer(style.FeatureSmallSymbolLayer, layerOptions);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
// Make sure our
|
|
79
|
+
// Make sure our colour options are set properly, in particular raster layer visibility
|
|
77
80
|
|
|
78
|
-
this.setColour(
|
|
81
|
+
this.setColour(layerOptions);
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
get id()
|
|
@@ -148,12 +151,28 @@ export class LayerManager
|
|
|
148
151
|
this.__mapLayers = new Map;
|
|
149
152
|
this.__activeLayers = [];
|
|
150
153
|
this.__activeLayerNames = [];
|
|
154
|
+
this.__rasterLayers = [];
|
|
151
155
|
const backgroundLayer = new style.BackgroundLayer();
|
|
152
156
|
if ('background' in flatmap.options) {
|
|
153
157
|
this.__map.addLayer(backgroundLayer.style(flatmap.options.background));
|
|
154
158
|
} else {
|
|
155
159
|
this.__map.addLayer(backgroundLayer.style('white'));
|
|
156
160
|
}
|
|
161
|
+
// Add the map's layers
|
|
162
|
+
const layerOptions = flatmap.options.layerOptions;
|
|
163
|
+
const fcDiagram = ('style' in layerOptions && layerOptions.style == 'fcdiagram');
|
|
164
|
+
if (fcDiagram && flatmap.details['image_layer']) {
|
|
165
|
+
for (const layer of flatmap.layers) {
|
|
166
|
+
for (const raster_layer_id of layer['image-layers']) {
|
|
167
|
+
const rasterLayer = new style.RasterLayer(raster_layer_id);
|
|
168
|
+
this.__map.addLayer(rasterLayer.style(layerOptions));
|
|
169
|
+
this.__rasterLayers.push(rasterLayer);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const layer of flatmap.layers) {
|
|
174
|
+
this.addLayer(layer, !fcDiagram);
|
|
175
|
+
}
|
|
157
176
|
}
|
|
158
177
|
|
|
159
178
|
get activeLayerNames()
|
|
@@ -162,12 +181,12 @@ export class LayerManager
|
|
|
162
181
|
return this.__activeLayerNames;
|
|
163
182
|
}
|
|
164
183
|
|
|
165
|
-
addLayer(layer,
|
|
166
|
-
|
|
184
|
+
addLayer(layer, background_layers=true)
|
|
185
|
+
//=====================================
|
|
167
186
|
{
|
|
168
187
|
this.__mapLayers.set(layer.id, layer);
|
|
169
188
|
|
|
170
|
-
const layers = new MapFeatureLayer(this.__flatmap, layer,
|
|
189
|
+
const layers = new MapFeatureLayer(this.__flatmap, layer, background_layers);
|
|
171
190
|
const layerId = this.__flatmap.mapLayerId(layer.id);
|
|
172
191
|
this.__layers.set(layerId, layers);
|
|
173
192
|
}
|
package/src/styling.js
CHANGED
|
@@ -265,7 +265,7 @@ export class FeatureLineLayer extends VectorStyleLayer
|
|
|
265
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',
|
|
@@ -279,7 +279,7 @@ export class FeatureLineLayer extends VectorStyleLayer
|
|
|
279
279
|
['has', 'centreline'], 1.2,
|
|
280
280
|
['==', ['get', 'type'], 'network'], 1.2,
|
|
281
281
|
['boolean', ['feature-state', 'active'], false], 1.2,
|
|
282
|
-
('
|
|
282
|
+
('style' in options && options.style === 'authoring') ? 0.7 : 0.5
|
|
283
283
|
], [
|
|
284
284
|
'interpolate',
|
|
285
285
|
['exponential', 2],
|