@abi-software/flatmap-viewer 2.7.2 → 2.7.3-a.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/dist/assets/index.css +1 -0
- package/dist/index.js +80577 -0
- package/dist/lib/index.d.ts +4 -0
- package/package.json +10 -7
- package/lib/index.ts +0 -10
- package/src/contextmenu.js +0 -97
- package/src/controls/annotation.js +0 -302
- package/src/controls/controls.js +0 -645
- package/src/controls/flightpaths.js +0 -95
- package/src/controls/info.js +0 -291
- package/src/controls/minimap.js +0 -442
- package/src/controls/paths.js +0 -143
- package/src/controls/search.js +0 -113
- package/src/controls/systems.js +0 -75
- package/src/controls/taxons.js +0 -73
- package/src/flatmap-viewer.js +0 -1789
- package/src/images.js +0 -66
- package/src/interactions.js +0 -1569
- package/src/layers/cluster.js +0 -177
- package/src/layers/filter.js +0 -310
- package/src/layers/flightpaths.js +0 -383
- package/src/layers/index.js +0 -478
- package/src/layers/styling.js +0 -1077
- package/src/main.js +0 -272
- package/src/mapserver.js +0 -64
- package/src/mathjax.js +0 -100
- package/src/pathways.js +0 -427
- package/src/search.js +0 -137
- package/src/systems.js +0 -146
- package/src/utils.js +0 -152
- package/static/css/flatmap-viewer.css +0 -238
- package/static/icons/favicon.ico +0 -0
- package/static/images/active.png +0 -0
- package/static/images/inactive.png +0 -0
- package/static/images/reset-map-active.png +0 -0
- package/static/images/reset-map-button.png +0 -0
- package/static/images/rounded-background.png +0 -0
- package/static/images/zoom-in-active.png +0 -0
- package/static/images/zoom-in-button.png +0 -0
- package/static/images/zoom-out-active.png +0 -0
- package/static/images/zoom-out-button.png +0 -0
- package/thirdParty/maplibre-gl-svg/CHANGELOG.md +0 -13
- package/thirdParty/maplibre-gl-svg/LICENSE +0 -21
- package/thirdParty/maplibre-gl-svg/LICENSE.md +0 -21
- package/thirdParty/maplibre-gl-svg/README.md +0 -24
- package/thirdParty/maplibre-gl-svg/assets/Add custom SVG template to template manager.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as HTML markers.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as symbols.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Fill polygon with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with Custom SVG Template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Line layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Load SVG from URL.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/SVG template options.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Smiley_face_changed.svg +0 -37
- package/thirdParty/maplibre-gl-svg/assets/Symbol layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up-thin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/car.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker-rotated.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles-spaced.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/dots.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag-triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-arrow.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-ball-pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-circle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-flat.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin-round.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-stripes.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-left.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/x-fill.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag-vertical.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag.png +0 -0
- package/thirdParty/maplibre-gl-svg/build/build.js +0 -210
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.js +0 -339
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.min.js +0 -4
- package/thirdParty/maplibre-gl-svg/docs/docs.md +0 -375
- package/thirdParty/maplibre-gl-svg/examples/Add custom SVG template to template manager.html +0 -101
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as HTML markers.html +0 -82
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as symbols.html +0 -124
- package/thirdParty/maplibre-gl-svg/examples/Fill polygon with built-in SVG template.html +0 -94
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with Custom SVG Template.html +0 -86
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with built-in SVG template.html +0 -83
- package/thirdParty/maplibre-gl-svg/examples/Line layer with built-in SVG template.html +0 -129
- package/thirdParty/maplibre-gl-svg/examples/Load SVG from URL.html +0 -96
- package/thirdParty/maplibre-gl-svg/examples/SVG template options.html +0 -264
- package/thirdParty/maplibre-gl-svg/examples/Symbol layer with built-in SVG template.html +0 -93
- package/thirdParty/maplibre-gl-svg/index.html +0 -151
- package/thirdParty/maplibre-gl-svg/package-lock.json +0 -5882
- package/thirdParty/maplibre-gl-svg/package.json +0 -49
- package/thirdParty/maplibre-gl-svg/src/SvgManager.ts +0 -186
- package/thirdParty/maplibre-gl-svg/src/SvgTemplateManager.ts +0 -144
- package/thirdParty/maplibre-gl-svg/src/index.ts +0 -4
- package/thirdParty/maplibre-gl-svg/tsconfig.json +0 -31
- package/thirdParty/maplibre-gl-svg/typings/index.d.ts +0 -111
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmap-viewer",
|
|
3
|
-
"version": "2.7.2",
|
|
3
|
+
"version": "2.7.3-a.2",
|
|
4
4
|
"description": "Flatmap viewer using Maplibre GL",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/AnatomicMaps/flatmap-viewer.git"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"main": "lib/index.ts",
|
|
11
10
|
"files": [
|
|
12
|
-
"
|
|
13
|
-
"src",
|
|
14
|
-
"static",
|
|
15
|
-
"thirdParty"
|
|
11
|
+
"dist"
|
|
16
12
|
],
|
|
13
|
+
"module": "./dist/flatmap-viewer.es.js",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/flatmapviewer.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
17
19
|
"scripts": {
|
|
18
20
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
21
|
"dev": "vite serve app --port 3000",
|
|
@@ -47,6 +49,7 @@
|
|
|
47
49
|
"glob": "^10.3.12",
|
|
48
50
|
"typescript": "^5.2.2",
|
|
49
51
|
"vite": "^5.1.4",
|
|
50
|
-
"vite-plugin-dts": "^3.8.1"
|
|
52
|
+
"vite-plugin-dts": "^3.8.1",
|
|
53
|
+
"vite-plugin-lib-inject-css": "^2.0.1"
|
|
51
54
|
}
|
|
52
55
|
}
|
package/lib/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//==============================================================================
|
|
2
|
-
|
|
3
|
-
import {FlatMap, MapManager} from '../src/flatmap-viewer'
|
|
4
|
-
import {standaloneViewer} from '../src/main'
|
|
5
|
-
|
|
6
|
-
//==============================================================================
|
|
7
|
-
|
|
8
|
-
export {FlatMap, MapManager, standaloneViewer}
|
|
9
|
-
|
|
10
|
-
//==============================================================================
|
package/src/contextmenu.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
|
|
3
|
-
Flatmap viewer and annotation tool
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2019 David Brooks
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
******************************************************************************/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
//==============================================================================
|
|
24
|
-
|
|
25
|
-
import maplibregl from 'maplibre-gl';
|
|
26
|
-
|
|
27
|
-
//==============================================================================
|
|
28
|
-
|
|
29
|
-
function domContextMenu(items, title)
|
|
30
|
-
{
|
|
31
|
-
const menuElement = document.createElement('ul');
|
|
32
|
-
menuElement.className = 'flatmap-contextmenu';
|
|
33
|
-
menuElement.setAttribute('type', 'context');
|
|
34
|
-
|
|
35
|
-
for (const item of items) {
|
|
36
|
-
if (item === '-') {
|
|
37
|
-
menuElement.appendChild(document.createElement('hr'));
|
|
38
|
-
} else {
|
|
39
|
-
const menuItem = document.createElement('li');
|
|
40
|
-
menuItem.className = 'flatmap-contextmenu-item';
|
|
41
|
-
menuItem.setAttribute('id', item.id);
|
|
42
|
-
menuItem.onclick = item.action;
|
|
43
|
-
menuItem.textContent = item.prompt;
|
|
44
|
-
menuElement.appendChild(menuItem);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return menuElement;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/*
|
|
52
|
-
<ul>
|
|
53
|
-
<li>prompt</li>
|
|
54
|
-
<li>item 2</li>
|
|
55
|
-
</ul>
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
//==============================================================================
|
|
59
|
-
|
|
60
|
-
export class ContextMenu
|
|
61
|
-
{
|
|
62
|
-
constructor(flatmap, closeCallback)
|
|
63
|
-
{
|
|
64
|
-
this._flatmap = flatmap;
|
|
65
|
-
this._map = flatmap.map;
|
|
66
|
-
this._closeCallback = closeCallback;
|
|
67
|
-
this._popup = new maplibregl.Popup({
|
|
68
|
-
closeButton: true,
|
|
69
|
-
closeOnClick: true,
|
|
70
|
-
className: 'flatmap-contextmenu-popup',
|
|
71
|
-
maxWidth: 'none'
|
|
72
|
-
});
|
|
73
|
-
this._popup.on('close', this.popupClose_.bind(this));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
hide()
|
|
77
|
-
//====
|
|
78
|
-
{
|
|
79
|
-
this._popup.remove();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
popupClose_(e)
|
|
83
|
-
//============
|
|
84
|
-
{
|
|
85
|
-
this._closeCallback();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
show(position, menuItems, title)
|
|
89
|
-
//==============================
|
|
90
|
-
{
|
|
91
|
-
this._popup.setLngLat(position);
|
|
92
|
-
this._popup.setDOMContent(domContextMenu(menuItems, title));
|
|
93
|
-
this._popup.addTo(this._map);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//==============================================================================
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
|
|
3
|
-
Flatmap viewer and annotation tool
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2019 - 2023 David Brooks
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
**/
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
* Annotation drawing mode is enabled/disabled by:
|
|
23
|
-
*
|
|
24
|
-
* 1. A call to ``Flatmap.enableAnnotation()``
|
|
25
|
-
* 2. An on-map control button calls this when in standalone viewing mode.
|
|
26
|
-
*
|
|
27
|
-
* Drawn features include a GeoJSON geometry. Existing geometries of annotated
|
|
28
|
-
* features are added to the MapboxDraw control when the map is loaded. These
|
|
29
|
-
* should only be visible on the map when the draw control is active.
|
|
30
|
-
*
|
|
31
|
-
* We listen for drawn features being created, updated and deleted, and notify
|
|
32
|
-
* the external annotator, first assigning new features and ID wrt the flatmap.
|
|
33
|
-
* The external annotator may reject a new feature (the user's cancelled the
|
|
34
|
-
* resulting dialog) which results in the newly drawn feature being removed from
|
|
35
|
-
* the control.
|
|
36
|
-
*
|
|
37
|
-
* The external annotator is responsible for saving/obtaining drawn geometries
|
|
38
|
-
* from an annotation service.
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
//==============================================================================
|
|
43
|
-
|
|
44
|
-
import MapboxDraw from "@mapbox/mapbox-gl-draw"
|
|
45
|
-
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//==============================================================================
|
|
49
|
-
|
|
50
|
-
const drawStyleIds = MapboxDraw.lib.theme.map(s => s.id)
|
|
51
|
-
|
|
52
|
-
export const DRAW_ANNOTATION_LAYERS = [...drawStyleIds.map(id => `${id}.cold`),
|
|
53
|
-
...drawStyleIds.map(id => `${id}.hot`)]
|
|
54
|
-
|
|
55
|
-
//==============================================================================
|
|
56
|
-
|
|
57
|
-
export class AnnotationDrawControl
|
|
58
|
-
{
|
|
59
|
-
constructor(flatmap, visible=false)
|
|
60
|
-
{
|
|
61
|
-
MapboxDraw.constants.classes.CONTROL_BASE = 'maplibregl-ctrl'
|
|
62
|
-
MapboxDraw.constants.classes.CONTROL_PREFIX = 'maplibregl-ctrl-'
|
|
63
|
-
MapboxDraw.constants.classes.CONTROL_GROUP = 'maplibregl-ctrl-group'
|
|
64
|
-
|
|
65
|
-
this.__flatmap = flatmap
|
|
66
|
-
this.__committedFeatures = new Map()
|
|
67
|
-
this.__uncommittedFeatureIds = new Set()
|
|
68
|
-
this.__visible = visible
|
|
69
|
-
this.__draw = new MapboxDraw({
|
|
70
|
-
displayControlsDefault: false,
|
|
71
|
-
controls: {
|
|
72
|
-
point: true,
|
|
73
|
-
line_string: true,
|
|
74
|
-
polygon: true,
|
|
75
|
-
trash: true
|
|
76
|
-
},
|
|
77
|
-
userProperties: true,
|
|
78
|
-
keybindings: true
|
|
79
|
-
})
|
|
80
|
-
this.__map = null
|
|
81
|
-
this.__inDrawing = false
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
onAdd(map)
|
|
85
|
-
//========
|
|
86
|
-
{
|
|
87
|
-
this.__map = map
|
|
88
|
-
this.__container = this.__draw.onAdd(map)
|
|
89
|
-
|
|
90
|
-
// Fix to allow deletion with Del Key when default trash icon is not shown.
|
|
91
|
-
// See https://github.com/mapbox/mapbox-gl-draw/issues/989
|
|
92
|
-
this.__draw.options.controls.trash = true
|
|
93
|
-
|
|
94
|
-
// Prevent firefox menu from appearing on Alt key up
|
|
95
|
-
window.addEventListener('keyup', function (e) {
|
|
96
|
-
if (e.key === "Alt") {
|
|
97
|
-
e.preventDefault();
|
|
98
|
-
}
|
|
99
|
-
}, false)
|
|
100
|
-
map.on('draw.modechange', this.modeChangedEvent.bind(this))
|
|
101
|
-
map.on('draw.create', this.createdFeature.bind(this))
|
|
102
|
-
map.on('draw.delete', this.deletedFeature.bind(this))
|
|
103
|
-
map.on('draw.update', this.updatedFeature.bind(this))
|
|
104
|
-
map.on('draw.selectionchange', this.selectionChangedEvent.bind(this))
|
|
105
|
-
this.show(this.__visible)
|
|
106
|
-
return this.__container
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
onRemove()
|
|
110
|
-
//========
|
|
111
|
-
{
|
|
112
|
-
this.__container.parentNode.removeChild(this.__container)
|
|
113
|
-
this.__container = null
|
|
114
|
-
this.__map = null
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
show(visible=true)
|
|
118
|
-
//================
|
|
119
|
-
{
|
|
120
|
-
if (this.__container) {
|
|
121
|
-
this.__container.style.display = visible ? 'block' : 'none'
|
|
122
|
-
if (visible && !this.__visible) {
|
|
123
|
-
for (const layerId of DRAW_ANNOTATION_LAYERS) {
|
|
124
|
-
this.__map.setLayoutProperty(layerId, 'visibility', 'visible')
|
|
125
|
-
}
|
|
126
|
-
} else if (!visible && this.__visible) {
|
|
127
|
-
for (const layerId of DRAW_ANNOTATION_LAYERS) {
|
|
128
|
-
this.__map.setLayoutProperty(layerId, 'visibility', 'none')
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
this.__visible = visible
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
#cleanFeature(event)
|
|
136
|
-
//==================
|
|
137
|
-
{
|
|
138
|
-
const features = event.features.filter(f => f.type === 'Feature')
|
|
139
|
-
.map(f => {
|
|
140
|
-
return {
|
|
141
|
-
id: f.id,
|
|
142
|
-
type: 'Feature',
|
|
143
|
-
geometry: f.geometry
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
return features.length ? features[0] : null
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
#sendEvent(type, feature)
|
|
150
|
-
//=======================
|
|
151
|
-
{
|
|
152
|
-
if (feature.id) {
|
|
153
|
-
// Add when the event is 'created', 'updated' or 'deleted'
|
|
154
|
-
this.__uncommittedFeatureIds.add(feature.id)
|
|
155
|
-
}
|
|
156
|
-
this.__flatmap.annotationEvent(type, feature)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
createdFeature(event)
|
|
160
|
-
//===================
|
|
161
|
-
{
|
|
162
|
-
const feature = this.#cleanFeature(event)
|
|
163
|
-
if (feature) {
|
|
164
|
-
// Set properties to indicate that this is a drawn annotation
|
|
165
|
-
this.__draw.setFeatureProperty(feature.id, 'drawn', true)
|
|
166
|
-
this.__draw.setFeatureProperty(feature.id, 'label', 'Drawn annotation')
|
|
167
|
-
// They need to be on the feature passed to the annotator for storage
|
|
168
|
-
feature.properties = {
|
|
169
|
-
user_drawn: true,
|
|
170
|
-
user_label: 'Drawn annotation'
|
|
171
|
-
}
|
|
172
|
-
this.#sendEvent('created', feature)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
deletedFeature(event)
|
|
177
|
-
//===================
|
|
178
|
-
{
|
|
179
|
-
const feature = this.#cleanFeature(event)
|
|
180
|
-
if (feature) {
|
|
181
|
-
if (this.__uncommittedFeatureIds.has(feature.id)) {
|
|
182
|
-
// Ignore delete on an uncommitted create or update
|
|
183
|
-
} else {
|
|
184
|
-
this.#sendEvent('deleted', feature)
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
updatedFeature(event)
|
|
190
|
-
//===================
|
|
191
|
-
{
|
|
192
|
-
const feature = this.#cleanFeature(event)
|
|
193
|
-
if (feature) {
|
|
194
|
-
// specify updated callback type, either `move` or `change_coordinates`
|
|
195
|
-
feature.action = event.action
|
|
196
|
-
if (this.__uncommittedFeatureIds.has(feature.id)) {
|
|
197
|
-
// Ignore updates on an uncommitted create or update
|
|
198
|
-
} else {
|
|
199
|
-
this.#sendEvent('updated', feature)
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
modeChangedEvent(event)
|
|
205
|
-
//=====================
|
|
206
|
-
{
|
|
207
|
-
// Used as a flag to indicate the feature mode
|
|
208
|
-
this.__inDrawing = (event.mode.startsWith('draw'))
|
|
209
|
-
this.#sendEvent('modeChanged', event)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
selectionChangedEvent(event)
|
|
213
|
-
//==========================
|
|
214
|
-
{
|
|
215
|
-
// Used to indicate a feature is selected or deselected
|
|
216
|
-
this.#sendEvent('selectionChanged', event)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
inDrawingMode()
|
|
220
|
-
//=============
|
|
221
|
-
{
|
|
222
|
-
return this.__inDrawing
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
commitEvent(event)
|
|
226
|
-
//================
|
|
227
|
-
{
|
|
228
|
-
const feature = event.feature
|
|
229
|
-
if (event.type === 'deleted') {
|
|
230
|
-
this.__committedFeatures.delete(feature.id)
|
|
231
|
-
} else {
|
|
232
|
-
this.__committedFeatures.set(feature.id, feature)
|
|
233
|
-
}
|
|
234
|
-
this.__uncommittedFeatureIds.delete(feature.id)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
abortEvent(event)
|
|
238
|
-
//===============
|
|
239
|
-
{
|
|
240
|
-
// Used as a flag to indicate the popup is closed
|
|
241
|
-
// Rollback should be performed when triggered 'aborted' event
|
|
242
|
-
this.#sendEvent('aborted', event)
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
rollbackEvent(event)
|
|
246
|
-
//==================
|
|
247
|
-
{
|
|
248
|
-
const feature = event.feature
|
|
249
|
-
if (event.type === 'created') {
|
|
250
|
-
this.__draw.delete(feature.id)
|
|
251
|
-
this.__committedFeatures.delete(feature.id)
|
|
252
|
-
this.__uncommittedFeatureIds.delete(feature.id)
|
|
253
|
-
} else if (event.type === 'deleted') {
|
|
254
|
-
this.__draw.add(feature)
|
|
255
|
-
this.__committedFeatures.set(feature.id, feature)
|
|
256
|
-
this.__uncommittedFeatureIds.delete(feature.id)
|
|
257
|
-
} else if (event.type === 'updated') {
|
|
258
|
-
const savedFeature = this.__committedFeatures.get(feature.id)
|
|
259
|
-
if (savedFeature) {
|
|
260
|
-
this.__draw.delete(feature.id)
|
|
261
|
-
this.__draw.add(savedFeature)
|
|
262
|
-
this.__uncommittedFeatureIds.delete(feature.id)
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
clearFeatures()
|
|
268
|
-
//=============
|
|
269
|
-
{
|
|
270
|
-
this.__draw.deleteAll()
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
removeFeature()
|
|
274
|
-
//=============
|
|
275
|
-
{
|
|
276
|
-
this.__draw.trash()
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
addFeature(feature)
|
|
280
|
-
//=================
|
|
281
|
-
{
|
|
282
|
-
feature = Object.assign({}, feature, {type: 'Feature'})
|
|
283
|
-
const ids = this.__draw.add(feature)
|
|
284
|
-
this.__committedFeatures.set(ids[0], feature)
|
|
285
|
-
this.__uncommittedFeatureIds.delete(ids[0])
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
refreshGeometry(feature)
|
|
289
|
-
//======================
|
|
290
|
-
{
|
|
291
|
-
return this.__draw.get(feature.id) || null
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
changeMode(type)
|
|
295
|
-
//==============
|
|
296
|
-
{
|
|
297
|
-
// Change the mode directly without listening to modes callback
|
|
298
|
-
this.__draw.changeMode(type.mode, type.options)
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
//==============================================================================
|