@xingm/vmap-cesium-toolbar 0.0.2-alpha.10 → 0.0.2-alpha.12
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/index.js +188 -69
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/libs/CesiumMapDraw.d.ts +23 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91,14 +91,14 @@ class L {
|
|
|
91
91
|
* 应用/切换选中样式(统一逻辑,供调度器和子类共用)
|
|
92
92
|
*/
|
|
93
93
|
applySelectedStyleToEntity(e) {
|
|
94
|
-
|
|
94
|
+
I(e);
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* 恢复原始样式(兼容旧接口,内部仍走统一逻辑)
|
|
98
98
|
*/
|
|
99
99
|
restoreOriginalStyleForEntity(e) {
|
|
100
100
|
const t = e;
|
|
101
|
-
t._isSelected &&
|
|
101
|
+
t._isSelected && I(t);
|
|
102
102
|
}
|
|
103
103
|
constructor(e, t = {}) {
|
|
104
104
|
this.viewer = e, this.scene = e.scene, this.entities = e.entities, this.callbacks = t, this.updateOffsetHeight();
|
|
@@ -199,7 +199,7 @@ class L {
|
|
|
199
199
|
}
|
|
200
200
|
// 其余公共方法(如有需要可在子类中覆盖)
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function I(c) {
|
|
203
203
|
try {
|
|
204
204
|
const t = c._drawOptions?.selected;
|
|
205
205
|
if (!t) return;
|
|
@@ -253,16 +253,16 @@ function j(c) {
|
|
|
253
253
|
console.warn("toggleSelectedStyle failed", e);
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function M(c) {
|
|
257
257
|
return !!c && Number.isFinite(c.x) && Number.isFinite(c.y) && Number.isFinite(c.z);
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function j(c) {
|
|
260
260
|
return !isFinite(c) || isNaN(c) ? "0.00 m" : c >= 1e3 ? `${(c / 1e3).toFixed(2)} km` : `${c.toFixed(2)} m`;
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function R(c) {
|
|
263
263
|
return !isFinite(c) || isNaN(c) ? "0.00 m²" : c >= 1 ? `${c.toFixed(2)} km²` : `${(c * 1e6).toFixed(2)} m²`;
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function W(c, e) {
|
|
266
266
|
const t = n.Cartographic.fromCartesian(c), i = n.Cartographic.fromCartesian(e), r = Math.min(t.longitude, i.longitude), o = Math.max(t.longitude, i.longitude), s = Math.min(t.latitude, i.latitude), a = Math.max(t.latitude, i.latitude);
|
|
267
267
|
return new n.Rectangle(r, s, o, a);
|
|
268
268
|
}
|
|
@@ -276,14 +276,14 @@ function q(c) {
|
|
|
276
276
|
);
|
|
277
277
|
return o * s / 1e6;
|
|
278
278
|
}
|
|
279
|
-
function
|
|
280
|
-
const t = c.filter((o) =>
|
|
279
|
+
function H(c, e = n.Ellipsoid.WGS84) {
|
|
280
|
+
const t = c.filter((o) => M(o));
|
|
281
281
|
if (t.length < 3) return 0;
|
|
282
282
|
let i = 0;
|
|
283
283
|
const r = t.length;
|
|
284
284
|
for (let o = 0; o < r; o++) {
|
|
285
285
|
const s = t[o], a = t[(o + 1) % r];
|
|
286
|
-
if (!
|
|
286
|
+
if (!M(s) || !M(a))
|
|
287
287
|
return 0;
|
|
288
288
|
const l = e.cartesianToCartographic(s), h = e.cartesianToCartographic(a);
|
|
289
289
|
if (!l || !h || !Number.isFinite(l.longitude) || !Number.isFinite(l.latitude) || !Number.isFinite(h.longitude) || !Number.isFinite(h.latitude))
|
|
@@ -293,7 +293,7 @@ function R(c, e = n.Ellipsoid.WGS84) {
|
|
|
293
293
|
return i = Math.abs(i * 6378137 * 6378137 / 2), i / 1e6;
|
|
294
294
|
}
|
|
295
295
|
function J(c) {
|
|
296
|
-
const e = c.filter((o) =>
|
|
296
|
+
const e = c.filter((o) => M(o));
|
|
297
297
|
if (e.length === 0) return n.Cartesian3.ZERO;
|
|
298
298
|
let t = 0, i = 0, r = 0;
|
|
299
299
|
for (let o = 0; o < e.length; o++)
|
|
@@ -354,7 +354,7 @@ class V extends L {
|
|
|
354
354
|
finishDrawing() {
|
|
355
355
|
if (this.tempPositions.length < 2)
|
|
356
356
|
return this.restoreRequestRenderModeIfNeeded(), null;
|
|
357
|
-
const e = this.tempPositions.filter((l) =>
|
|
357
|
+
const e = this.tempPositions.filter((l) => M(l));
|
|
358
358
|
if (e.length < 2)
|
|
359
359
|
return this.restoreRequestRenderModeIfNeeded(), null;
|
|
360
360
|
const t = e.map((l) => {
|
|
@@ -474,7 +474,7 @@ class V extends L {
|
|
|
474
474
|
h.latitude,
|
|
475
475
|
(h.height || 0) + this.offsetHeight
|
|
476
476
|
));
|
|
477
|
-
const m = r % 2 === 0 ? -25 : 25, w =
|
|
477
|
+
const m = r % 2 === 0 ? -25 : 25, w = j(a);
|
|
478
478
|
if (r < this.currentSegmentLabels.length && this.currentSegmentLabels[r].billboard) {
|
|
479
479
|
const g = this.currentSegmentLabels[r];
|
|
480
480
|
if (g.position = new n.ConstantPositionProperty(u), g.billboard.pixelOffset = new n.ConstantProperty(new n.Cartesian2(0, m)), g._groundPosition = d, g._segmentText !== w) {
|
|
@@ -531,7 +531,7 @@ class V extends L {
|
|
|
531
531
|
i.latitude,
|
|
532
532
|
(i.height || 0) + this.offsetHeight
|
|
533
533
|
));
|
|
534
|
-
const a = `总长: ${
|
|
534
|
+
const a = `总长: ${j(e)}`, l = this.createTotalLengthBillboardImage(a);
|
|
535
535
|
if (this.currentTotalLabel && this.currentTotalLabel.billboard)
|
|
536
536
|
this.currentTotalLabel.position = new n.ConstantPositionProperty(o), this.currentTotalLabel.billboard.image = new n.ConstantProperty(l), this.currentTotalLabel._groundPosition = r;
|
|
537
537
|
else {
|
|
@@ -616,9 +616,15 @@ class K extends L {
|
|
|
616
616
|
updateDrawingEntity(e) {
|
|
617
617
|
if (this.scene.mode === n.SceneMode.SCENE3D && !this.scene.globe.tilesLoaded)
|
|
618
618
|
return;
|
|
619
|
-
const i = this.tempPositions.filter((o) =>
|
|
619
|
+
const i = this.tempPositions.filter((o) => M(o)), r = e && M(e) && i.length >= 2 ? [...i, e] : i;
|
|
620
620
|
if (r.length >= 3) {
|
|
621
|
-
const o = r.map((g) =>
|
|
621
|
+
const o = r.map((g) => {
|
|
622
|
+
try {
|
|
623
|
+
return n.Cartographic.fromCartesian(g);
|
|
624
|
+
} catch {
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
}).filter((g) => g && Number.isFinite(g.longitude) && Number.isFinite(g.latitude));
|
|
622
628
|
if (o.length < 3) {
|
|
623
629
|
if (this.currentPolygonEntity) {
|
|
624
630
|
this.entities.remove(this.currentPolygonEntity);
|
|
@@ -684,10 +690,16 @@ class K extends L {
|
|
|
684
690
|
* 完成绘制
|
|
685
691
|
*/
|
|
686
692
|
finishDrawing() {
|
|
687
|
-
const e = this.tempPositions.filter((u) =>
|
|
693
|
+
const e = this.tempPositions.filter((u) => M(u));
|
|
688
694
|
if (e.length < 3)
|
|
689
695
|
return this.restoreRequestRenderModeIfNeeded(), null;
|
|
690
|
-
const t = e.map((u) =>
|
|
696
|
+
const t = e.map((u) => {
|
|
697
|
+
try {
|
|
698
|
+
return n.Cartographic.fromCartesian(u);
|
|
699
|
+
} catch {
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
}).filter((u) => u && Number.isFinite(u.longitude) && Number.isFinite(u.latitude));
|
|
691
703
|
if (t.length < 3)
|
|
692
704
|
return this.restoreRequestRenderModeIfNeeded(), null;
|
|
693
705
|
const i = t.map(
|
|
@@ -742,7 +754,7 @@ class K extends L {
|
|
|
742
754
|
}
|
|
743
755
|
}), r._groundPositions = i, r && (r._drawOptions = this.drawOptions, r._drawType = this.getDrawType(), this.drawOptions?.onClick && (r._onClick = this.drawOptions.onClick), o && (r._borderEntity = o));
|
|
744
756
|
}
|
|
745
|
-
const h =
|
|
757
|
+
const h = H(i, this.scene.globe.ellipsoid);
|
|
746
758
|
if (h > 0) {
|
|
747
759
|
const u = J(i), m = n.Cartographic.fromCartesian(u), w = n.Cartesian3.fromRadians(
|
|
748
760
|
m.longitude,
|
|
@@ -755,7 +767,7 @@ class K extends L {
|
|
|
755
767
|
m.latitude,
|
|
756
768
|
(m.height || 0) + this.offsetHeight
|
|
757
769
|
));
|
|
758
|
-
const p = `面积: ${
|
|
770
|
+
const p = `面积: ${R(h)}`, f = this.createTotalLengthBillboardImage(p), b = this.entities.add({
|
|
759
771
|
position: g,
|
|
760
772
|
billboard: {
|
|
761
773
|
image: f,
|
|
@@ -778,7 +790,7 @@ class K extends L {
|
|
|
778
790
|
entity: r,
|
|
779
791
|
type: "polygon",
|
|
780
792
|
positions: i,
|
|
781
|
-
areaKm2:
|
|
793
|
+
areaKm2: H(i, this.scene.globe.ellipsoid)
|
|
782
794
|
};
|
|
783
795
|
return this.callbacks.onMeasureComplete && this.callbacks.onMeasureComplete(d), this.restoreRequestRenderModeIfNeeded(), this.callbacks.onDrawEnd && this.callbacks.onDrawEnd(r, d), d;
|
|
784
796
|
}
|
|
@@ -825,7 +837,7 @@ class _ extends L {
|
|
|
825
837
|
}
|
|
826
838
|
return;
|
|
827
839
|
}
|
|
828
|
-
const i =
|
|
840
|
+
const i = W(t[0], t[1]), r = n.HeightReference.NONE, o = this.drawOptions?.fillColor ? this.resolveColor(this.drawOptions.fillColor) : n.Color.GREEN, s = this.drawOptions?.strokeColor ? this.resolveColor(this.drawOptions.strokeColor) : this.drawOptions?.outlineColor ? this.resolveColor(this.drawOptions.outlineColor) : n.Color.DARKGREEN, a = this.drawOptions?.strokeWidth ?? this.drawOptions?.outlineWidth ?? 1;
|
|
829
841
|
this.currentRectangleEntity && !this.entities.contains(this.currentRectangleEntity) && (this.currentRectangleEntity = null), this.currentRectangleEntity ? (this.currentRectangleEntity.rectangle.coordinates = new n.ConstantProperty(i), this.currentRectangleEntity.rectangle.heightReference = new n.ConstantProperty(r), this.currentRectangleEntity.rectangle.extrudedHeight = this.offsetHeight > 0 ? new n.ConstantProperty(this.offsetHeight) : void 0, this.currentRectangleEntity.rectangle.material = new n.ColorMaterialProperty(o.withAlpha(0.5)), this.currentRectangleEntity.rectangle.outlineColor = new n.ConstantProperty(s), this.currentRectangleEntity.rectangle.outlineWidth = new n.ConstantProperty(a)) : (this.currentRectangleEntity = this.entities.add({
|
|
830
842
|
rectangle: {
|
|
831
843
|
coordinates: i,
|
|
@@ -844,7 +856,7 @@ class _ extends L {
|
|
|
844
856
|
finishDrawing() {
|
|
845
857
|
if (this.tempPositions.length < 2)
|
|
846
858
|
return this.restoreRequestRenderModeIfNeeded(), null;
|
|
847
|
-
const e = this.tempPositions.filter((m) =>
|
|
859
|
+
const e = this.tempPositions.filter((m) => M(m));
|
|
848
860
|
if (e.length < 2)
|
|
849
861
|
return this.restoreRequestRenderModeIfNeeded(), null;
|
|
850
862
|
const t = e.map((m) => {
|
|
@@ -854,7 +866,7 @@ class _ extends L {
|
|
|
854
866
|
w.latitude,
|
|
855
867
|
w.height || 0
|
|
856
868
|
);
|
|
857
|
-
}), i =
|
|
869
|
+
}), i = W(t[0], t[1]);
|
|
858
870
|
let r = null;
|
|
859
871
|
const o = this.drawOptions?.fillColor ? this.resolveColor(this.drawOptions.fillColor) : n.Color.GREEN, s = this.drawOptions?.strokeColor ? this.resolveColor(this.drawOptions.strokeColor) : this.drawOptions?.outlineColor ? this.resolveColor(this.drawOptions.outlineColor) : n.Color.DARKGREEN, a = this.drawOptions?.strokeWidth ?? this.drawOptions?.outlineWidth ?? 1;
|
|
860
872
|
this.offsetHeight > 0 ? (r = this.entities.add({
|
|
@@ -892,7 +904,7 @@ class _ extends L {
|
|
|
892
904
|
m.latitude,
|
|
893
905
|
this.offsetHeight
|
|
894
906
|
));
|
|
895
|
-
const p = `面积: ${
|
|
907
|
+
const p = `面积: ${R(l)}`, f = this.createTotalLengthBillboardImage(p), b = this.entities.add({
|
|
896
908
|
position: g,
|
|
897
909
|
billboard: {
|
|
898
910
|
image: f,
|
|
@@ -1077,7 +1089,7 @@ class $ extends L {
|
|
|
1077
1089
|
o._groundPosition = i, o._radius = r, o && (o._drawOptions = this.drawOptions, o._drawType = this.getDrawType(), this.drawOptions?.onClick && (o._onClick = this.drawOptions.onClick));
|
|
1078
1090
|
const d = Math.PI * r * r / 1e6;
|
|
1079
1091
|
if (d > 0) {
|
|
1080
|
-
const f = `面积: ${
|
|
1092
|
+
const f = `面积: ${R(d)}`, b = this.createTotalLengthBillboardImage(f), C = this.entities.add({
|
|
1081
1093
|
position: s,
|
|
1082
1094
|
billboard: {
|
|
1083
1095
|
image: b,
|
|
@@ -1158,6 +1170,10 @@ class D {
|
|
|
1158
1170
|
// 双击判断
|
|
1159
1171
|
// 最近一次鼠标移动位置,用于在右键删点后立即重绘预览
|
|
1160
1172
|
lastPreviewPosition = null;
|
|
1173
|
+
// 绘制步骤提示(跟随鼠标的提示 Label)
|
|
1174
|
+
drawHintEntity = null;
|
|
1175
|
+
drawHintText = "";
|
|
1176
|
+
drawHintLastPosition = null;
|
|
1161
1177
|
// 静态:当前处于绘制状态的 DrawHelper,用于跨实例互斥
|
|
1162
1178
|
static activeDrawingHelper = null;
|
|
1163
1179
|
// 绘制类实例
|
|
@@ -1219,7 +1235,7 @@ class D {
|
|
|
1219
1235
|
} catch (d) {
|
|
1220
1236
|
console.warn("entity onClick handler error", d);
|
|
1221
1237
|
}
|
|
1222
|
-
s._drawOptions?.selected &&
|
|
1238
|
+
s._drawOptions?.selected && I(s);
|
|
1223
1239
|
}, n.ScreenSpaceEventType.LEFT_CLICK);
|
|
1224
1240
|
} catch (i) {
|
|
1225
1241
|
console.warn("entity click handler init failed", i);
|
|
@@ -1230,7 +1246,7 @@ class D {
|
|
|
1230
1246
|
*/
|
|
1231
1247
|
handleSceneModeChanged() {
|
|
1232
1248
|
const e = this.offsetHeight;
|
|
1233
|
-
this.updateOffsetHeight(), e !== this.offsetHeight && this.updateFinishedEntitiesForModeChange();
|
|
1249
|
+
this.updateOffsetHeight(), e !== this.offsetHeight && this.updateFinishedEntitiesForModeChange(), this.isDrawing && this.drawHintLastPosition && this.updateDrawHintPosition(this.drawHintLastPosition);
|
|
1234
1250
|
}
|
|
1235
1251
|
/**
|
|
1236
1252
|
* 根据场景模式更新偏移高度
|
|
@@ -1238,6 +1254,97 @@ class D {
|
|
|
1238
1254
|
updateOffsetHeight() {
|
|
1239
1255
|
this.scene.mode === n.SceneMode.SCENE3D ? this.offsetHeight = 1 : this.offsetHeight = 0;
|
|
1240
1256
|
}
|
|
1257
|
+
/**
|
|
1258
|
+
* 计算提示文本(随绘制模式 + 点数量变化)
|
|
1259
|
+
*/
|
|
1260
|
+
getDrawHintText() {
|
|
1261
|
+
if (!this.isDrawing || !this.drawMode)
|
|
1262
|
+
return "";
|
|
1263
|
+
const e = this.tempPositions.length;
|
|
1264
|
+
switch (this.drawMode) {
|
|
1265
|
+
case "circle":
|
|
1266
|
+
return e === 0 ? "单击确定圆心" : e === 1 ? "移动鼠标确定半径,单击确定半径点,双击完成,右键撤销" : "双击完成,右键撤销";
|
|
1267
|
+
case "rectangle":
|
|
1268
|
+
return e === 0 ? "单击确定起点" : e === 1 ? "移动鼠标确定终点,单击确定终点,双击完成,右键撤销" : "双击完成,右键撤销";
|
|
1269
|
+
case "polygon":
|
|
1270
|
+
return e === 0 ? "单击开始绘制" : "单击继续添加点,双击完成,右键删除最后一点";
|
|
1271
|
+
case "line":
|
|
1272
|
+
return e === 0 ? "单击开始绘制" : "单击继续添加点,双击完成,右键删除最后一点";
|
|
1273
|
+
default:
|
|
1274
|
+
return "";
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* 将提示位置转换为显示位置(按当前模式做轻微抬高,避免被地形遮挡)
|
|
1279
|
+
*/
|
|
1280
|
+
toHintDisplayPosition(e) {
|
|
1281
|
+
try {
|
|
1282
|
+
const t = n.Cartographic.fromCartesian(e), i = t.height || 0, r = this.offsetHeight > 0 ? this.offsetHeight : 0.1;
|
|
1283
|
+
return n.Cartesian3.fromRadians(
|
|
1284
|
+
t.longitude,
|
|
1285
|
+
t.latitude,
|
|
1286
|
+
i + r
|
|
1287
|
+
);
|
|
1288
|
+
} catch {
|
|
1289
|
+
return e;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* 创建或更新提示实体的位置与文本
|
|
1294
|
+
*/
|
|
1295
|
+
updateDrawHintPosition(e) {
|
|
1296
|
+
if (!this.isDrawing) return;
|
|
1297
|
+
const t = this.getDrawHintText();
|
|
1298
|
+
if (!t) {
|
|
1299
|
+
this.clearDrawHint();
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
this.drawHintText = t, this.drawHintLastPosition = e.clone();
|
|
1303
|
+
const i = this.toHintDisplayPosition(e);
|
|
1304
|
+
this.drawHintEntity ? (this.drawHintEntity.position = new n.ConstantPositionProperty(i), this.drawHintEntity.label && (this.drawHintEntity.label.text = new n.ConstantProperty(this.drawHintText))) : this.drawHintEntity = this.entities.add({
|
|
1305
|
+
position: new n.ConstantPositionProperty(i),
|
|
1306
|
+
label: {
|
|
1307
|
+
text: this.drawHintText,
|
|
1308
|
+
font: "14px 'Microsoft YaHei', 'PingFang SC', sans-serif",
|
|
1309
|
+
showBackground: !0,
|
|
1310
|
+
backgroundColor: n.Color.BLACK.withAlpha(0.75),
|
|
1311
|
+
fillColor: n.Color.WHITE,
|
|
1312
|
+
outlineColor: n.Color.BLACK,
|
|
1313
|
+
outlineWidth: 2,
|
|
1314
|
+
style: n.LabelStyle.FILL_AND_OUTLINE,
|
|
1315
|
+
pixelOffset: new n.Cartesian2(12, -18),
|
|
1316
|
+
horizontalOrigin: n.HorizontalOrigin.LEFT,
|
|
1317
|
+
verticalOrigin: n.VerticalOrigin.TOP,
|
|
1318
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1319
|
+
heightReference: n.HeightReference.NONE,
|
|
1320
|
+
scaleByDistance: new n.NearFarScalar(150, 1, 15e6, 0.6)
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* 更新提示文本(不改变位置;通常在点数变化时调用)
|
|
1326
|
+
*/
|
|
1327
|
+
refreshDrawHintTextOnly() {
|
|
1328
|
+
const e = this.getDrawHintText();
|
|
1329
|
+
if (this.drawHintText = e, !e) {
|
|
1330
|
+
this.clearDrawHint();
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
this.drawHintEntity?.label && (this.drawHintEntity.label.text = new n.ConstantProperty(e));
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* 清除绘制提示实体
|
|
1337
|
+
*/
|
|
1338
|
+
clearDrawHint() {
|
|
1339
|
+
if (this.drawHintEntity) {
|
|
1340
|
+
try {
|
|
1341
|
+
this.entities.remove(this.drawHintEntity);
|
|
1342
|
+
} catch {
|
|
1343
|
+
}
|
|
1344
|
+
this.drawHintEntity = null;
|
|
1345
|
+
}
|
|
1346
|
+
this.drawHintText = "", this.drawHintLastPosition = null;
|
|
1347
|
+
}
|
|
1241
1348
|
/**
|
|
1242
1349
|
* 开始绘制线条
|
|
1243
1350
|
*/
|
|
@@ -1268,7 +1375,7 @@ class D {
|
|
|
1268
1375
|
*/
|
|
1269
1376
|
startDrawing(e, t) {
|
|
1270
1377
|
const i = D.activeDrawingHelper;
|
|
1271
|
-
switch (i && i !== this && i.cancelDrawing(), this.endDrawingInternal(!1), this.drawMode = e, this.isDrawing = !0, this.lastPreviewPosition = null, D.activeDrawingHelper = this, this.tempPositions = [], this.tempEntities = [], this._doubleClickPending = !1, e) {
|
|
1378
|
+
switch (i && i !== this && i.cancelDrawing(), this.endDrawingInternal(!1), this.clearDrawHint(), this.drawMode = e, this.isDrawing = !0, this.lastPreviewPosition = null, D.activeDrawingHelper = this, this.tempPositions = [], this.tempEntities = [], this._doubleClickPending = !1, e) {
|
|
1272
1379
|
case "line":
|
|
1273
1380
|
this.currentDrawer = this.drawLine;
|
|
1274
1381
|
break;
|
|
@@ -1282,7 +1389,7 @@ class D {
|
|
|
1282
1389
|
this.currentDrawer = this.drawCircle;
|
|
1283
1390
|
break;
|
|
1284
1391
|
}
|
|
1285
|
-
this.currentDrawer && this.currentDrawer.startDrawing(t), this.activateDrawingHandlers();
|
|
1392
|
+
this.currentDrawer && this.currentDrawer.startDrawing(t), this.refreshDrawHintTextOnly(), this.activateDrawingHandlers();
|
|
1286
1393
|
}
|
|
1287
1394
|
/**
|
|
1288
1395
|
* 激活屏幕空间事件处理器
|
|
@@ -1298,16 +1405,16 @@ class D {
|
|
|
1298
1405
|
return;
|
|
1299
1406
|
}
|
|
1300
1407
|
const i = this.pickGlobePosition(t.position);
|
|
1301
|
-
i && this.addPoint(i);
|
|
1408
|
+
i && (this.updateDrawHintPosition(i), this.addPoint(i));
|
|
1302
1409
|
},
|
|
1303
1410
|
n.ScreenSpaceEventType.LEFT_CLICK
|
|
1304
1411
|
), this.screenSpaceEventHandler.setInputAction(() => {
|
|
1305
1412
|
!this.isDrawing || this.tempPositions.length === 0 || this.removeLastPoint();
|
|
1306
1413
|
}, n.ScreenSpaceEventType.RIGHT_CLICK), this.screenSpaceEventHandler.setInputAction(
|
|
1307
1414
|
(t) => {
|
|
1308
|
-
if (!this.isDrawing
|
|
1415
|
+
if (!this.isDrawing) return;
|
|
1309
1416
|
const i = this.pickGlobePosition(t.endPosition);
|
|
1310
|
-
i && this.updatePreview(i);
|
|
1417
|
+
i && (this.updateDrawHintPosition(i), this.tempPositions.length > 0 && this.updatePreview(i));
|
|
1311
1418
|
},
|
|
1312
1419
|
n.ScreenSpaceEventType.MOUSE_MOVE
|
|
1313
1420
|
);
|
|
@@ -1318,10 +1425,15 @@ class D {
|
|
|
1318
1425
|
n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
|
|
1319
1426
|
), this.screenSpaceEventHandler.setInputAction(
|
|
1320
1427
|
(t) => {
|
|
1321
|
-
|
|
1428
|
+
if (!this.isDrawing) return;
|
|
1429
|
+
if (!this.pickGlobePosition(t.position)) {
|
|
1430
|
+
console.warn("Double-click event ignored: not on the map.");
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
this._doubleClickPending = !0, this.finishDrawing(), e && this.viewer.cesiumWidget.screenSpaceEventHandler.setInputAction(
|
|
1322
1434
|
e,
|
|
1323
1435
|
n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
|
|
1324
|
-
)
|
|
1436
|
+
);
|
|
1325
1437
|
},
|
|
1326
1438
|
n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
|
|
1327
1439
|
);
|
|
@@ -1332,24 +1444,31 @@ class D {
|
|
|
1332
1444
|
* @returns 世界坐标 Cartesian3 或 null
|
|
1333
1445
|
*/
|
|
1334
1446
|
pickGlobePosition(e) {
|
|
1335
|
-
const t =
|
|
1336
|
-
if (t
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1447
|
+
const t = e;
|
|
1448
|
+
if (!t || !Number.isFinite(t.x) || !Number.isFinite(t.y))
|
|
1449
|
+
return null;
|
|
1450
|
+
try {
|
|
1451
|
+
const i = this.viewer.camera.getPickRay(e);
|
|
1452
|
+
if (i && this.scene.mode === n.SceneMode.SCENE3D && this.scene.globe.tilesLoaded) {
|
|
1453
|
+
const o = this.scene.globe.pick(i, this.scene);
|
|
1454
|
+
if (n.defined(o) && Number.isFinite(o.x) && Number.isFinite(o.y) && Number.isFinite(o.z))
|
|
1455
|
+
return o.clone();
|
|
1456
|
+
}
|
|
1457
|
+
const r = this.viewer.camera.pickEllipsoid(
|
|
1458
|
+
e,
|
|
1459
|
+
this.scene.globe.ellipsoid
|
|
1460
|
+
);
|
|
1461
|
+
return r && Number.isFinite(r.x) && Number.isFinite(r.y) && Number.isFinite(r.z) ? r.clone() : null;
|
|
1462
|
+
} catch {
|
|
1463
|
+
return null;
|
|
1340
1464
|
}
|
|
1341
|
-
const i = this.viewer.camera.pickEllipsoid(
|
|
1342
|
-
e,
|
|
1343
|
-
this.scene.globe.ellipsoid
|
|
1344
|
-
);
|
|
1345
|
-
return i && Number.isFinite(i.x) && Number.isFinite(i.y) && Number.isFinite(i.z) ? i : null;
|
|
1346
1465
|
}
|
|
1347
1466
|
/**
|
|
1348
1467
|
* 添加一个点到临时位置数组并创建点实体
|
|
1349
1468
|
* @param position 世界坐标
|
|
1350
1469
|
*/
|
|
1351
1470
|
addPoint(e) {
|
|
1352
|
-
this.drawMode === "polygon" && this.scene.mode === n.SceneMode.SCENE3D && !this.scene.globe.tilesLoaded || this.currentDrawer && (this.currentDrawer.addPointForHelper(e), this.tempPositions = this.currentDrawer.getTempPositions(), this.tempEntities = this.currentDrawer.getTempEntities(), this.updateDrawingEntity());
|
|
1471
|
+
this.drawMode === "polygon" && this.scene.mode === n.SceneMode.SCENE3D && !this.scene.globe.tilesLoaded || this.currentDrawer && (this.currentDrawer.addPointForHelper(e), this.tempPositions = this.currentDrawer.getTempPositions(), this.tempEntities = this.currentDrawer.getTempEntities(), this.updateDrawingEntity(), this.refreshDrawHintTextOnly());
|
|
1353
1472
|
}
|
|
1354
1473
|
/**
|
|
1355
1474
|
* 删除最后一个添加的点及其相关的临时实体
|
|
@@ -1358,7 +1477,7 @@ class D {
|
|
|
1358
1477
|
if (!this.currentDrawer)
|
|
1359
1478
|
return;
|
|
1360
1479
|
const e = this.currentDrawer.getTempPositions();
|
|
1361
|
-
!e || e.length === 0 || (this.currentDrawer.removeLastPointAndRedraw(), this.tempPositions = this.currentDrawer.getTempPositions(), this.tempEntities = this.currentDrawer.getTempEntities(), this.tempLabelEntities = this.currentDrawer.getTempLabelEntities(), this.lastPreviewPosition && this.isDrawing && this.updateDrawingEntity(this.lastPreviewPosition));
|
|
1480
|
+
!e || e.length === 0 || (this.currentDrawer.removeLastPointAndRedraw(), this.tempPositions = this.currentDrawer.getTempPositions(), this.tempEntities = this.currentDrawer.getTempEntities(), this.tempLabelEntities = this.currentDrawer.getTempLabelEntities(), this.lastPreviewPosition && this.isDrawing && this.updateDrawingEntity(this.lastPreviewPosition), this.refreshDrawHintTextOnly());
|
|
1362
1481
|
}
|
|
1363
1482
|
/**
|
|
1364
1483
|
* 更新预览线/面
|
|
@@ -1393,7 +1512,7 @@ class D {
|
|
|
1393
1512
|
}
|
|
1394
1513
|
e && e.entity && this.finishedEntities.push(e.entity), this.tempPositions = this.currentDrawer.getTempPositions(), this.tempEntities = this.currentDrawer.getTempEntities(), this.tempLabelEntities = this.currentDrawer.getTempLabelEntities(), this.finishedPointEntities = this.currentDrawer.getFinishedPointEntities(), this.tempLabelEntities.forEach((t) => {
|
|
1395
1514
|
this.finishedLabelEntities.push(t);
|
|
1396
|
-
}), this.tempLabelEntities = [], this.drawMode = null, this.isDrawing = !1, this.lastPreviewPosition = null, this.currentDrawer = null, this.deactivateDrawingHandlers(), D.activeDrawingHelper === this && (D.activeDrawingHelper = null);
|
|
1515
|
+
}), this.tempLabelEntities = [], this.drawMode = null, this.isDrawing = !1, this.lastPreviewPosition = null, this.currentDrawer = null, this.deactivateDrawingHandlers(), this.clearDrawHint(), D.activeDrawingHelper === this && (D.activeDrawingHelper = null);
|
|
1397
1516
|
}
|
|
1398
1517
|
/**
|
|
1399
1518
|
* 内部方法:重置绘图状态和清理临时数据
|
|
@@ -1401,7 +1520,7 @@ class D {
|
|
|
1401
1520
|
*/
|
|
1402
1521
|
endDrawingInternal(e) {
|
|
1403
1522
|
if (this.currentDrawer && (this.currentDrawer.clearTempEntitiesForHelper(), this.tempPositions = this.currentDrawer.getTempPositions(), this.tempEntities = this.currentDrawer.getTempEntities(), this.tempLabelEntities = this.currentDrawer.getTempLabelEntities()), this.tempEntities = [], this.tempLabelEntities = [], this.tempPositions = [], e) {
|
|
1404
|
-
this.drawMode = null, this.isDrawing = !1, this.lastPreviewPosition = null, this.currentDrawer = null, this.deactivateDrawingHandlers(), this.originalDepthTestAgainstTerrain !== null && (this.scene.globe.depthTestAgainstTerrain = this.originalDepthTestAgainstTerrain, this.originalDepthTestAgainstTerrain = null);
|
|
1523
|
+
this.drawMode = null, this.isDrawing = !1, this.lastPreviewPosition = null, this.currentDrawer = null, this.deactivateDrawingHandlers(), this.clearDrawHint(), this.originalDepthTestAgainstTerrain !== null && (this.scene.globe.depthTestAgainstTerrain = this.originalDepthTestAgainstTerrain, this.originalDepthTestAgainstTerrain = null);
|
|
1405
1524
|
try {
|
|
1406
1525
|
this.currentDrawer && this.currentDrawer.restoreRequestRenderModeIfNeeded && this.currentDrawer.restoreRequestRenderModeIfNeeded();
|
|
1407
1526
|
} catch {
|
|
@@ -2361,12 +2480,12 @@ class le {
|
|
|
2361
2480
|
}
|
|
2362
2481
|
}
|
|
2363
2482
|
}
|
|
2364
|
-
const
|
|
2483
|
+
const z = {
|
|
2365
2484
|
basePath: "/geojson",
|
|
2366
2485
|
silent: !1
|
|
2367
2486
|
};
|
|
2368
2487
|
async function ce(c = {}) {
|
|
2369
|
-
const { basePath: e } = { ...
|
|
2488
|
+
const { basePath: e } = { ...z, ...c };
|
|
2370
2489
|
try {
|
|
2371
2490
|
const t = await fetch(`${e}/file-list.json`);
|
|
2372
2491
|
if (t.ok) {
|
|
@@ -2379,7 +2498,7 @@ async function ce(c = {}) {
|
|
|
2379
2498
|
return [];
|
|
2380
2499
|
}
|
|
2381
2500
|
async function he(c, e = {}) {
|
|
2382
|
-
const { basePath: t, silent: i } = { ...
|
|
2501
|
+
const { basePath: t, silent: i } = { ...z, ...e };
|
|
2383
2502
|
try {
|
|
2384
2503
|
const r = `${t}/${c}.geojson`, o = await fetch(r);
|
|
2385
2504
|
if (!o.ok)
|
|
@@ -2391,7 +2510,7 @@ async function he(c, e = {}) {
|
|
|
2391
2510
|
}
|
|
2392
2511
|
}
|
|
2393
2512
|
async function de(c, e = {}) {
|
|
2394
|
-
const { silent: t } = { ...
|
|
2513
|
+
const { silent: t } = { ...z, ...e };
|
|
2395
2514
|
let i = c;
|
|
2396
2515
|
if ((!i || i.length === 0) && (i = await ce(e)), !i || i.length === 0)
|
|
2397
2516
|
return t || (console.warn("未提供 GeoJSON 文件列表,无法加载数据"), console.warn("请使用 loadAllAirportNoFlyZones(fileList) 提供文件列表,"), console.warn("或在 public/geojson 目录下创建 file-list.json 文件")), [];
|
|
@@ -2972,14 +3091,14 @@ class be {
|
|
|
2972
3091
|
if (this.measurementCallback?.onDistanceComplete)
|
|
2973
3092
|
this.measurementCallback.onDistanceComplete(t, i);
|
|
2974
3093
|
else {
|
|
2975
|
-
const r =
|
|
3094
|
+
const r = j(i);
|
|
2976
3095
|
console.log(`测距完成,总距离: ${r}`);
|
|
2977
3096
|
}
|
|
2978
3097
|
}
|
|
2979
3098
|
} else if (e.polygon) {
|
|
2980
3099
|
const t = e.polygon.hierarchy?.getValue(n.JulianDate.now());
|
|
2981
3100
|
if (t && this.measurementCallback?.onAreaComplete) {
|
|
2982
|
-
const i =
|
|
3101
|
+
const i = H(t.positions, this.viewer.scene.globe.ellipsoid);
|
|
2983
3102
|
this.measurementCallback.onAreaComplete(t.positions, i);
|
|
2984
3103
|
}
|
|
2985
3104
|
}
|
|
@@ -3750,12 +3869,12 @@ class De {
|
|
|
3750
3869
|
return t ? (t._onClick = void 0, this.entities.remove(t)) : !1;
|
|
3751
3870
|
}
|
|
3752
3871
|
}
|
|
3753
|
-
const
|
|
3754
|
-
class
|
|
3872
|
+
const Pe = 1e3, T = "_infoWindowData";
|
|
3873
|
+
class Me {
|
|
3755
3874
|
viewer;
|
|
3756
3875
|
container;
|
|
3757
3876
|
entityMap = /* @__PURE__ */ new Map();
|
|
3758
|
-
currentTopZIndex =
|
|
3877
|
+
currentTopZIndex = Pe;
|
|
3759
3878
|
defaultUpdateInterval = 0;
|
|
3760
3879
|
// ms, 默认 0 = 每帧更新
|
|
3761
3880
|
isCameraMoving = !1;
|
|
@@ -3855,8 +3974,8 @@ class Pe {
|
|
|
3855
3974
|
if (typeof r.anchorPixel == "number" && y)
|
|
3856
3975
|
a = y.x, l = y.y - r.anchorPixel;
|
|
3857
3976
|
else {
|
|
3858
|
-
const x = n.Cartographic.fromCartesian(o), G = n.Math.toDegrees(x.longitude), A = n.Math.toDegrees(x.latitude), Y = n.Cartesian3.fromDegrees(G, A, x.height + h), E = this.getContainerPixelPosition(Y),
|
|
3859
|
-
E &&
|
|
3977
|
+
const x = n.Cartographic.fromCartesian(o), G = n.Math.toDegrees(x.longitude), A = n.Math.toDegrees(x.latitude), Y = n.Cartesian3.fromDegrees(G, A, x.height + h), E = this.getContainerPixelPosition(Y), P = this.getContainerPixelPosition(o);
|
|
3978
|
+
E && P ? (a = E.x, l = E.y) : P && (a = P.x, l = P.y);
|
|
3860
3979
|
}
|
|
3861
3980
|
} catch {
|
|
3862
3981
|
}
|
|
@@ -3968,8 +4087,8 @@ class Pe {
|
|
|
3968
4087
|
})()), i.style.left = `${a}px`, i.style.top = `${l}px`, i.style.transform = C, i.style.display = "block", t.arrowEl && r.showArrow) {
|
|
3969
4088
|
const y = t.arrowEl, x = (r.arrowSize ?? 8) + "px", G = i.style.background || r.backgroundColor || "#ffffff";
|
|
3970
4089
|
y.style.borderLeft = "0", y.style.borderRight = "0", y.style.borderTop = "0", y.style.borderBottom = "0", y.style.left = "", y.style.right = "", y.style.top = "", y.style.bottom = "", y.style.transform = "";
|
|
3971
|
-
const A = (O) => O.startsWith("top") ? "top" : O.startsWith("bottom") ? "bottom" : O.startsWith("left") ? "left" : O.startsWith("right") ? "right" : "top", Y = (O) => O.includes("left") ? 25 : O.includes("right") ? 75 : 50, E = A(b),
|
|
3972
|
-
E === "top" ? (y.style.left = `${
|
|
4090
|
+
const A = (O) => O.startsWith("top") ? "top" : O.startsWith("bottom") ? "bottom" : O.startsWith("left") ? "left" : O.startsWith("right") ? "right" : "top", Y = (O) => O.includes("left") ? 25 : O.includes("right") ? 75 : 50, E = A(b), P = Y(b);
|
|
4091
|
+
E === "top" ? (y.style.left = `${P}%`, y.style.bottom = `-${x}`, y.style.transform = "translateX(-50%)", y.style.borderLeft = `${x} solid transparent`, y.style.borderRight = `${x} solid transparent`, y.style.borderTop = `${x} solid ${G}`) : E === "bottom" ? (y.style.left = `${P}%`, y.style.top = `-${x}`, y.style.transform = "translateX(-50%)", y.style.borderLeft = `${x} solid transparent`, y.style.borderRight = `${x} solid transparent`, y.style.borderBottom = `${x} solid ${G}`) : E === "left" ? (y.style.right = `-${x}`, y.style.top = `${P}%`, y.style.transform = "translateY(-50%)", y.style.borderTop = `${x} solid transparent`, y.style.borderBottom = `${x} solid transparent`, y.style.borderLeft = `${x} solid ${G}`) : (y.style.left = `-${x}`, y.style.top = `${P}%`, y.style.transform = "translateY(-50%)", y.style.borderTop = `${x} solid transparent`, y.style.borderBottom = `${x} solid transparent`, y.style.borderRight = `${x} solid ${G}`);
|
|
3973
4092
|
}
|
|
3974
4093
|
}
|
|
3975
4094
|
/**
|
|
@@ -4901,7 +5020,7 @@ class Ae {
|
|
|
4901
5020
|
circle;
|
|
4902
5021
|
ring;
|
|
4903
5022
|
constructor(e) {
|
|
4904
|
-
this.viewer = e, this.entities = e.entities, this.initInfoWindowContainer(), this.setupEntityClickHandler(), this.marker = new xe(e), this.label = new ve(e), this.icon = new Ge(e), this.svg = new De(e), this.infoWindow = new
|
|
5023
|
+
this.viewer = e, this.entities = e.entities, this.initInfoWindowContainer(), this.setupEntityClickHandler(), this.marker = new xe(e), this.label = new ve(e), this.icon = new Ge(e), this.svg = new De(e), this.infoWindow = new Me(e, this.infoWindowContainer), this.polyline = new Ne(e), this.polygon = new Te(e), this.rectangle = new Ee(e), this.circle = new Oe(e), this.ring = new Le(e);
|
|
4905
5024
|
}
|
|
4906
5025
|
/**
|
|
4907
5026
|
* 初始化信息窗口容器
|
|
@@ -5066,7 +5185,7 @@ class Ae {
|
|
|
5066
5185
|
this.removeAllOverlays(), this.infoWindowContainer && this.infoWindowContainer.parentNode && this.infoWindowContainer.parentNode.removeChild(this.infoWindowContainer), this.overlayMap.clear();
|
|
5067
5186
|
}
|
|
5068
5187
|
}
|
|
5069
|
-
class
|
|
5188
|
+
class Ie {
|
|
5070
5189
|
viewer;
|
|
5071
5190
|
imageryLayer = null;
|
|
5072
5191
|
rectangle = null;
|
|
@@ -5426,7 +5545,7 @@ class je {
|
|
|
5426
5545
|
this.imageryLayer = this.viewer.imageryLayers.addImageryProvider(i), this.imageryLayer.alpha = this.options.opacity, this.imageryLayer.show = !0;
|
|
5427
5546
|
}
|
|
5428
5547
|
}
|
|
5429
|
-
const
|
|
5548
|
+
const je = {
|
|
5430
5549
|
CesiumMapToolbar: be,
|
|
5431
5550
|
DrawHelper: D,
|
|
5432
5551
|
CesiumOverlayService: Ae,
|
|
@@ -5443,10 +5562,10 @@ export {
|
|
|
5443
5562
|
V as DrawLine,
|
|
5444
5563
|
K as DrawPolygon,
|
|
5445
5564
|
_ as DrawRectangle,
|
|
5446
|
-
|
|
5565
|
+
Ie as HeatmapLayer,
|
|
5447
5566
|
Oe as MapCircle,
|
|
5448
5567
|
Ge as MapIcon,
|
|
5449
|
-
|
|
5568
|
+
Me as MapInfoWindow,
|
|
5450
5569
|
ve as MapLabel,
|
|
5451
5570
|
le as MapLayersService,
|
|
5452
5571
|
xe as MapMarker,
|
|
@@ -5457,10 +5576,10 @@ export {
|
|
|
5457
5576
|
De as MapSVG,
|
|
5458
5577
|
ue as NotFlyZonesService,
|
|
5459
5578
|
ae as SearchService,
|
|
5460
|
-
|
|
5579
|
+
je as default,
|
|
5461
5580
|
N as defaultButtonSorts,
|
|
5462
5581
|
we as defaultButtons,
|
|
5463
5582
|
S as initCesium,
|
|
5464
|
-
|
|
5583
|
+
I as toggleSelectedStyle
|
|
5465
5584
|
};
|
|
5466
5585
|
//# sourceMappingURL=index.es.js.map
|