@hzab/map-combine 0.4.1 → 0.4.2-alpha.0
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/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/basic/BasicElement.ts +14 -14
- package/src/basic/BasicMarker.ts +32 -26
- package/src/basic/BasicMouseHandler.ts +4 -4
- package/src/basic/Point.ts +173 -173
- package/src/basic/Polygon.ts +81 -70
- package/src/basic/Polyline.ts +85 -75
- package/src/basic/ReactPopup.tsx +12 -10
- package/src/cesium/CesiumPoint.ts +69 -69
- package/src/cesium/CesiumPolygon.ts +181 -190
- package/src/cesium/CesiumPolyline.ts +369 -369
- package/src/mine/MinePoint.ts +70 -78
- package/src/mine/MinePolygon.ts +206 -216
- package/src/mine/MinePolyline.ts +193 -203
- package/src/mine/MineTile3D.ts +7 -11
- package/src/openlayer/OpenlayerPoint.ts +185 -177
- package/src/openlayer/OpenlayerPolygon.ts +302 -299
- package/src/openlayer/OpenlayerPolyline.ts +303 -289
- package/src/utils/Image.ts +16 -20
- package/src/utils/PolygonEditor.ts +78 -99
- package/src/utils/PolylineEditor.ts +75 -90
- package/src/utils/static.ts +3 -3
package/src/mine/MinePolygon.ts
CHANGED
|
@@ -1,148 +1,146 @@
|
|
|
1
|
-
|
|
2
1
|
import { Polygon } from "../basic/Polygon";
|
|
3
2
|
import { ChainNode, PolygonEditor } from "../utils/PolygonEditor";
|
|
4
|
-
import { MineMap } from
|
|
5
|
-
import iconPoint from
|
|
6
|
-
import iconAdd from
|
|
3
|
+
import { MineMap } from "./MineMap";
|
|
4
|
+
import iconPoint from "../assets/point.png";
|
|
5
|
+
import iconAdd from "../assets/add.png";
|
|
7
6
|
import { dealColor } from "../utils";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
img.
|
|
17
|
-
img.
|
|
18
|
-
img.height = 16
|
|
19
|
-
img.style.cursor = 'move'
|
|
20
|
-
img.addEventListener('pointerdown', onPointerDown)
|
|
21
|
-
img.addEventListener('pointerup', onPointerUp)
|
|
22
|
-
img.addEventListener('dblclick', onDbClick)
|
|
8
|
+
function createImgNode(onPointerDown: () => void, onPointerUp: () => void, onDbClick: () => void) {
|
|
9
|
+
const img = document.createElement("img");
|
|
10
|
+
img.src = iconPoint;
|
|
11
|
+
img.width = 16;
|
|
12
|
+
img.height = 16;
|
|
13
|
+
img.style.cursor = "move";
|
|
14
|
+
img.addEventListener("pointerdown", onPointerDown);
|
|
15
|
+
img.addEventListener("pointerup", onPointerUp);
|
|
16
|
+
img.addEventListener("dblclick", onDbClick);
|
|
23
17
|
const marker = new minemap.Marker({
|
|
24
18
|
draggable: false,
|
|
25
19
|
element: img,
|
|
26
20
|
offset: [-8, -8],
|
|
27
|
-
})
|
|
28
|
-
return marker
|
|
21
|
+
});
|
|
22
|
+
return marker;
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
function createImgVirtul(onPointerDown: () => void) {
|
|
32
|
-
const img = document.createElement(
|
|
33
|
-
img.src = iconAdd
|
|
34
|
-
img.width = 16
|
|
35
|
-
img.height = 16
|
|
36
|
-
img.style.cursor =
|
|
37
|
-
img.addEventListener(
|
|
26
|
+
const img = document.createElement("img");
|
|
27
|
+
img.src = iconAdd;
|
|
28
|
+
img.width = 16;
|
|
29
|
+
img.height = 16;
|
|
30
|
+
img.style.cursor = "pointer";
|
|
31
|
+
img.addEventListener("pointerdown", onPointerDown);
|
|
38
32
|
const marker = new minemap.Marker({
|
|
39
33
|
draggable: false,
|
|
40
34
|
element: img,
|
|
41
35
|
offset: [-8, -8],
|
|
42
|
-
})
|
|
43
|
-
return marker
|
|
36
|
+
});
|
|
37
|
+
return marker;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
|
-
|
|
47
40
|
function getPolygonOption(polygon: Polygon<unknown>) {
|
|
48
|
-
const [color, opacity] = dealColor(polygon.fill)
|
|
41
|
+
const [color, opacity] = dealColor(polygon.fill);
|
|
49
42
|
return {
|
|
50
43
|
id: polygon.name,
|
|
51
44
|
source: polygon.name,
|
|
52
45
|
type: "fill",
|
|
53
46
|
layout: {
|
|
54
|
-
visibility: polygon.show ? "visible" :
|
|
47
|
+
visibility: polygon.show ? "visible" : "none",
|
|
55
48
|
},
|
|
56
49
|
paint: {
|
|
57
50
|
"fill-color": color,
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
51
|
+
"fill-opacity": opacity,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
function getPolylineOption(polygon: Polygon<unknown>) {
|
|
64
57
|
return {
|
|
65
|
-
id: polygon.name +
|
|
58
|
+
id: polygon.name + "_outline",
|
|
66
59
|
source: polygon.name,
|
|
67
60
|
type: "line",
|
|
68
61
|
translation: [0, 0, 1000],
|
|
69
62
|
"depth-test": false,
|
|
70
63
|
layout: {
|
|
71
|
-
visibility: polygon.show ? "visible" :
|
|
72
|
-
},
|
|
73
|
-
paint: polygon.dash ? {
|
|
74
|
-
"line-dasharray": [10, 10],
|
|
75
|
-
"line-color": polygon.stroke,
|
|
76
|
-
"line-width": polygon.lineWidth
|
|
77
|
-
} : {
|
|
78
|
-
"line-color": polygon.stroke,
|
|
79
|
-
"line-width": polygon.lineWidth
|
|
64
|
+
visibility: polygon.show ? "visible" : "none",
|
|
80
65
|
},
|
|
81
|
-
|
|
66
|
+
paint: polygon.dash
|
|
67
|
+
? {
|
|
68
|
+
"line-dasharray": [10, 10],
|
|
69
|
+
"line-color": polygon.stroke,
|
|
70
|
+
"line-width": polygon.lineWidth,
|
|
71
|
+
}
|
|
72
|
+
: {
|
|
73
|
+
"line-color": polygon.stroke,
|
|
74
|
+
"line-width": polygon.lineWidth,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
82
77
|
}
|
|
83
78
|
|
|
84
|
-
|
|
85
79
|
function main(map: MineMap, polygon: Polygon<unknown>) {
|
|
86
|
-
const { viewer } = map
|
|
80
|
+
const { viewer } = map;
|
|
87
81
|
const data = {
|
|
88
82
|
type: "FeatureCollection",
|
|
89
83
|
features: [],
|
|
90
|
-
}
|
|
84
|
+
};
|
|
91
85
|
viewer.addSource(polygon.name, {
|
|
92
86
|
type: "geojson",
|
|
93
|
-
data
|
|
87
|
+
data,
|
|
94
88
|
});
|
|
95
89
|
|
|
96
|
-
const cource = viewer.getSource(polygon.name)
|
|
90
|
+
const cource = viewer.getSource(polygon.name);
|
|
97
91
|
|
|
98
92
|
viewer.addLayer(getPolylineOption(polygon));
|
|
99
93
|
viewer.addLayer(getPolygonOption(polygon));
|
|
100
94
|
|
|
101
|
-
let status = 0
|
|
102
|
-
let skip = 0
|
|
103
|
-
const editor = new PolygonEditor<any, any>()
|
|
104
|
-
let activeNode: ChainNode<any, any
|
|
105
|
-
editor.on(
|
|
106
|
-
if (n.type ==
|
|
107
|
-
const maker = createImgNode(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
95
|
+
let status = 0;
|
|
96
|
+
let skip = 0;
|
|
97
|
+
const editor = new PolygonEditor<any, any>();
|
|
98
|
+
let activeNode: ChainNode<any, any>;
|
|
99
|
+
editor.on("create-node", (n) => {
|
|
100
|
+
if (n.type == "node") {
|
|
101
|
+
const maker = createImgNode(
|
|
102
|
+
() => {
|
|
103
|
+
status = 4;
|
|
104
|
+
activeNode = n;
|
|
105
|
+
map.moveable = false;
|
|
106
|
+
},
|
|
107
|
+
() => {
|
|
108
|
+
if (status == 4) {
|
|
109
|
+
status = 3;
|
|
110
|
+
map.moveable = true;
|
|
111
|
+
activeNode = undefined;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
() => {
|
|
115
|
+
n.destroy();
|
|
116
|
+
updateCoordinate(editor.getCoordinates());
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
maker.setLngLat(n.position).addTo(viewer);
|
|
122
120
|
|
|
123
|
-
n.shape = maker
|
|
121
|
+
n.shape = maker;
|
|
124
122
|
} else {
|
|
125
123
|
const maker = createImgVirtul(() => {
|
|
126
|
-
status = 4
|
|
127
|
-
activeNode = n.insert()
|
|
128
|
-
map.moveable = false
|
|
129
|
-
})
|
|
130
|
-
maker.setLngLat(n.position).addTo(viewer)
|
|
131
|
-
viewer.addMarker(maker)
|
|
132
|
-
n.shape = maker
|
|
124
|
+
status = 4;
|
|
125
|
+
activeNode = n.insert();
|
|
126
|
+
map.moveable = false;
|
|
127
|
+
});
|
|
128
|
+
maker.setLngLat(n.position).addTo(viewer);
|
|
129
|
+
viewer.addMarker(maker);
|
|
130
|
+
n.shape = maker;
|
|
133
131
|
}
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
editor.on(
|
|
137
|
-
n.shape.setLngLat(n.position)
|
|
138
|
-
})
|
|
139
|
-
editor.on(
|
|
140
|
-
viewer.removeMarker(n.shape)
|
|
141
|
-
})
|
|
142
|
-
editor.on(
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
editor.on("update-node", (n) => {
|
|
135
|
+
n.shape.setLngLat(n.position);
|
|
136
|
+
});
|
|
137
|
+
editor.on("remove-node", (n) => {
|
|
138
|
+
viewer.removeMarker(n.shape);
|
|
139
|
+
});
|
|
140
|
+
editor.on("empty", () => {
|
|
143
141
|
// source.removeFeature(feature)
|
|
144
|
-
status = 0
|
|
145
|
-
})
|
|
142
|
+
status = 0;
|
|
143
|
+
});
|
|
146
144
|
|
|
147
145
|
const updateCoordinate = (coordinates) => {
|
|
148
146
|
if (coordinates) {
|
|
@@ -155,234 +153,226 @@ function main(map: MineMap, polygon: Polygon<unknown>) {
|
|
|
155
153
|
properties: {
|
|
156
154
|
id: polygon.name,
|
|
157
155
|
},
|
|
158
|
-
}
|
|
156
|
+
};
|
|
159
157
|
} else {
|
|
160
|
-
data.features = []
|
|
158
|
+
data.features = [];
|
|
161
159
|
}
|
|
162
|
-
cource.setData(data)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
160
|
+
cource.setData(data);
|
|
161
|
+
};
|
|
168
162
|
|
|
169
163
|
if (polygon.coordinates) {
|
|
170
|
-
status = 2
|
|
171
|
-
updateCoordinate(polygon.coordinates)
|
|
164
|
+
status = 2;
|
|
165
|
+
updateCoordinate(polygon.coordinates);
|
|
172
166
|
}
|
|
173
167
|
const onUpdate = (e: Set<string>) => {
|
|
174
168
|
if (skip) {
|
|
175
|
-
skip
|
|
176
|
-
return
|
|
169
|
+
skip--;
|
|
170
|
+
return;
|
|
177
171
|
}
|
|
178
172
|
|
|
179
|
-
const keys = new Set()
|
|
173
|
+
const keys = new Set();
|
|
180
174
|
|
|
181
|
-
e.forEach(key => {
|
|
175
|
+
e.forEach((key) => {
|
|
182
176
|
switch (key) {
|
|
183
|
-
case
|
|
184
|
-
keys.add(
|
|
185
|
-
keys.add(
|
|
177
|
+
case "show":
|
|
178
|
+
keys.add("polyline");
|
|
179
|
+
keys.add("polygon");
|
|
186
180
|
break;
|
|
187
|
-
case
|
|
181
|
+
case "editable":
|
|
188
182
|
break;
|
|
189
|
-
case
|
|
190
|
-
updateCoordinate(polygon.coordinates)
|
|
183
|
+
case "coordinates":
|
|
184
|
+
updateCoordinate(polygon.coordinates);
|
|
191
185
|
if (status == 3) {
|
|
192
|
-
editor.setCoordinates([])
|
|
186
|
+
editor.setCoordinates([]);
|
|
193
187
|
}
|
|
194
188
|
if (polygon.coordinates) {
|
|
195
|
-
status = 2
|
|
196
|
-
|
|
189
|
+
status = 2;
|
|
197
190
|
} else {
|
|
198
|
-
status = 0
|
|
199
|
-
|
|
191
|
+
status = 0;
|
|
200
192
|
}
|
|
201
193
|
|
|
202
194
|
break;
|
|
203
|
-
case
|
|
204
|
-
keys.add(
|
|
205
|
-
break
|
|
206
|
-
case
|
|
207
|
-
keys.add(
|
|
195
|
+
case "fill":
|
|
196
|
+
keys.add("polygon");
|
|
197
|
+
break;
|
|
198
|
+
case "lineWidth":
|
|
199
|
+
keys.add("polyline");
|
|
208
200
|
break;
|
|
209
|
-
case
|
|
210
|
-
keys.add(
|
|
201
|
+
case "stroke":
|
|
202
|
+
keys.add("polyline");
|
|
211
203
|
break;
|
|
212
|
-
case
|
|
213
|
-
keys.add(
|
|
204
|
+
case "dash":
|
|
205
|
+
keys.add("polyline");
|
|
214
206
|
break;
|
|
215
207
|
default:
|
|
216
|
-
throw new Error(`${key} 还不支持修改`)
|
|
208
|
+
throw new Error(`${key} 还不支持修改`);
|
|
217
209
|
}
|
|
218
|
-
})
|
|
210
|
+
});
|
|
219
211
|
|
|
220
|
-
keys.forEach(e => {
|
|
212
|
+
keys.forEach((e) => {
|
|
221
213
|
switch (e) {
|
|
222
|
-
case
|
|
223
|
-
viewer.removeLayer(polygon.name +
|
|
214
|
+
case "polyline":
|
|
215
|
+
viewer.removeLayer(polygon.name + "_outline");
|
|
224
216
|
viewer.addLayer(getPolylineOption(polygon));
|
|
225
217
|
break;
|
|
226
|
-
case
|
|
227
|
-
viewer.removeLayer(polygon.name)
|
|
218
|
+
case "polygon":
|
|
219
|
+
viewer.removeLayer(polygon.name);
|
|
228
220
|
viewer.addLayer(getPolygonOption(polygon));
|
|
229
221
|
break;
|
|
230
222
|
}
|
|
231
|
-
})
|
|
232
|
-
}
|
|
223
|
+
});
|
|
224
|
+
};
|
|
233
225
|
|
|
234
226
|
const onPointerIn = () => {
|
|
235
227
|
if (status == 2) {
|
|
236
|
-
map.cursor = polygon.cursor
|
|
237
|
-
polygon.event.trigger(
|
|
228
|
+
map.cursor = polygon.cursor;
|
|
229
|
+
polygon.event.trigger("pointer-in");
|
|
238
230
|
}
|
|
239
|
-
|
|
240
|
-
}
|
|
231
|
+
};
|
|
241
232
|
|
|
242
233
|
const onPointerOut = () => {
|
|
243
234
|
if (status == 2) {
|
|
244
|
-
map.cursor =
|
|
245
|
-
polygon.event.trigger(
|
|
235
|
+
map.cursor = "default";
|
|
236
|
+
polygon.event.trigger("pointer-out");
|
|
246
237
|
}
|
|
247
|
-
}
|
|
238
|
+
};
|
|
248
239
|
|
|
249
|
-
let cache = []
|
|
240
|
+
let cache = [];
|
|
250
241
|
|
|
251
242
|
const onClick = (e: any) => {
|
|
252
243
|
switch (status) {
|
|
253
244
|
case 0:
|
|
254
|
-
status = 1
|
|
255
|
-
cache = [
|
|
245
|
+
status = 1;
|
|
246
|
+
cache = [
|
|
247
|
+
[e.lngLat.lng, e.lngLat.lat],
|
|
248
|
+
[e.lngLat.lng, e.lngLat.lat],
|
|
249
|
+
];
|
|
256
250
|
break;
|
|
257
251
|
case 1:
|
|
258
|
-
cache.push(cache[cache.length - 1])
|
|
252
|
+
cache.push(cache[cache.length - 1]);
|
|
259
253
|
break;
|
|
260
254
|
}
|
|
261
|
-
}
|
|
255
|
+
};
|
|
262
256
|
|
|
263
257
|
const onPointerMove = (e: any) => {
|
|
264
258
|
switch (status) {
|
|
265
259
|
case 1:
|
|
266
|
-
cache.pop()
|
|
267
|
-
cache.push([e.lngLat.lng, e.lngLat.lat])
|
|
268
|
-
updateCoordinate(cache)
|
|
260
|
+
cache.pop();
|
|
261
|
+
cache.push([e.lngLat.lng, e.lngLat.lat]);
|
|
262
|
+
updateCoordinate(cache);
|
|
269
263
|
break;
|
|
270
264
|
case 4:
|
|
271
|
-
activeNode.update([e.lngLat.lng, e.lngLat.lat])
|
|
272
|
-
updateCoordinate(editor.getCoordinates())
|
|
265
|
+
activeNode.update([e.lngLat.lng, e.lngLat.lat]);
|
|
266
|
+
updateCoordinate(editor.getCoordinates());
|
|
273
267
|
|
|
274
268
|
break;
|
|
275
269
|
}
|
|
276
|
-
}
|
|
270
|
+
};
|
|
277
271
|
|
|
278
272
|
const onDbClick = () => {
|
|
279
273
|
switch (status) {
|
|
280
274
|
case 1:
|
|
281
|
-
status = 2
|
|
282
|
-
skip
|
|
283
|
-
cache.pop()
|
|
284
|
-
cache.pop()
|
|
285
|
-
polygon.coordinates = cache
|
|
286
|
-
polygon.event.trigger(
|
|
275
|
+
status = 2;
|
|
276
|
+
skip++;
|
|
277
|
+
cache.pop();
|
|
278
|
+
cache.pop();
|
|
279
|
+
polygon.coordinates = cache;
|
|
280
|
+
polygon.event.trigger("pointer-in");
|
|
287
281
|
break;
|
|
288
282
|
case 3:
|
|
289
283
|
if (!skip) {
|
|
290
|
-
polygon.event.trigger(
|
|
284
|
+
polygon.event.trigger("stop-edit");
|
|
291
285
|
} else {
|
|
292
|
-
skip = 0
|
|
286
|
+
skip = 0;
|
|
293
287
|
}
|
|
294
288
|
break;
|
|
295
289
|
}
|
|
296
|
-
}
|
|
290
|
+
};
|
|
297
291
|
|
|
298
292
|
const onLineDbClick = () => {
|
|
299
|
-
|
|
300
293
|
switch (status) {
|
|
301
294
|
case 2:
|
|
302
|
-
polygon.event.trigger(
|
|
295
|
+
polygon.event.trigger("start-edit");
|
|
303
296
|
break;
|
|
304
297
|
}
|
|
305
|
-
}
|
|
298
|
+
};
|
|
306
299
|
|
|
307
300
|
const onLineClick = () => {
|
|
308
301
|
switch (status) {
|
|
309
302
|
case 2:
|
|
310
|
-
polygon.event.trigger(
|
|
303
|
+
polygon.event.trigger("left-click");
|
|
311
304
|
break;
|
|
312
305
|
}
|
|
313
|
-
}
|
|
306
|
+
};
|
|
314
307
|
const onLineRClick = () => {
|
|
315
308
|
if (polygon.menu) {
|
|
316
309
|
map.menu.show(polygon.menu);
|
|
317
310
|
}
|
|
318
311
|
switch (status) {
|
|
319
312
|
case 2:
|
|
320
|
-
polygon.event.trigger(
|
|
313
|
+
polygon.event.trigger("right-click");
|
|
321
314
|
break;
|
|
322
315
|
}
|
|
323
|
-
}
|
|
324
|
-
|
|
316
|
+
};
|
|
325
317
|
|
|
326
318
|
const onStartEdit = () => {
|
|
327
319
|
if (status == 2) {
|
|
328
|
-
status = 3
|
|
329
|
-
map.cursor =
|
|
330
|
-
editor.setCoordinates(polygon.coordinates)
|
|
331
|
-
skip = 1
|
|
320
|
+
status = 3;
|
|
321
|
+
map.cursor = "default";
|
|
322
|
+
editor.setCoordinates(polygon.coordinates);
|
|
323
|
+
skip = 1;
|
|
332
324
|
}
|
|
333
|
-
}
|
|
325
|
+
};
|
|
334
326
|
|
|
335
327
|
const onStopEdit = () => {
|
|
336
328
|
if (status == 3) {
|
|
337
|
-
status = 2
|
|
338
|
-
skip
|
|
339
|
-
polygon.coordinates = editor.getCoordinates()
|
|
340
|
-
editor.setCoordinates([])
|
|
329
|
+
status = 2;
|
|
330
|
+
skip++;
|
|
331
|
+
polygon.coordinates = editor.getCoordinates();
|
|
332
|
+
editor.setCoordinates([]);
|
|
341
333
|
}
|
|
342
|
-
}
|
|
343
|
-
|
|
334
|
+
};
|
|
344
335
|
|
|
345
336
|
const onDestroy = () => {
|
|
346
|
-
viewer.removeLayer(polygon.name)
|
|
347
|
-
viewer.removeSource(polygon.name)
|
|
348
|
-
|
|
349
|
-
viewer.off(
|
|
350
|
-
viewer.off(
|
|
351
|
-
viewer.off(
|
|
352
|
-
viewer.off(
|
|
353
|
-
viewer.off(
|
|
354
|
-
viewer.off(
|
|
355
|
-
viewer.off(
|
|
356
|
-
viewer.off(
|
|
357
|
-
polygon.event.off(
|
|
358
|
-
polygon.event.off(
|
|
359
|
-
polygon.event.off(
|
|
360
|
-
polygon.event.off(
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
viewer.on(
|
|
364
|
-
viewer.on(
|
|
365
|
-
viewer.on(
|
|
366
|
-
viewer.on(
|
|
367
|
-
viewer.on(
|
|
368
|
-
viewer.on(
|
|
369
|
-
viewer.on(
|
|
370
|
-
viewer.on(
|
|
371
|
-
|
|
372
|
-
polygon.event.on(
|
|
373
|
-
polygon.event.on(
|
|
374
|
-
polygon.event.on(
|
|
375
|
-
polygon.event.on(
|
|
337
|
+
viewer.removeLayer(polygon.name);
|
|
338
|
+
viewer.removeSource(polygon.name);
|
|
339
|
+
|
|
340
|
+
viewer.off("mouseover", polygon.name, onPointerIn);
|
|
341
|
+
viewer.off("mouseout", polygon.name, onPointerOut);
|
|
342
|
+
viewer.off("dblclick", polygon.name, onLineDbClick);
|
|
343
|
+
viewer.off("click", polygon.name, onLineClick);
|
|
344
|
+
viewer.off("contextmenu", polygon.name, onLineRClick);
|
|
345
|
+
viewer.off("click", onClick);
|
|
346
|
+
viewer.off("mousemove", onPointerMove);
|
|
347
|
+
viewer.off("dblclick", onDbClick);
|
|
348
|
+
polygon.event.off("update", onUpdate);
|
|
349
|
+
polygon.event.off("destroy", onDestroy);
|
|
350
|
+
polygon.event.off("start-edit", onStartEdit);
|
|
351
|
+
polygon.event.off("stop-edit", onStopEdit);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
viewer.on("mouseover", polygon.name, onPointerIn);
|
|
355
|
+
viewer.on("mouseout", polygon.name, onPointerOut);
|
|
356
|
+
viewer.on("dblclick", polygon.name, onLineDbClick);
|
|
357
|
+
viewer.on("click", polygon.name, onLineClick);
|
|
358
|
+
viewer.on("contextmenu", polygon.name, onLineRClick);
|
|
359
|
+
viewer.on("click", onClick);
|
|
360
|
+
viewer.on("mousemove", onPointerMove);
|
|
361
|
+
viewer.on("dblclick", onDbClick);
|
|
362
|
+
|
|
363
|
+
polygon.event.on("update", onUpdate);
|
|
364
|
+
polygon.event.on("destroy", onDestroy);
|
|
365
|
+
polygon.event.on("start-edit", onStartEdit);
|
|
366
|
+
polygon.event.on("stop-edit", onStopEdit);
|
|
376
367
|
}
|
|
377
368
|
|
|
378
|
-
|
|
379
369
|
export function drawPolygon(map: MineMap, polygon: Polygon<unknown>) {
|
|
380
|
-
const { viewer } = map
|
|
370
|
+
const { viewer } = map;
|
|
381
371
|
if (viewer.loaded()) {
|
|
382
|
-
main(map, polygon)
|
|
372
|
+
main(map, polygon);
|
|
383
373
|
} else {
|
|
384
|
-
viewer.once(
|
|
385
|
-
main(map, polygon)
|
|
386
|
-
})
|
|
374
|
+
viewer.once("load", () => {
|
|
375
|
+
main(map, polygon);
|
|
376
|
+
});
|
|
387
377
|
}
|
|
388
|
-
}
|
|
378
|
+
}
|