@abi-software/flatmap-viewer 2.5.0-a.1 → 2.5.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 +3 -2
- package/src/controls/annotation.js +351 -0
- package/src/controls/controls.js +68 -0
- package/src/controls/minimap.js +3 -8
- package/src/controls/paths3d.js +90 -0
- package/src/flatmap-viewer.js +68 -35
- package/src/interactions.js +188 -138
- package/src/{layers.js → layers/index.js} +2 -2
- package/src/layers/paths3d.js +335 -0
- package/src/{styling.js → layers/styling.js} +2 -2
- package/src/main.js +1 -0
- package/src/pathways.js +62 -5
package/src/flatmap-viewer.js
CHANGED
|
@@ -37,8 +37,6 @@ import {MapServer, loadJSON} from './mapserver.js';
|
|
|
37
37
|
import {SearchIndex} from './search.js';
|
|
38
38
|
import {UserInteractions} from './interactions.js';
|
|
39
39
|
|
|
40
|
-
import {MinimapControl} from './controls/minimap.js';
|
|
41
|
-
import {NavigationControl} from './controls/controls.js';
|
|
42
40
|
import {APINATOMY_PATH_PREFIX} from './pathways';
|
|
43
41
|
|
|
44
42
|
import * as images from './images.js';
|
|
@@ -162,33 +160,16 @@ class FlatMap
|
|
|
162
160
|
|
|
163
161
|
this._map.setRenderWorldCopies(false);
|
|
164
162
|
|
|
165
|
-
// Do we want a fullscreen control?
|
|
166
|
-
|
|
167
|
-
if (mapDescription.options.fullscreenControl === true) {
|
|
168
|
-
this._map.addControl(new maplibregl.FullscreenControl(), 'top-right');
|
|
169
|
-
}
|
|
170
|
-
|
|
171
163
|
// Disable map rotation
|
|
172
164
|
|
|
173
165
|
//this._map.dragRotate.disable();
|
|
174
166
|
//this._map.touchZoomRotate.disableRotation();
|
|
175
167
|
|
|
176
|
-
// Add navigation controls if option set
|
|
177
|
-
|
|
178
|
-
if (mapDescription.options.navigationControl) {
|
|
179
|
-
const value = mapDescription.options.navigationControl;
|
|
180
|
-
const position = ((typeof value === 'string')
|
|
181
|
-
&& ['top-left', 'top-right', 'bottom-right', 'bottom-left'].includes(value))
|
|
182
|
-
? value : 'bottom-right';
|
|
183
|
-
this._map.addControl(new NavigationControl(this), position);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
168
|
// Finish initialisation when all sources have loaded
|
|
187
169
|
// and map has rendered
|
|
188
170
|
|
|
189
171
|
this._userInteractions = null;
|
|
190
172
|
this._initialState = null;
|
|
191
|
-
this._minimap = null;
|
|
192
173
|
|
|
193
174
|
this._map.on('idle', () => {
|
|
194
175
|
if (this._userInteractions === null) {
|
|
@@ -207,14 +188,9 @@ class FlatMap
|
|
|
207
188
|
this._userInteractions.setState(this._options.state);
|
|
208
189
|
}
|
|
209
190
|
this._initialState = this.getState();
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (this.options.minimap) {
|
|
214
|
-
this._minimap = new MinimapControl(this, this.options.minimap);
|
|
215
|
-
this._map.addControl(this._minimap);
|
|
216
|
-
}
|
|
217
|
-
|
|
191
|
+
if (this._userInteractions.minimap) {
|
|
192
|
+
this._userInteractions.minimap.initialise()
|
|
193
|
+
}
|
|
218
194
|
this._resolve(this);
|
|
219
195
|
}
|
|
220
196
|
});
|
|
@@ -224,13 +200,11 @@ class FlatMap
|
|
|
224
200
|
//============================
|
|
225
201
|
{
|
|
226
202
|
// Load any images required by the map
|
|
227
|
-
|
|
228
203
|
for (const image of this._options.images) {
|
|
229
204
|
await this.addImage(image.id, image.url, '', image.options);
|
|
230
205
|
}
|
|
231
206
|
|
|
232
207
|
// Layers have now loaded so finish setting up
|
|
233
|
-
|
|
234
208
|
this._userInteractions = new UserInteractions(this);
|
|
235
209
|
}
|
|
236
210
|
|
|
@@ -836,8 +810,8 @@ class FlatMap
|
|
|
836
810
|
|
|
837
811
|
this._map.setPaintProperty('background', 'background-color', colour);
|
|
838
812
|
|
|
839
|
-
if (this.
|
|
840
|
-
this.
|
|
813
|
+
if (this._userInteractions.minimap) {
|
|
814
|
+
this._userInteractions.minimap.setBackgroundColour(colour);
|
|
841
815
|
}
|
|
842
816
|
}
|
|
843
817
|
|
|
@@ -851,8 +825,8 @@ class FlatMap
|
|
|
851
825
|
{
|
|
852
826
|
this._map.setPaintProperty('background', 'background-opacity', opacity);
|
|
853
827
|
|
|
854
|
-
if (this.
|
|
855
|
-
this.
|
|
828
|
+
if (this._userInteractions.minimap) {
|
|
829
|
+
this._userInteractions.minimap.setBackgroundOpacity(opacity);
|
|
856
830
|
}
|
|
857
831
|
}
|
|
858
832
|
|
|
@@ -864,8 +838,8 @@ class FlatMap
|
|
|
864
838
|
showMinimap(show)
|
|
865
839
|
//===============
|
|
866
840
|
{
|
|
867
|
-
if (this.
|
|
868
|
-
this.
|
|
841
|
+
if (this._userInteractions.minimap) {
|
|
842
|
+
this._userInteractions.minimap.show(show);
|
|
869
843
|
}
|
|
870
844
|
|
|
871
845
|
}
|
|
@@ -898,6 +872,19 @@ class FlatMap
|
|
|
898
872
|
}
|
|
899
873
|
}
|
|
900
874
|
|
|
875
|
+
/**
|
|
876
|
+
* Show/hide 3D path view.
|
|
877
|
+
*
|
|
878
|
+
* @param {boolean} [enable=true]
|
|
879
|
+
*/
|
|
880
|
+
enable3dPaths(enable=true)
|
|
881
|
+
//========================
|
|
882
|
+
{
|
|
883
|
+
if (this._userInteractions !== null) {
|
|
884
|
+
this._userInteractions.enable3dPaths(enable)
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
901
888
|
//==========================================================================
|
|
902
889
|
|
|
903
890
|
/**
|
|
@@ -1050,6 +1037,52 @@ class FlatMap
|
|
|
1050
1037
|
return data;
|
|
1051
1038
|
}
|
|
1052
1039
|
|
|
1040
|
+
/**
|
|
1041
|
+
* Show or hide a tool for drawing regions to annotate on the map.
|
|
1042
|
+
*
|
|
1043
|
+
* @param {boolean} [visible=true]
|
|
1044
|
+
*/
|
|
1045
|
+
showAnnotator(visible=true)
|
|
1046
|
+
//=========================
|
|
1047
|
+
{
|
|
1048
|
+
if (this._userInteractions !== null) {
|
|
1049
|
+
this._userInteractions.showAnnotator(visible)
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Generate an ``'annotation-draw`` callback when a drawn annotation has changed.
|
|
1055
|
+
*
|
|
1056
|
+
* @param {string} operation Either ``created``, ``updated`` or ``deleted``
|
|
1057
|
+
* @param {string|Object} feature An object with ``id`` and ``geometry`` fields
|
|
1058
|
+
* for a feature that has been created or updated
|
|
1059
|
+
* or the ``id`` of a feature that has been deleted.
|
|
1060
|
+
*/
|
|
1061
|
+
annotationDrawEvent(drawEvent, feature)
|
|
1062
|
+
//=====================================
|
|
1063
|
+
{
|
|
1064
|
+
this.callback('annotation-draw', {
|
|
1065
|
+
type: drawEvent,
|
|
1066
|
+
feature: feature
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Add or remove a drawn annotation.
|
|
1072
|
+
*
|
|
1073
|
+
* @param {string} operation Either ``add`` or ``remove``
|
|
1074
|
+
* @param {Object} feature The feature to add or remove
|
|
1075
|
+
* @param {string} feature.id The feature's id
|
|
1076
|
+
* @param {Object} feature.geometry The feature's geometry as GeoJSON
|
|
1077
|
+
*/
|
|
1078
|
+
modifyDrawnAnnotatorFeature(operation, feature)
|
|
1079
|
+
//=============================================
|
|
1080
|
+
{
|
|
1081
|
+
if (this._userInteractions) {
|
|
1082
|
+
this._userInteractions.modifyDrawnAnnotatorFeature(operation, feature)
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1053
1086
|
/**
|
|
1054
1087
|
* Generate a callback as a result of some event with a flatmap feature.
|
|
1055
1088
|
*
|