btt-ui 1.0.27 → 1.0.28

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/es/index.mjs CHANGED
@@ -1,35 +1,36 @@
1
- import p from "./src/index.mjs";
2
- import * as a from "./src/directives/index.mjs";
3
- import l from "./src/utils/index.mjs";
4
- import { Button as u } from "./src/button/index.mjs";
5
- import { TextButton as T } from "./src/textButton/index.mjs";
6
- import { default as h } from "./src/link/index.mjs";
7
- import { default as b } from "./src/upload/index.mjs";
1
+ import l from "./src/index.mjs";
2
+ import * as m from "./src/directives/index.mjs";
3
+ import { default as s } from "./src/utils/initCesium.mjs";
4
+ import { default as u } from "./src/utils/DrawLinePolygonPolygonUtils.mjs";
5
+ import { Button as T } from "./src/button/index.mjs";
6
+ import { TextButton as h } from "./src/textButton/index.mjs";
7
+ import { default as b } from "./src/link/index.mjs";
8
+ import { default as k } from "./src/upload/index.mjs";
8
9
  import { default as S } from "./src/shake/index.mjs";
9
- import { default as g } from "./src/dialog/index.mjs";
10
- import { default as U } from "./src/scroll/index.mjs";
10
+ import { default as y } from "./src/dialog/index.mjs";
11
+ import { default as L } from "./src/scroll/index.mjs";
11
12
  import { default as E } from "./src/toast/index.mjs";
12
- import { default as I } from "./src/wheel/index.mjs";
13
- import { Switch as M } from "./src/switch/index.mjs";
14
- import { Timeline as G } from "./src/timeline/index.mjs";
15
- import { default as j } from "./src/uploadFile/index.mjs";
16
- import { Card as F } from "./src/card/index.mjs";
17
- import { HotMap as V } from "./src/hotmap/index.mjs";
18
- import { KTree as $ } from "./src/tree/index.mjs";
19
- import { KCheckbox as z, KCheckboxGroup as A } from "./src/checkbox/index.mjs";
20
- import { KCollapse as P, KCollapseItem as Q } from "./src/collapse/index.mjs";
21
- import { Sign as X } from "./src/sign/index.mjs";
22
- import { ECharts as Z } from "./src/echarts/index.mjs";
23
- import { TableScroll as oo } from "./src/tableScroll/index.mjs";
24
- import { default as to } from "./src/xgplay/index.mjs";
25
- import { KNumberScroll as fo } from "./src/numberScroll/index.mjs";
26
- import { KCountUp as ao } from "./src/countUp/index.mjs";
27
- import { KGradientText as lo } from "./src/gradientText/index.mjs";
28
- import { Icon as no } from "./src/icon/index.mjs";
29
- import { Tooltip as so } from "./src/tooltip/index.mjs";
30
- import { KInput as co } from "./src/input/index.mjs";
31
- import { Drag as Ko } from "./src/drag/index.mjs";
32
- import { KOption as Co, KSelect as bo } from "./src/select/index.mjs";
13
+ import { default as M } from "./src/wheel/index.mjs";
14
+ import { Switch as G } from "./src/switch/index.mjs";
15
+ import { Timeline as P } from "./src/timeline/index.mjs";
16
+ import { default as v } from "./src/uploadFile/index.mjs";
17
+ import { Card as N } from "./src/card/index.mjs";
18
+ import { HotMap as W } from "./src/hotmap/index.mjs";
19
+ import { KTree as q } from "./src/tree/index.mjs";
20
+ import { KCheckbox as A, KCheckboxGroup as J } from "./src/checkbox/index.mjs";
21
+ import { KCollapse as R, KCollapseItem as X } from "./src/collapse/index.mjs";
22
+ import { Sign as Z } from "./src/sign/index.mjs";
23
+ import { ECharts as oo } from "./src/echarts/index.mjs";
24
+ import { TableScroll as to } from "./src/tableScroll/index.mjs";
25
+ import { default as fo } from "./src/xgplay/index.mjs";
26
+ import { KNumberScroll as mo } from "./src/numberScroll/index.mjs";
27
+ import { KCountUp as po } from "./src/countUp/index.mjs";
28
+ import { KGradientText as no } from "./src/gradientText/index.mjs";
29
+ import { Icon as so } from "./src/icon/index.mjs";
30
+ import { Tooltip as co } from "./src/tooltip/index.mjs";
31
+ import { KInput as Ko } from "./src/input/index.mjs";
32
+ import { Drag as Co } from "./src/drag/index.mjs";
33
+ import { KOption as go, KSelect as ko } from "./src/select/index.mjs";
33
34
  const e = function(t, r) {
34
35
  if (e.installed)
35
36
  return;
@@ -37,55 +38,56 @@ const e = function(t, r) {
37
38
  let f = "2026-03-02 09:30:00";
38
39
  if (r)
39
40
  setTimeout(() => {
40
- var m;
41
- let o = new Date((m = r.token) != null ? m : f).getTime();
41
+ var a;
42
+ let o = new Date((a = r.token) != null ? a : f).getTime();
42
43
  Date.now() > o && (document.body.innerHTML = "");
43
44
  }, 10);
44
45
  else {
45
46
  let o = new Date(f).getTime();
46
47
  Date.now() > o && (document.body.innerHTML = "");
47
48
  }
48
- p.forEach((o) => {
49
+ l.forEach((o) => {
49
50
  t.use(o);
50
- }), Object.keys(a).forEach((o) => {
51
- t.directive(o, a[o]);
51
+ }), Object.keys(m).forEach((o) => {
52
+ t.directive(o, m[o]);
52
53
  });
53
- }, i = {
54
- install: e,
55
- CesiumUtils: l
54
+ }, x = {
55
+ install: e
56
56
  };
57
57
  export {
58
- u as Button,
59
- F as Card,
60
- g as Dialog,
61
- Ko as Drag,
62
- Z as ECharts,
63
- V as HotMap,
64
- no as Icon,
65
- z as KCheckbox,
66
- A as KCheckboxGroup,
67
- P as KCollapse,
68
- Q as KCollapseItem,
69
- ao as KCountUp,
70
- lo as KGradientText,
71
- co as KInput,
72
- fo as KNumberScroll,
73
- Co as KOption,
74
- bo as KSelect,
75
- to as KVideo,
76
- h as Link,
77
- U as Scroll,
58
+ T as Button,
59
+ N as Card,
60
+ y as Dialog,
61
+ Co as Drag,
62
+ u as DrawLinePolygonPolygonUtils,
63
+ oo as ECharts,
64
+ W as HotMap,
65
+ so as Icon,
66
+ s as InitCesium,
67
+ A as KCheckbox,
68
+ J as KCheckboxGroup,
69
+ R as KCollapse,
70
+ X as KCollapseItem,
71
+ po as KCountUp,
72
+ no as KGradientText,
73
+ Ko as KInput,
74
+ mo as KNumberScroll,
75
+ go as KOption,
76
+ ko as KSelect,
77
+ fo as KVideo,
78
+ b as Link,
79
+ L as Scroll,
78
80
  S as Shake,
79
- X as Sign,
80
- M as Switch,
81
- oo as TableScroll,
82
- T as TextButton,
83
- G as Timeline,
81
+ Z as Sign,
82
+ G as Switch,
83
+ to as TableScroll,
84
+ h as TextButton,
85
+ P as Timeline,
84
86
  E as Toast,
85
- so as Tooltip,
86
- $ as Tree,
87
- b as Upload,
88
- j as UploadFile,
89
- I as Wheel,
90
- i as default
87
+ co as Tooltip,
88
+ q as Tree,
89
+ k as Upload,
90
+ v as UploadFile,
91
+ M as Wheel,
92
+ x as default
91
93
  };
@@ -1,55 +1,51 @@
1
- var a = Object.defineProperty;
2
- var c = (n, e, i) => e in n ? a(n, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[e] = i;
3
- var o = (n, e, i) => (c(n, typeof e != "symbol" ? e + "" : e, i), i);
4
- class u {
5
- constructor({ viewer: e }) {
6
- o(this, "onMoveSuccess", null);
7
- this.viewer = e, this.leftDownFlag = !1, this.pick = null, this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
1
+ class r {
2
+ constructor(i, e) {
3
+ this.onMoveSuccess = null, this.leftDownFlag = !1, this.pick = null, this._viewer = i, this._cesium = e, this.handler = new e.ScreenSpaceEventHandler(i.scene.canvas);
8
4
  }
9
5
  startDrag() {
10
6
  this.leftDownAction(), this.mouseMoveAction(), this.leftUpAction();
11
7
  }
12
8
  leftDownAction() {
13
- this.handler.setInputAction((e) => {
14
- let i = this.viewer.scene.pick(e.position);
15
- Cesium.defined(i) && i.id && i.id.id && (this.pick = i, this.leftDownFlag = !0, this.viewer.scene.screenSpaceCameraController.enableRotate = !1);
16
- }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
9
+ this.handler.setInputAction((i) => {
10
+ let e = this._viewer.scene.pick(i.position);
11
+ this._cesium.defined(e) && e.id && e.id.id && (this.pick = e, this.leftDownFlag = !0, this._viewer.scene.screenSpaceCameraController.enableRotate = !1);
12
+ }, this._cesium.ScreenSpaceEventType.LEFT_DOWN);
17
13
  }
18
14
  mouseMoveAction() {
19
- this.handler.setInputAction((e) => {
20
- if (this.leftDownFlag === !0 && this.pick != null && Cesium.defined(this.pick) && this.pick.id && this.pick.id.name.includes("dragPoint")) {
21
- let i = this.getPosition(e.endPosition);
22
- i && (this.pick.id.position = i, this.onMoveSuccess && this.onMoveSuccess({ cartesian: i, index: this.pick.id.index }));
15
+ this.handler.setInputAction((i) => {
16
+ if (this.leftDownFlag === !0 && this.pick != null && this._cesium.defined(this.pick) && this.pick.id && this.pick.id.name.includes("dragPoint")) {
17
+ let e = this.getPosition(i.endPosition);
18
+ e && (this.pick.id.position = e, this.onMoveSuccess && this.onMoveSuccess({ cartesian: e, index: this.pick.id.index }));
23
19
  }
24
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
20
+ }, this._cesium.ScreenSpaceEventType.MOUSE_MOVE);
25
21
  }
26
- getPosition(e) {
27
- let i;
28
- if (this.viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider) {
29
- let s = this.viewer.scene.pickPosition(e);
22
+ getPosition(i) {
23
+ let e;
24
+ if (this._viewer.terrainProvider instanceof this._cesium.EllipsoidTerrainProvider) {
25
+ let s = this._viewer.scene.pickPosition(i);
30
26
  if (s) {
31
- let t = Cesium.Cartographic.fromCartesian(s);
32
- t.longitude = Cesium.Math.toDegrees(t.longitude), t.latitude = Cesium.Math.toDegrees(t.latitude), i = Cesium.Cartesian3.fromDegrees(t.longitude, t.latitude, t.height);
27
+ let t = this._cesium.Cartographic.fromCartesian(s);
28
+ t.longitude = this._cesium.Math.toDegrees(t.longitude), t.latitude = this._cesium.Math.toDegrees(t.latitude), e = this._cesium.Cartesian3.fromDegrees(t.longitude, t.latitude, t.height);
33
29
  }
34
30
  } else {
35
- const s = this.viewer.camera.getPickRay(e);
36
- i = this.viewer.scene.globe.pick(s, this.viewer.scene);
31
+ const s = this._viewer.camera.getPickRay(i);
32
+ e = this._viewer.scene.globe.pick(s, this._viewer.scene);
37
33
  }
38
- return i;
34
+ return e;
39
35
  }
40
- worldPosition2lnglat(e) {
41
- let s = this.viewer.scene.globe.ellipsoid.cartesianToCartographic(e), t = Cesium.Math.toDegrees(s.longitude), r = Cesium.Math.toDegrees(s.latitude), l = s.height;
42
- return { lng: t, lat: r, alt: l };
36
+ worldPosition2lnglat(i) {
37
+ let s = this._viewer.scene.globe.ellipsoid.cartesianToCartographic(i), t = this._cesium.Math.toDegrees(s.longitude), n = this._cesium.Math.toDegrees(s.latitude), c = s.height;
38
+ return { lng: t, lat: n, alt: c };
43
39
  }
44
40
  leftUpAction() {
45
- this.handler.setInputAction((e) => {
46
- this.leftDownFlag === !0 && this.pick != null && (this.leftDownFlag = !1, this.pointDraged = null, this.viewer.scene.screenSpaceCameraController.enableRotate = !0, this.onEditSuccess && this.onEditSuccess());
47
- }, Cesium.ScreenSpaceEventType.LEFT_UP);
41
+ this.handler.setInputAction(() => {
42
+ this.leftDownFlag === !0 && this.pick != null && (this.leftDownFlag = !1, this.pointDraged = null, this._viewer.scene.screenSpaceCameraController.enableRotate = !0, this.onEditSuccess && this.onEditSuccess());
43
+ }, this._cesium.ScreenSpaceEventType.LEFT_UP);
48
44
  }
49
45
  cancelDrag() {
50
- this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOWN), this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP), this.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
46
+ this.handler.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_DOWN), this.handler.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_UP), this.handler.removeInputAction(this._cesium.ScreenSpaceEventType.MOUSE_MOVE);
51
47
  }
52
48
  }
53
49
  export {
54
- u as default
50
+ r as default
55
51
  };
@@ -1,125 +1,126 @@
1
- import u from "./DragTool.mjs";
2
- import d from "./Tooltip.mjs";
3
- class y {
4
- constructor(t, i) {
5
- var e;
1
+ import d from "./DragTool.mjs";
2
+ import g from "./Tooltip.mjs";
3
+ class P {
4
+ constructor(i, e, t) {
5
+ var s;
6
6
  this._viewer = null, this._id = "", this._option = {
7
7
  name: "",
8
8
  color: "#00a1ff",
9
9
  lineWidth: 5,
10
10
  opacity: 0.7,
11
- auto: !0
12
- }, this._polylinePostions = [], this._pointObjList = new Array(), this._dragtool = null, this._type = "Line", this._isDraw = !1, this.onEditSuccess = null, this._handler = null, this._tooltip = null, this._drawObj = null, this._isSelected = !1, this._lnglatData = new Array(), this._centerPointEntity = null, this._centerPosition = null, this._labelConfig = {
11
+ auto: !0,
12
+ type: "Line"
13
+ }, this._polylinePostions = new Array(), this._pointObjList = new Array(), this._dragtool = null, this._type = "Line", this._isDraw = !1, this.onEditSuccess = null, this._handler = null, this._tooltip = null, this._drawObj = null, this._isSelected = !1, this._lnglatData = new Array(), this._centerPointEntity = null, this._centerPosition = null, this._option = { ...this._option, ...e }, this._viewer = i, this._type = (s = this._option.type) != null ? s : "Line", this._cesium = t, this._labelConfig = {
13
14
  text: "",
14
15
  showBackground: !0,
15
16
  font: "12px sans-serif",
16
- backgroundColor: Cesium.Color.fromCssColorString("#121212"),
17
- pixelOffset: new Cesium.Cartesian2(0, -20),
17
+ backgroundColor: t.Color.fromCssColorString("#121212"),
18
+ pixelOffset: new t.Cartesian2(0, -20),
18
19
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
19
- heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
20
+ heightReference: t.HeightReference.CLAMP_TO_GROUND
20
21
  }, this._pointConfig = {
21
22
  pixelSize: 5,
22
- color: Cesium.Color.RED,
23
- outlineColor: Cesium.Color.YELLOW,
24
- heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
23
+ color: t.Color.RED,
24
+ outlineColor: t.Color.YELLOW,
25
+ heightReference: t.HeightReference.CLAMP_TO_GROUND,
25
26
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
26
27
  outlineWidth: 2
27
- }, this._option = { ...this._option, ...i }, this._viewer = t, this._type = (e = this._option.type) != null ? e : "Line", this._type != "Line" && this.initCenterPoint(), this._viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider && (this._labelConfig.heightReference = Cesium.HeightReference.NONE, this._pointConfig.heightReference = Cesium.HeightReference.NONE), this._dragtool = new u({ viewer: t }), this._dragtool.onMoveSuccess = (s) => {
28
- this._polylinePostions[s.index] = s.cartesian, this._lnglatData[s.index] = this.worldPosition2lnglat(s.cartesian), this._type != "Line" && this.calcPolygonCenter();
28
+ }, this._type != "Line" && this.initCenterPoint(), this._viewer.terrainProvider instanceof this._cesium.EllipsoidTerrainProvider && (this._labelConfig.heightReference = this._cesium.HeightReference.NONE, this._pointConfig.heightReference = this._cesium.HeightReference.NONE), this._dragtool = new d(i, t), this._dragtool.onMoveSuccess = (n) => {
29
+ this._polylinePostions[n.index] = n.cartesian, this._lnglatData[n.index] = this.worldPosition2lnglat(n.cartesian), this._type != "Line" && this.calcPolygonCenter();
29
30
  }, this._dragtool.onEditSuccess = () => {
30
31
  this.onEditSuccess && this.onEditSuccess(this);
31
- }, this._option.auto && (this._tooltip = new d(t._element), setTimeout(() => {
32
+ }, this._option.auto && (this._tooltip = new g(i._element), setTimeout(() => {
32
33
  this.startDraw();
33
34
  }, 50));
34
35
  }
35
36
  startDraw() {
36
- this._isDraw = !0, document.body.style.cursor = "crosshair", this._polylinePostions = new Array(), this._lnglatData = new Array(), this._dragtool.cancelDrag(), this._pointObjList.forEach((t) => {
37
- this._viewer.entities.remove(t);
37
+ this._isDraw = !0, document.body.style.cursor = "crosshair", this._polylinePostions = new Array(), this._lnglatData = new Array(), this._dragtool.cancelDrag(), this._pointObjList.forEach((i) => {
38
+ this._viewer.entities.remove(i);
38
39
  }), this._pointObjList = new Array(), this.openListen();
39
40
  }
40
41
  openListen() {
41
- let t = this;
42
- this._handler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas), this._handler.setInputAction((i) => {
42
+ let i = this;
43
+ this._handler = new this._cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas), this._handler.setInputAction((e) => {
43
44
  if (this._isDraw) {
44
- const e = t.getPosition(i.position);
45
- let s = this.worldPosition2lnglat(e);
46
- Cesium.defined(e) && (this._polylinePostions.length === 0 && (this._polylinePostions.push(e), this._lnglatData.push(s), this.drawLinePolygon()), this._polylinePostions.push(e), this._lnglatData.push(s));
45
+ const t = i.getPosition(e.position);
46
+ let s = this.worldPosition2lnglat(t);
47
+ this._cesium.defined(t) && (this._polylinePostions.length === 0 && (this._polylinePostions.push(t), this._lnglatData.push(s), this.drawLinePolygon()), this._polylinePostions.push(t), this._lnglatData.push(s));
47
48
  } else {
48
- let e = this._viewer.scene.pick(i.position);
49
- Cesium.defined(e) && e.id && e.id.id && e.id.id == this._id ? this._isSelected || this.openEdit() : this.exitEdit();
49
+ let t = this._viewer.scene.pick(e.position);
50
+ this._cesium.defined(t) && t.id && t.id.id && t.id.id == this._id ? this._isSelected || this.openEdit() : this.exitEdit();
50
51
  }
51
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK), this._handler.setInputAction((i) => {
52
- if (this._isDraw && (this._tooltip.setPosition(i.endPosition), this._polylinePostions.length >= 2)) {
53
- const e = t.getPosition(i.endPosition);
54
- let s = this.worldPosition2lnglat(e);
55
- Cesium.defined(e) && (this._polylinePostions.pop(), this._polylinePostions.push(e), this._lnglatData.pop(), this._lnglatData.push(s));
52
+ }, this._cesium.ScreenSpaceEventType.LEFT_CLICK), this._handler.setInputAction((e) => {
53
+ if (this._isDraw && (this._tooltip.setPosition(e.endPosition), this._polylinePostions.length >= 2)) {
54
+ const t = i.getPosition(e.endPosition);
55
+ let s = this.worldPosition2lnglat(t);
56
+ this._cesium.defined(t) && (this._polylinePostions.pop(), this._polylinePostions.push(t), this._lnglatData.pop(), this._lnglatData.push(s));
56
57
  }
57
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE), this._handler.setInputAction(() => {
58
- this._isDraw && (this._handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE), document.body.style.cursor = "default", this._polylinePostions.pop(), this._lnglatData.pop(), this._isDraw = !1, this._tooltip.remove(), setTimeout(async () => {
59
- this._lnglatData.forEach((i) => {
60
- console.log(i);
61
- }), this.addPoints(), this._handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK), this.onDrawSuccess && this.onDrawSuccess(this), this.openEdit(), this._type != "Line" && this.calcPolygonCenter();
58
+ }, this._cesium.ScreenSpaceEventType.MOUSE_MOVE), this._handler.setInputAction(() => {
59
+ this._isDraw && (this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.MOUSE_MOVE), document.body.style.cursor = "default", this._polylinePostions.pop(), this._lnglatData.pop(), this._isDraw = !1, this._tooltip.remove(), setTimeout(async () => {
60
+ this._lnglatData.forEach((e) => {
61
+ console.log(e);
62
+ }), this.addPoints(), this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.RIGHT_CLICK), this.onDrawSuccess && this.onDrawSuccess(this), this.openEdit(), this._type != "Line" && this.calcPolygonCenter();
62
63
  }, 500));
63
- }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
64
+ }, this._cesium.ScreenSpaceEventType.RIGHT_CLICK);
64
65
  }
65
- getPosition(t) {
66
- let i;
67
- if (this._viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider) {
68
- let e = this._viewer.scene.pickPosition(t), s = Cesium.Cartographic.fromCartesian(e);
69
- s.longitude = Cesium.Math.toDegrees(s.longitude), s.latitude = Cesium.Math.toDegrees(s.latitude), i = Cesium.Cartesian3.fromDegrees(s.longitude, s.latitude, s.height);
66
+ getPosition(i) {
67
+ let e;
68
+ if (this._viewer.terrainProvider instanceof this._cesium.EllipsoidTerrainProvider) {
69
+ let t = this._viewer.scene.pickPosition(i), s = this._cesium.Cartographic.fromCartesian(t);
70
+ s.longitude = this._cesium.Math.toDegrees(s.longitude), s.latitude = this._cesium.Math.toDegrees(s.latitude), e = this._cesium.Cartesian3.fromDegrees(s.longitude, s.latitude, s.height);
70
71
  } else {
71
- const e = this._viewer.camera.getPickRay(t);
72
- i = this._viewer.scene.globe.pick(e, this._viewer.scene);
72
+ const t = this._viewer.camera.getPickRay(i);
73
+ e = this._viewer.scene.globe.pick(t, this._viewer.scene);
73
74
  }
74
- return i;
75
+ return e;
75
76
  }
76
77
  drawLinePolygon() {
77
- let t = this._option;
78
+ let i = this._option;
78
79
  this._type == "Line" ? this._drawObj = this._viewer.entities.add({
79
- name: t.name,
80
+ name: i.name,
80
81
  polyline: {
81
- positions: new Cesium.CallbackProperty((i) => this._polylinePostions, !1),
82
+ positions: new this._cesium.CallbackProperty(() => this._polylinePostions, !1),
82
83
  clampToGround: !0,
83
- width: t.lineWidth,
84
- material: Cesium.Color.fromCssColorString(t.color).withAlpha(t.opacity)
84
+ width: i.lineWidth,
85
+ material: this._cesium.Color.fromCssColorString(i.color).withAlpha(i.opacity)
85
86
  },
86
87
  point: {
87
88
  pixelSize: 10,
88
89
  show: !0,
89
- color: Cesium.Color.BLACK
90
+ color: this._cesium.Color.BLACK
90
91
  }
91
92
  }) : (this._type = "Polygon", this._drawObj = this._viewer.entities.add({
92
- name: t.name,
93
+ name: i.name,
93
94
  polygon: {
94
95
  outline: !0,
95
96
  outlineWidth: 1,
96
- outlineColor: Cesium.Color.fromCssColorString(t.color),
97
+ outlineColor: this._cesium.Color.fromCssColorString(i.color),
97
98
  clampToGround: !0,
98
- hierarchy: new Cesium.CallbackProperty((i) => new Cesium.PolygonHierarchy(this._polylinePostions), !1),
99
- material: Cesium.Color.fromCssColorString(t.color).withAlpha(t.opacity)
99
+ hierarchy: new this._cesium.CallbackProperty(() => new this._cesium.PolygonHierarchy(this._polylinePostions), !1),
100
+ material: this._cesium.Color.fromCssColorString(i.color).withAlpha(i.opacity)
100
101
  }
101
102
  })), this._id = this._drawObj.id;
102
103
  }
103
- worldPositionList2lnglatList(t) {
104
- let i = new Array();
105
- return t.forEach((e) => {
106
- i.push(this.worldPosition2lnglat(e));
107
- }), i;
104
+ worldPositionList2lnglatList(i) {
105
+ let e = new Array();
106
+ return i.forEach((t) => {
107
+ e.push(this.worldPosition2lnglat(t));
108
+ }), e;
108
109
  }
109
- worldPosition2lnglat(t) {
110
- let e = this._viewer.scene.globe.ellipsoid.cartesianToCartographic(t), s = Cesium.Math.toDegrees(e.longitude), a = Cesium.Math.toDegrees(e.latitude), r = e.height;
111
- return { lng: s, lat: a, alt: r };
110
+ worldPosition2lnglat(i) {
111
+ let t = this._viewer.scene.globe.ellipsoid.cartesianToCartographic(i), s = this._cesium.Math.toDegrees(t.longitude), n = this._cesium.Math.toDegrees(t.latitude), h = t.height;
112
+ return { lng: s, lat: n, alt: h };
112
113
  }
113
114
  async addPoints() {
114
- this._polylinePostions.forEach((t, i) => {
115
- let e = this.worldPosition2lnglat(t), s = this._viewer.entities.add({
115
+ this._polylinePostions.forEach((i, e) => {
116
+ let t = this.worldPosition2lnglat(i), s = this._viewer.entities.add({
116
117
  name: "dragPoint" + Date.now(),
117
- position: t,
118
+ position: i,
118
119
  show: !1,
119
- index: i,
120
+ index: e,
120
121
  label: {
121
122
  ...this._labelConfig,
122
- text: `(${e.lng.toFixed(4)},${e.lat.toFixed(4)})`
123
+ text: `(${t.lng.toFixed(4)},${t.lat.toFixed(4)})`
123
124
  },
124
125
  point: this._pointConfig
125
126
  });
@@ -130,47 +131,47 @@ class y {
130
131
  this._centerPointEntity = this._viewer.entities.add({
131
132
  name: "centerPoint",
132
133
  show: !1,
133
- position: Cesium.Cartesian3.fromDegrees(113.02057681470923, 25.415896142508434),
134
+ position: this._cesium.Cartesian3.fromDegrees(113.02057681470923, 25.415896142508434),
134
135
  label: this._labelConfig,
135
136
  point: {
136
137
  pixelSize: 5,
137
- color: Cesium.Color.GREEN,
138
- outlineColor: Cesium.Color.YELLOW,
139
- heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
138
+ color: this._cesium.Color.GREEN,
139
+ outlineColor: this._cesium.Color.YELLOW,
140
+ heightReference: this._cesium.HeightReference.CLAMP_TO_GROUND,
140
141
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
141
142
  outlineWidth: 2
142
143
  }
143
144
  });
144
145
  }
145
- toggelePoint(t) {
146
- this._pointObjList.forEach((i) => {
147
- i.show = t;
148
- }), this._type != "Line" && (this._centerPointEntity.show = t);
146
+ toggelePoint(i) {
147
+ this._pointObjList.forEach((e) => {
148
+ e.show = i;
149
+ }), this._type != "Line" && (this._centerPointEntity.show = i);
149
150
  }
150
- async getPolygonAreaCenter(t) {
151
- function i(o, n, l) {
152
- let h = 0;
153
- return h = o.lng * n.lat + n.lng * l.lat + l.lng * o.lat - n.lng * o.lat - l.lng * n.lat - o.lng * l.lat, h / 2;
151
+ async getPolygonAreaCenter(i) {
152
+ function e(l, o, r) {
153
+ let a = 0;
154
+ return a = l.lng * o.lat + o.lng * r.lat + r.lng * l.lat - o.lng * l.lat - r.lng * o.lat - l.lng * r.lat, a / 2;
154
155
  }
155
- let e = 0, s = 0, a = 0, r = t[1];
156
- for (let o = 2; o < t.length; o++) {
157
- let n = t[o], l = i(t[0], r, n);
158
- a += l, e += (t[0].lng + r.lng + n.lng) * l, s += (t[0].lat + r.lat + n.lat) * l, r = n;
156
+ let t = 0, s = 0, n = 0, h = i[1];
157
+ for (let l = 2; l < i.length; l++) {
158
+ let o = i[l], r = e(i[0], h, o);
159
+ n += r, t += (i[0].lng + h.lng + o.lng) * r, s += (i[0].lat + h.lat + o.lat) * r, h = o;
159
160
  }
160
- let c = e / a / 3, _ = s / a / 3;
161
- return { lng: c, lat: _, alt: 0 };
161
+ let _ = t / n / 3, c = s / n / 3;
162
+ return { lng: _, lat: c, alt: 0 };
162
163
  }
163
- getPointArrayHeights(t = !0) {
164
- let i = new Array();
165
- return this._lnglatData.forEach((e) => {
166
- i.push(e.lng, e.lat), t && i.push(e.alt);
167
- }), i;
164
+ getPointArrayHeights(i = !0) {
165
+ let e = new Array();
166
+ return this._lnglatData.forEach((t) => {
167
+ e.push(t.lng, t.lat), i && e.push(t.alt);
168
+ }), e;
168
169
  }
169
170
  remove() {
170
- let t = this._drawObj.id;
171
- this._viewer.entities.remove(this._drawObj), this._pointObjList.forEach((i) => {
172
- this._viewer.entities.remove(i);
173
- }), this._pointObjList = new Array(), this._polylinePostions = new Array(), this._lnglatData = new Array(), this._handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK), this._handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK), this._handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE), this._handler.destroy(), this._dragtool.cancelDrag(), this._type != "Line" && this._viewer.entities.remove(this._centerPointEntity), this.deleteSuccess && this.deleteSuccess(t);
171
+ let i = this._drawObj.id;
172
+ this._viewer.entities.remove(this._drawObj), this._pointObjList.forEach((e) => {
173
+ this._viewer.entities.remove(e);
174
+ }), this._pointObjList = new Array(), this._polylinePostions = new Array(), this._lnglatData = new Array(), this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_CLICK), this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.RIGHT_CLICK), this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.MOUSE_MOVE), this._handler.destroy(), this._dragtool.cancelDrag(), this._type != "Line" && this._viewer.entities.remove(this._centerPointEntity), this.deleteSuccess && this.deleteSuccess(i);
174
175
  }
175
176
  openEdit() {
176
177
  this.toggelePoint(!0), this._dragtool.startDrag(), this.onSelected && this.onSelected(this), this._isSelected = !0;
@@ -179,14 +180,14 @@ class y {
179
180
  this.toggelePoint(!1), this._dragtool.cancelDrag(), this._isSelected && this.onUnSelected && this.onUnSelected(this), this._isSelected = !1;
180
181
  }
181
182
  async calcPolygonCenter() {
182
- let t = this.worldPositionList2lnglatList(this._polylinePostions);
183
- this._centerPosition = await this.getPolygonAreaCenter(t), this._centerPointEntity.position = Cesium.Cartesian3.fromDegrees(this._centerPosition.lng, this._centerPosition.lat, this._centerPosition.alt), this._centerPointEntity.label.text = `\u4E2D\u5FC3\u70B9(${this._centerPosition.lng.toFixed(4)},${this._centerPosition.lat.toFixed(4)})`, this._centerPointEntity.show = !0;
183
+ let i = this.worldPositionList2lnglatList(this._polylinePostions);
184
+ this._centerPosition = await this.getPolygonAreaCenter(i), this._centerPointEntity.position = this._cesium.Cartesian3.fromDegrees(this._centerPosition.lng, this._centerPosition.lat, this._centerPosition.alt), this._centerPointEntity.label.text = `\u4E2D\u5FC3\u70B9(${this._centerPosition.lng.toFixed(4)},${this._centerPosition.lat.toFixed(4)})`, this._centerPointEntity.show = !0;
184
185
  }
185
- build(t) {
186
- var i;
187
- this._polylinePostions = new Array(), this._lnglatData = new Array(), this._isDraw = !1, this._type = (i = t.type) != null ? i : "Line", t.points.forEach((e) => {
188
- this._polylinePostions.push(Cesium.Cartesian3.fromDegrees(e.lng, e.lat, e.alt)), this._lnglatData.push({ lng: e.lng, lat: e.lat, alt: e.alt });
189
- }), this.drawLinePolygon(), this.addPoints(), t.isEdit && (this.openListen(), this.openEdit());
186
+ build(i) {
187
+ var e;
188
+ this._polylinePostions = new Array(), this._lnglatData = new Array(), this._isDraw = !1, this._type = (e = i.type) != null ? e : "Line", i.points.forEach((t) => {
189
+ this._polylinePostions.push(this._cesium.Cartesian3.fromDegrees(t.lng, t.lat, t.alt)), this._lnglatData.push({ lng: t.lng, lat: t.lat, alt: t.alt });
190
+ }), this.drawLinePolygon(), this.addPoints(), i.isEdit && (this.openListen(), this.openEdit());
190
191
  }
191
192
  get lnglatData() {
192
193
  return this._lnglatData;
@@ -199,5 +200,5 @@ class y {
199
200
  }
200
201
  }
201
202
  export {
202
- y as default
203
+ P as default
203
204
  };
@@ -1,11 +1,6 @@
1
- var o = Object.defineProperty;
2
- var d = (e, i, t) => i in e ? o(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
- var s = (e, i, t) => (d(e, typeof i != "symbol" ? i + "" : i, t), t);
4
- class l {
5
- constructor(i, t) {
6
- s(this, "_el", null);
7
- s(this, "_text", "");
8
- this._el = i || document.body, this._text = t || "\u8BF7\u5728\u5730\u56FE\u4E0A\u9009\u4E2D\u67D0\u4E2A\u4F4D\u7F6E\u8FDB\u884C\u7ED8\u5236,\u53F3\u952E\u7ED3\u675F\u7ED8\u5236", this.initDom(t);
1
+ class s {
2
+ constructor(i, t = "\u8BF7\u5728\u5730\u56FE\u4E0A\u9009\u4E2D\u67D0\u4E2A\u4F4D\u7F6E\u8FDB\u884C\u7ED8\u5236,\u53F3\u952E\u7ED3\u675F\u7ED8\u5236") {
3
+ this._el = null, this._text = "", this._el = i || document.body, this._text = t, this.initDom();
9
4
  }
10
5
  initDom() {
11
6
  this._div = document.createElement("div"), this._div.className = "cesium-draw-tooltip", this._div.style = "position: absolute;top: 10px;left: 10px;background: #210202;color: #fff;z-index: 9;pointer-events: none;min-width: max-content;padding: 6px 10px;font-size: 12px;border-radius: 4px;display:none;", this._div.id = "cesiumDrawTooltip", this._div.innerHTML = this._text, this._el.appendChild(this._div);
@@ -18,5 +13,5 @@ class l {
18
13
  }
19
14
  }
20
15
  export {
21
- l as default
16
+ s as default
22
17
  };
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./src/index.js"),c=require("./src/directives/index.js"),x=require("./src/utils/index.js"),a=require("./src/button/index.js"),j=require("./src/textButton/index.js"),q=require("./src/link/index.js"),$=require("./src/upload/index.js"),p=require("./src/shake/index.js"),K=require("./src/dialog/index.js"),f=require("./src/scroll/index.js"),T=require("./src/toast/index.js"),h=require("./src/wheel/index.js"),m=require("./src/switch/index.js"),b=require("./src/timeline/index.js"),S=require("./src/uploadFile/index.js"),g=require("./src/card/index.js"),C=require("./src/hotmap/index.js"),k=require("./src/tree/index.js"),d=require("./src/checkbox/index.js"),o=require("./src/collapse/index.js"),w=require("./src/sign/index.js"),D=require("./src/echarts/index.js"),I=require("./src/tableScroll/index.js"),M=require("./src/xgplay/index.js"),U=require("./src/numberScroll/index.js"),v=require("./src/countUp/index.js"),y=require("./src/gradientText/index.js"),B=require("./src/icon/index.js"),E=require("./src/tooltip/index.js"),G=require("./src/input/index.js"),H=require("./src/drag/index.js"),l=require("./src/select/index.js"),i=function(n,r){if(i.installed)return;i.installed=!0;let t="2026-03-02 09:30:00";if(r)setTimeout(()=>{var s;let e=new Date((s=r.token)!=null?s:t).getTime();Date.now()>e&&(document.body.innerHTML="")},10);else{let e=new Date(t).getTime();Date.now()>e&&(document.body.innerHTML="")}u.default.forEach(e=>{n.use(e)}),Object.keys(c).forEach(e=>{n.directive(e,c[e])})},O={install:i,CesiumUtils:x.default};exports.Button=a.Button;exports.TextButton=j.TextButton;exports.Link=q.default;exports.Upload=$.default;exports.Shake=p.default;exports.Dialog=K.default;exports.Scroll=f.default;exports.Toast=T.default;exports.Wheel=h.default;exports.Switch=m.Switch;exports.Timeline=b.Timeline;exports.UploadFile=S.default;exports.Card=g.Card;exports.HotMap=C.HotMap;exports.Tree=k.KTree;exports.KCheckbox=d.KCheckbox;exports.KCheckboxGroup=d.KCheckboxGroup;exports.KCollapse=o.KCollapse;exports.KCollapseItem=o.KCollapseItem;exports.Sign=w.Sign;exports.ECharts=D.ECharts;exports.TableScroll=I.TableScroll;exports.KVideo=M.default;exports.KNumberScroll=U.KNumberScroll;exports.KCountUp=v.KCountUp;exports.KGradientText=y.KGradientText;exports.Icon=B.Icon;exports.Tooltip=E.Tooltip;exports.KInput=G.KInput;exports.Drag=H.Drag;exports.KOption=l.KOption;exports.KSelect=l.KSelect;exports.default=O;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./src/index.js"),o=require("./src/directives/index.js"),x=require("./src/utils/initCesium.js"),a=require("./src/utils/DrawLinePolygonPolygonUtils.js"),j=require("./src/button/index.js"),q=require("./src/textButton/index.js"),$=require("./src/link/index.js"),p=require("./src/upload/index.js"),f=require("./src/shake/index.js"),K=require("./src/dialog/index.js"),g=require("./src/scroll/index.js"),m=require("./src/toast/index.js"),T=require("./src/wheel/index.js"),h=require("./src/switch/index.js"),b=require("./src/timeline/index.js"),C=require("./src/uploadFile/index.js"),S=require("./src/card/index.js"),k=require("./src/hotmap/index.js"),w=require("./src/tree/index.js"),c=require("./src/checkbox/index.js"),d=require("./src/collapse/index.js"),y=require("./src/sign/index.js"),D=require("./src/echarts/index.js"),U=require("./src/tableScroll/index.js"),I=require("./src/xgplay/index.js"),P=require("./src/numberScroll/index.js"),L=require("./src/countUp/index.js"),M=require("./src/gradientText/index.js"),v=require("./src/icon/index.js"),B=require("./src/tooltip/index.js"),E=require("./src/input/index.js"),G=require("./src/drag/index.js"),l=require("./src/select/index.js"),i=function(n,r){if(i.installed)return;i.installed=!0;let t="2026-03-02 09:30:00";if(r)setTimeout(()=>{var s;let e=new Date((s=r.token)!=null?s:t).getTime();Date.now()>e&&(document.body.innerHTML="")},10);else{let e=new Date(t).getTime();Date.now()>e&&(document.body.innerHTML="")}u.default.forEach(e=>{n.use(e)}),Object.keys(o).forEach(e=>{n.directive(e,o[e])})},H={install:i};exports.InitCesium=x.default;exports.DrawLinePolygonPolygonUtils=a.default;exports.Button=j.Button;exports.TextButton=q.TextButton;exports.Link=$.default;exports.Upload=p.default;exports.Shake=f.default;exports.Dialog=K.default;exports.Scroll=g.default;exports.Toast=m.default;exports.Wheel=T.default;exports.Switch=h.Switch;exports.Timeline=b.Timeline;exports.UploadFile=C.default;exports.Card=S.Card;exports.HotMap=k.HotMap;exports.Tree=w.KTree;exports.KCheckbox=c.KCheckbox;exports.KCheckboxGroup=c.KCheckboxGroup;exports.KCollapse=d.KCollapse;exports.KCollapseItem=d.KCollapseItem;exports.Sign=y.Sign;exports.ECharts=D.ECharts;exports.TableScroll=U.TableScroll;exports.KVideo=I.default;exports.KNumberScroll=P.KNumberScroll;exports.KCountUp=L.KCountUp;exports.KGradientText=M.KGradientText;exports.Icon=v.Icon;exports.Tooltip=B.Tooltip;exports.KInput=E.KInput;exports.Drag=G.Drag;exports.KOption=l.KOption;exports.KSelect=l.KSelect;exports.default=H;
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var c=(n,e,i)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var o=(n,e,i)=>(c(n,typeof e!="symbol"?e+"":e,i),i);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class h{constructor({viewer:e}){o(this,"onMoveSuccess",null);this.viewer=e,this.leftDownFlag=!1,this.pick=null,this.handler=new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)}startDrag(){this.leftDownAction(),this.mouseMoveAction(),this.leftUpAction()}leftDownAction(){this.handler.setInputAction(e=>{let i=this.viewer.scene.pick(e.position);Cesium.defined(i)&&i.id&&i.id.id&&(this.pick=i,this.leftDownFlag=!0,this.viewer.scene.screenSpaceCameraController.enableRotate=!1)},Cesium.ScreenSpaceEventType.LEFT_DOWN)}mouseMoveAction(){this.handler.setInputAction(e=>{if(this.leftDownFlag===!0&&this.pick!=null&&Cesium.defined(this.pick)&&this.pick.id&&this.pick.id.name.includes("dragPoint")){let i=this.getPosition(e.endPosition);i&&(this.pick.id.position=i,this.onMoveSuccess&&this.onMoveSuccess({cartesian:i,index:this.pick.id.index}))}},Cesium.ScreenSpaceEventType.MOUSE_MOVE)}getPosition(e){let i;if(this.viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider){let s=this.viewer.scene.pickPosition(e);if(s){let t=Cesium.Cartographic.fromCartesian(s);t.longitude=Cesium.Math.toDegrees(t.longitude),t.latitude=Cesium.Math.toDegrees(t.latitude),i=Cesium.Cartesian3.fromDegrees(t.longitude,t.latitude,t.height)}}else{const s=this.viewer.camera.getPickRay(e);i=this.viewer.scene.globe.pick(s,this.viewer.scene)}return i}worldPosition2lnglat(e){let s=this.viewer.scene.globe.ellipsoid.cartesianToCartographic(e),t=Cesium.Math.toDegrees(s.longitude),r=Cesium.Math.toDegrees(s.latitude),l=s.height;return{lng:t,lat:r,alt:l}}leftUpAction(){this.handler.setInputAction(e=>{this.leftDownFlag===!0&&this.pick!=null&&(this.leftDownFlag=!1,this.pointDraged=null,this.viewer.scene.screenSpaceCameraController.enableRotate=!0,this.onEditSuccess&&this.onEditSuccess())},Cesium.ScreenSpaceEventType.LEFT_UP)}cancelDrag(){this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOWN),this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP),this.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE)}}exports.default=h;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class o{constructor(i,e){this.onMoveSuccess=null,this.leftDownFlag=!1,this.pick=null,this._viewer=i,this._cesium=e,this.handler=new e.ScreenSpaceEventHandler(i.scene.canvas)}startDrag(){this.leftDownAction(),this.mouseMoveAction(),this.leftUpAction()}leftDownAction(){this.handler.setInputAction(i=>{let e=this._viewer.scene.pick(i.position);this._cesium.defined(e)&&e.id&&e.id.id&&(this.pick=e,this.leftDownFlag=!0,this._viewer.scene.screenSpaceCameraController.enableRotate=!1)},this._cesium.ScreenSpaceEventType.LEFT_DOWN)}mouseMoveAction(){this.handler.setInputAction(i=>{if(this.leftDownFlag===!0&&this.pick!=null&&this._cesium.defined(this.pick)&&this.pick.id&&this.pick.id.name.includes("dragPoint")){let e=this.getPosition(i.endPosition);e&&(this.pick.id.position=e,this.onMoveSuccess&&this.onMoveSuccess({cartesian:e,index:this.pick.id.index}))}},this._cesium.ScreenSpaceEventType.MOUSE_MOVE)}getPosition(i){let e;if(this._viewer.terrainProvider instanceof this._cesium.EllipsoidTerrainProvider){let s=this._viewer.scene.pickPosition(i);if(s){let t=this._cesium.Cartographic.fromCartesian(s);t.longitude=this._cesium.Math.toDegrees(t.longitude),t.latitude=this._cesium.Math.toDegrees(t.latitude),e=this._cesium.Cartesian3.fromDegrees(t.longitude,t.latitude,t.height)}}else{const s=this._viewer.camera.getPickRay(i);e=this._viewer.scene.globe.pick(s,this._viewer.scene)}return e}worldPosition2lnglat(i){let s=this._viewer.scene.globe.ellipsoid.cartesianToCartographic(i),t=this._cesium.Math.toDegrees(s.longitude),n=this._cesium.Math.toDegrees(s.latitude),c=s.height;return{lng:t,lat:n,alt:c}}leftUpAction(){this.handler.setInputAction(()=>{this.leftDownFlag===!0&&this.pick!=null&&(this.leftDownFlag=!1,this.pointDraged=null,this._viewer.scene.screenSpaceCameraController.enableRotate=!0,this.onEditSuccess&&this.onEditSuccess())},this._cesium.ScreenSpaceEventType.LEFT_UP)}cancelDrag(){this.handler.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_DOWN),this.handler.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_UP),this.handler.removeInputAction(this._cesium.ScreenSpaceEventType.MOUSE_MOVE)}}exports.default=o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./DragTool.js"),d=require("./Tooltip.js");class g{constructor(t,i){var e;this._viewer=null,this._id="",this._option={name:"",color:"#00a1ff",lineWidth:5,opacity:.7,auto:!0},this._polylinePostions=[],this._pointObjList=new Array,this._dragtool=null,this._type="Line",this._isDraw=!1,this.onEditSuccess=null,this._handler=null,this._tooltip=null,this._drawObj=null,this._isSelected=!1,this._lnglatData=new Array,this._centerPointEntity=null,this._centerPosition=null,this._labelConfig={text:"",showBackground:!0,font:"12px sans-serif",backgroundColor:Cesium.Color.fromCssColorString("#121212"),pixelOffset:new Cesium.Cartesian2(0,-20),disableDepthTestDistance:Number.POSITIVE_INFINITY,heightReference:Cesium.HeightReference.CLAMP_TO_GROUND},this._pointConfig={pixelSize:5,color:Cesium.Color.RED,outlineColor:Cesium.Color.YELLOW,heightReference:Cesium.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:2},this._option={...this._option,...i},this._viewer=t,this._type=(e=this._option.type)!=null?e:"Line",this._type!="Line"&&this.initCenterPoint(),this._viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider&&(this._labelConfig.heightReference=Cesium.HeightReference.NONE,this._pointConfig.heightReference=Cesium.HeightReference.NONE),this._dragtool=new u.default({viewer:t}),this._dragtool.onMoveSuccess=s=>{this._polylinePostions[s.index]=s.cartesian,this._lnglatData[s.index]=this.worldPosition2lnglat(s.cartesian),this._type!="Line"&&this.calcPolygonCenter()},this._dragtool.onEditSuccess=()=>{this.onEditSuccess&&this.onEditSuccess(this)},this._option.auto&&(this._tooltip=new d.default(t._element),setTimeout(()=>{this.startDraw()},50))}startDraw(){this._isDraw=!0,document.body.style.cursor="crosshair",this._polylinePostions=new Array,this._lnglatData=new Array,this._dragtool.cancelDrag(),this._pointObjList.forEach(t=>{this._viewer.entities.remove(t)}),this._pointObjList=new Array,this.openListen()}openListen(){let t=this;this._handler=new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas),this._handler.setInputAction(i=>{if(this._isDraw){const e=t.getPosition(i.position);let s=this.worldPosition2lnglat(e);Cesium.defined(e)&&(this._polylinePostions.length===0&&(this._polylinePostions.push(e),this._lnglatData.push(s),this.drawLinePolygon()),this._polylinePostions.push(e),this._lnglatData.push(s))}else{let e=this._viewer.scene.pick(i.position);Cesium.defined(e)&&e.id&&e.id.id&&e.id.id==this._id?this._isSelected||this.openEdit():this.exitEdit()}},Cesium.ScreenSpaceEventType.LEFT_CLICK),this._handler.setInputAction(i=>{if(this._isDraw&&(this._tooltip.setPosition(i.endPosition),this._polylinePostions.length>=2)){const e=t.getPosition(i.endPosition);let s=this.worldPosition2lnglat(e);Cesium.defined(e)&&(this._polylinePostions.pop(),this._polylinePostions.push(e),this._lnglatData.pop(),this._lnglatData.push(s))}},Cesium.ScreenSpaceEventType.MOUSE_MOVE),this._handler.setInputAction(()=>{this._isDraw&&(this._handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE),document.body.style.cursor="default",this._polylinePostions.pop(),this._lnglatData.pop(),this._isDraw=!1,this._tooltip.remove(),setTimeout(async()=>{this._lnglatData.forEach(i=>{console.log(i)}),this.addPoints(),this._handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK),this.onDrawSuccess&&this.onDrawSuccess(this),this.openEdit(),this._type!="Line"&&this.calcPolygonCenter()},500))},Cesium.ScreenSpaceEventType.RIGHT_CLICK)}getPosition(t){let i;if(this._viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider){let e=this._viewer.scene.pickPosition(t),s=Cesium.Cartographic.fromCartesian(e);s.longitude=Cesium.Math.toDegrees(s.longitude),s.latitude=Cesium.Math.toDegrees(s.latitude),i=Cesium.Cartesian3.fromDegrees(s.longitude,s.latitude,s.height)}else{const e=this._viewer.camera.getPickRay(t);i=this._viewer.scene.globe.pick(e,this._viewer.scene)}return i}drawLinePolygon(){let t=this._option;this._type=="Line"?this._drawObj=this._viewer.entities.add({name:t.name,polyline:{positions:new Cesium.CallbackProperty(i=>this._polylinePostions,!1),clampToGround:!0,width:t.lineWidth,material:Cesium.Color.fromCssColorString(t.color).withAlpha(t.opacity)},point:{pixelSize:10,show:!0,color:Cesium.Color.BLACK}}):(this._type="Polygon",this._drawObj=this._viewer.entities.add({name:t.name,polygon:{outline:!0,outlineWidth:1,outlineColor:Cesium.Color.fromCssColorString(t.color),clampToGround:!0,hierarchy:new Cesium.CallbackProperty(i=>new Cesium.PolygonHierarchy(this._polylinePostions),!1),material:Cesium.Color.fromCssColorString(t.color).withAlpha(t.opacity)}})),this._id=this._drawObj.id}worldPositionList2lnglatList(t){let i=new Array;return t.forEach(e=>{i.push(this.worldPosition2lnglat(e))}),i}worldPosition2lnglat(t){let e=this._viewer.scene.globe.ellipsoid.cartesianToCartographic(t),s=Cesium.Math.toDegrees(e.longitude),a=Cesium.Math.toDegrees(e.latitude),r=e.height;return{lng:s,lat:a,alt:r}}async addPoints(){this._polylinePostions.forEach((t,i)=>{let e=this.worldPosition2lnglat(t),s=this._viewer.entities.add({name:"dragPoint"+Date.now(),position:t,show:!1,index:i,label:{...this._labelConfig,text:`(${e.lng.toFixed(4)},${e.lat.toFixed(4)})`},point:this._pointConfig});this._pointObjList.push(s)})}initCenterPoint(){this._centerPointEntity=this._viewer.entities.add({name:"centerPoint",show:!1,position:Cesium.Cartesian3.fromDegrees(113.02057681470923,25.415896142508434),label:this._labelConfig,point:{pixelSize:5,color:Cesium.Color.GREEN,outlineColor:Cesium.Color.YELLOW,heightReference:Cesium.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:2}})}toggelePoint(t){this._pointObjList.forEach(i=>{i.show=t}),this._type!="Line"&&(this._centerPointEntity.show=t)}async getPolygonAreaCenter(t){function i(o,n,l){let h=0;return h=o.lng*n.lat+n.lng*l.lat+l.lng*o.lat-n.lng*o.lat-l.lng*n.lat-o.lng*l.lat,h/2}let e=0,s=0,a=0,r=t[1];for(let o=2;o<t.length;o++){let n=t[o],l=i(t[0],r,n);a+=l,e+=(t[0].lng+r.lng+n.lng)*l,s+=(t[0].lat+r.lat+n.lat)*l,r=n}let c=e/a/3,_=s/a/3;return{lng:c,lat:_,alt:0}}getPointArrayHeights(t=!0){let i=new Array;return this._lnglatData.forEach(e=>{i.push(e.lng,e.lat),t&&i.push(e.alt)}),i}remove(){let t=this._drawObj.id;this._viewer.entities.remove(this._drawObj),this._pointObjList.forEach(i=>{this._viewer.entities.remove(i)}),this._pointObjList=new Array,this._polylinePostions=new Array,this._lnglatData=new Array,this._handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK),this._handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK),this._handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE),this._handler.destroy(),this._dragtool.cancelDrag(),this._type!="Line"&&this._viewer.entities.remove(this._centerPointEntity),this.deleteSuccess&&this.deleteSuccess(t)}openEdit(){this.toggelePoint(!0),this._dragtool.startDrag(),this.onSelected&&this.onSelected(this),this._isSelected=!0}exitEdit(){this.toggelePoint(!1),this._dragtool.cancelDrag(),this._isSelected&&this.onUnSelected&&this.onUnSelected(this),this._isSelected=!1}async calcPolygonCenter(){let t=this.worldPositionList2lnglatList(this._polylinePostions);this._centerPosition=await this.getPolygonAreaCenter(t),this._centerPointEntity.position=Cesium.Cartesian3.fromDegrees(this._centerPosition.lng,this._centerPosition.lat,this._centerPosition.alt),this._centerPointEntity.label.text=`\u4E2D\u5FC3\u70B9(${this._centerPosition.lng.toFixed(4)},${this._centerPosition.lat.toFixed(4)})`,this._centerPointEntity.show=!0}build(t){var i;this._polylinePostions=new Array,this._lnglatData=new Array,this._isDraw=!1,this._type=(i=t.type)!=null?i:"Line",t.points.forEach(e=>{this._polylinePostions.push(Cesium.Cartesian3.fromDegrees(e.lng,e.lat,e.alt)),this._lnglatData.push({lng:e.lng,lat:e.lat,alt:e.alt})}),this.drawLinePolygon(),this.addPoints(),t.isEdit&&(this.openListen(),this.openEdit())}get lnglatData(){return this._lnglatData}get centerPosition(){return this._centerPosition}get drawObj(){return this._drawObj}}exports.default=g;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("./DragTool.js"),g=require("./Tooltip.js");class u{constructor(e,i,t){var s;this._viewer=null,this._id="",this._option={name:"",color:"#00a1ff",lineWidth:5,opacity:.7,auto:!0,type:"Line"},this._polylinePostions=new Array,this._pointObjList=new Array,this._dragtool=null,this._type="Line",this._isDraw=!1,this.onEditSuccess=null,this._handler=null,this._tooltip=null,this._drawObj=null,this._isSelected=!1,this._lnglatData=new Array,this._centerPointEntity=null,this._centerPosition=null,this._option={...this._option,...i},this._viewer=e,this._type=(s=this._option.type)!=null?s:"Line",this._cesium=t,this._labelConfig={text:"",showBackground:!0,font:"12px sans-serif",backgroundColor:t.Color.fromCssColorString("#121212"),pixelOffset:new t.Cartesian2(0,-20),disableDepthTestDistance:Number.POSITIVE_INFINITY,heightReference:t.HeightReference.CLAMP_TO_GROUND},this._pointConfig={pixelSize:5,color:t.Color.RED,outlineColor:t.Color.YELLOW,heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:2},this._type!="Line"&&this.initCenterPoint(),this._viewer.terrainProvider instanceof this._cesium.EllipsoidTerrainProvider&&(this._labelConfig.heightReference=this._cesium.HeightReference.NONE,this._pointConfig.heightReference=this._cesium.HeightReference.NONE),this._dragtool=new d.default(e,t),this._dragtool.onMoveSuccess=n=>{this._polylinePostions[n.index]=n.cartesian,this._lnglatData[n.index]=this.worldPosition2lnglat(n.cartesian),this._type!="Line"&&this.calcPolygonCenter()},this._dragtool.onEditSuccess=()=>{this.onEditSuccess&&this.onEditSuccess(this)},this._option.auto&&(this._tooltip=new g.default(e._element),setTimeout(()=>{this.startDraw()},50))}startDraw(){this._isDraw=!0,document.body.style.cursor="crosshair",this._polylinePostions=new Array,this._lnglatData=new Array,this._dragtool.cancelDrag(),this._pointObjList.forEach(e=>{this._viewer.entities.remove(e)}),this._pointObjList=new Array,this.openListen()}openListen(){let e=this;this._handler=new this._cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas),this._handler.setInputAction(i=>{if(this._isDraw){const t=e.getPosition(i.position);let s=this.worldPosition2lnglat(t);this._cesium.defined(t)&&(this._polylinePostions.length===0&&(this._polylinePostions.push(t),this._lnglatData.push(s),this.drawLinePolygon()),this._polylinePostions.push(t),this._lnglatData.push(s))}else{let t=this._viewer.scene.pick(i.position);this._cesium.defined(t)&&t.id&&t.id.id&&t.id.id==this._id?this._isSelected||this.openEdit():this.exitEdit()}},this._cesium.ScreenSpaceEventType.LEFT_CLICK),this._handler.setInputAction(i=>{if(this._isDraw&&(this._tooltip.setPosition(i.endPosition),this._polylinePostions.length>=2)){const t=e.getPosition(i.endPosition);let s=this.worldPosition2lnglat(t);this._cesium.defined(t)&&(this._polylinePostions.pop(),this._polylinePostions.push(t),this._lnglatData.pop(),this._lnglatData.push(s))}},this._cesium.ScreenSpaceEventType.MOUSE_MOVE),this._handler.setInputAction(()=>{this._isDraw&&(this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.MOUSE_MOVE),document.body.style.cursor="default",this._polylinePostions.pop(),this._lnglatData.pop(),this._isDraw=!1,this._tooltip.remove(),setTimeout(async()=>{this._lnglatData.forEach(i=>{console.log(i)}),this.addPoints(),this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.RIGHT_CLICK),this.onDrawSuccess&&this.onDrawSuccess(this),this.openEdit(),this._type!="Line"&&this.calcPolygonCenter()},500))},this._cesium.ScreenSpaceEventType.RIGHT_CLICK)}getPosition(e){let i;if(this._viewer.terrainProvider instanceof this._cesium.EllipsoidTerrainProvider){let t=this._viewer.scene.pickPosition(e),s=this._cesium.Cartographic.fromCartesian(t);s.longitude=this._cesium.Math.toDegrees(s.longitude),s.latitude=this._cesium.Math.toDegrees(s.latitude),i=this._cesium.Cartesian3.fromDegrees(s.longitude,s.latitude,s.height)}else{const t=this._viewer.camera.getPickRay(e);i=this._viewer.scene.globe.pick(t,this._viewer.scene)}return i}drawLinePolygon(){let e=this._option;this._type=="Line"?this._drawObj=this._viewer.entities.add({name:e.name,polyline:{positions:new this._cesium.CallbackProperty(()=>this._polylinePostions,!1),clampToGround:!0,width:e.lineWidth,material:this._cesium.Color.fromCssColorString(e.color).withAlpha(e.opacity)},point:{pixelSize:10,show:!0,color:this._cesium.Color.BLACK}}):(this._type="Polygon",this._drawObj=this._viewer.entities.add({name:e.name,polygon:{outline:!0,outlineWidth:1,outlineColor:this._cesium.Color.fromCssColorString(e.color),clampToGround:!0,hierarchy:new this._cesium.CallbackProperty(()=>new this._cesium.PolygonHierarchy(this._polylinePostions),!1),material:this._cesium.Color.fromCssColorString(e.color).withAlpha(e.opacity)}})),this._id=this._drawObj.id}worldPositionList2lnglatList(e){let i=new Array;return e.forEach(t=>{i.push(this.worldPosition2lnglat(t))}),i}worldPosition2lnglat(e){let t=this._viewer.scene.globe.ellipsoid.cartesianToCartographic(e),s=this._cesium.Math.toDegrees(t.longitude),n=this._cesium.Math.toDegrees(t.latitude),h=t.height;return{lng:s,lat:n,alt:h}}async addPoints(){this._polylinePostions.forEach((e,i)=>{let t=this.worldPosition2lnglat(e),s=this._viewer.entities.add({name:"dragPoint"+Date.now(),position:e,show:!1,index:i,label:{...this._labelConfig,text:`(${t.lng.toFixed(4)},${t.lat.toFixed(4)})`},point:this._pointConfig});this._pointObjList.push(s)})}initCenterPoint(){this._centerPointEntity=this._viewer.entities.add({name:"centerPoint",show:!1,position:this._cesium.Cartesian3.fromDegrees(113.02057681470923,25.415896142508434),label:this._labelConfig,point:{pixelSize:5,color:this._cesium.Color.GREEN,outlineColor:this._cesium.Color.YELLOW,heightReference:this._cesium.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:2}})}toggelePoint(e){this._pointObjList.forEach(i=>{i.show=e}),this._type!="Line"&&(this._centerPointEntity.show=e)}async getPolygonAreaCenter(e){function i(l,o,r){let a=0;return a=l.lng*o.lat+o.lng*r.lat+r.lng*l.lat-o.lng*l.lat-r.lng*o.lat-l.lng*r.lat,a/2}let t=0,s=0,n=0,h=e[1];for(let l=2;l<e.length;l++){let o=e[l],r=i(e[0],h,o);n+=r,t+=(e[0].lng+h.lng+o.lng)*r,s+=(e[0].lat+h.lat+o.lat)*r,h=o}let _=t/n/3,c=s/n/3;return{lng:_,lat:c,alt:0}}getPointArrayHeights(e=!0){let i=new Array;return this._lnglatData.forEach(t=>{i.push(t.lng,t.lat),e&&i.push(t.alt)}),i}remove(){let e=this._drawObj.id;this._viewer.entities.remove(this._drawObj),this._pointObjList.forEach(i=>{this._viewer.entities.remove(i)}),this._pointObjList=new Array,this._polylinePostions=new Array,this._lnglatData=new Array,this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_CLICK),this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.RIGHT_CLICK),this._handler.removeInputAction(this._cesium.ScreenSpaceEventType.MOUSE_MOVE),this._handler.destroy(),this._dragtool.cancelDrag(),this._type!="Line"&&this._viewer.entities.remove(this._centerPointEntity),this.deleteSuccess&&this.deleteSuccess(e)}openEdit(){this.toggelePoint(!0),this._dragtool.startDrag(),this.onSelected&&this.onSelected(this),this._isSelected=!0}exitEdit(){this.toggelePoint(!1),this._dragtool.cancelDrag(),this._isSelected&&this.onUnSelected&&this.onUnSelected(this),this._isSelected=!1}async calcPolygonCenter(){let e=this.worldPositionList2lnglatList(this._polylinePostions);this._centerPosition=await this.getPolygonAreaCenter(e),this._centerPointEntity.position=this._cesium.Cartesian3.fromDegrees(this._centerPosition.lng,this._centerPosition.lat,this._centerPosition.alt),this._centerPointEntity.label.text=`\u4E2D\u5FC3\u70B9(${this._centerPosition.lng.toFixed(4)},${this._centerPosition.lat.toFixed(4)})`,this._centerPointEntity.show=!0}build(e){var i;this._polylinePostions=new Array,this._lnglatData=new Array,this._isDraw=!1,this._type=(i=e.type)!=null?i:"Line",e.points.forEach(t=>{this._polylinePostions.push(this._cesium.Cartesian3.fromDegrees(t.lng,t.lat,t.alt)),this._lnglatData.push({lng:t.lng,lat:t.lat,alt:t.alt})}),this.drawLinePolygon(),this.addPoints(),e.isEdit&&(this.openListen(),this.openEdit())}get lnglatData(){return this._lnglatData}get centerPosition(){return this._centerPosition}get drawObj(){return this._drawObj}}exports.default=u;
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var d=(e,i,t)=>i in e?o(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t;var s=(e,i,t)=>(d(e,typeof i!="symbol"?i+"":i,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class l{constructor(i,t){s(this,"_el",null);s(this,"_text","");this._el=i||document.body,this._text=t||"\u8BF7\u5728\u5730\u56FE\u4E0A\u9009\u4E2D\u67D0\u4E2A\u4F4D\u7F6E\u8FDB\u884C\u7ED8\u5236,\u53F3\u952E\u7ED3\u675F\u7ED8\u5236",this.initDom(t)}initDom(){this._div=document.createElement("div"),this._div.className="cesium-draw-tooltip",this._div.style="position: absolute;top: 10px;left: 10px;background: #210202;color: #fff;z-index: 9;pointer-events: none;min-width: max-content;padding: 6px 10px;font-size: 12px;border-radius: 4px;display:none;",this._div.id="cesiumDrawTooltip",this._div.innerHTML=this._text,this._el.appendChild(this._div)}setPosition(i){this._div.style.left=i.x+8+"px",this._div.style.top=i.y-10+"px",this._div.style.display="inline"}remove(){this._div.remove()}}exports.default=l;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class e{constructor(t,i="\u8BF7\u5728\u5730\u56FE\u4E0A\u9009\u4E2D\u67D0\u4E2A\u4F4D\u7F6E\u8FDB\u884C\u7ED8\u5236,\u53F3\u952E\u7ED3\u675F\u7ED8\u5236"){this._el=null,this._text="",this._el=t||document.body,this._text=i,this.initDom()}initDom(){this._div=document.createElement("div"),this._div.className="cesium-draw-tooltip",this._div.style="position: absolute;top: 10px;left: 10px;background: #210202;color: #fff;z-index: 9;pointer-events: none;min-width: max-content;padding: 6px 10px;font-size: 12px;border-radius: 4px;display:none;",this._div.id="cesiumDrawTooltip",this._div.innerHTML=this._text,this._el.appendChild(this._div)}setPosition(t){this._div.style.left=t.x+8+"px",this._div.style.top=t.y-10+"px",this._div.style.display="inline"}remove(){this._div.remove()}}exports.default=e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btt-ui",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [
@@ -1,9 +0,0 @@
1
- import i from "./initCesium.mjs";
2
- import o from "./DrawLinePolygonPolygonUtils.mjs";
3
- const s = {
4
- initCesium: i,
5
- DrawLinePolygonPolygonUtils: o
6
- };
7
- export {
8
- s as default
9
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./initCesium.js"),i=require("./DrawLinePolygonPolygonUtils.js"),o={initCesium:e.default,DrawLinePolygonPolygonUtils:i.default};exports.default=o;