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