zhihao-ui 1.3.46 → 1.3.47

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.
Files changed (51) hide show
  1. package/dist/es/{BaseInfo-Cu3ME-K_.js → BaseInfo-BQ9mgGZQ.js} +1 -1
  2. package/dist/es/{BaseItem-Co7KlYD6.js → BaseItem-CEFYU-vZ.js} +3 -3
  3. package/dist/es/{Button-Dp3Eoz3O.js → Button-BdGo3Kfv.js} +2 -2
  4. package/dist/es/CascaderLoadMore-1ENwzKY8.js +261 -0
  5. package/dist/es/DatePicker-DvSoaSq9.js +73 -0
  6. package/dist/es/{DetailHeader-DTHE-pQa.js → DetailHeader-70m7dEou.js} +3 -3
  7. package/dist/es/{DetailSubTitle-BG-q2NNN.js → DetailSubTitle-CqcoW7Qc.js} +2 -2
  8. package/dist/es/{Dialog-B0N_UsO3.js → Dialog-Cib_m5sM.js} +3 -3
  9. package/dist/es/DiyDataTable-bO--1zPQ.js +366 -0
  10. package/dist/es/{EditInfoPair-DwrwCanm.js → EditInfoPair-CIN0LGcX.js} +3 -3
  11. package/dist/es/{FileWrapper-BDK8YvRB.js → FileWrapper-kRc7s3wS.js} +4 -4
  12. package/dist/es/{Grid-pVjqXcmJ.js → Grid-YHrIHuuu.js} +2 -2
  13. package/dist/es/{InfoPair-lu2zDhpQ.js → InfoPair-Dg0qbY3Z.js} +3 -3
  14. package/dist/es/{Input-Du4ztfNG.js → Input-uOt745UZ.js} +14 -14
  15. package/dist/es/{Loading-Dc9138dn.js → Loading-C_6ERpeb.js} +2 -2
  16. package/dist/es/Map-BURr7_36.js +2528 -0
  17. package/dist/es/{MessageBox-CJMqwEqr.js → MessageBox-h_sFrr4D.js} +2 -2
  18. package/dist/es/{MoneyInput-CJxSKPIk.js → MoneyInput-n52E-q_5.js} +5 -5
  19. package/dist/es/{PageHeadPanel-BChW8Tal.js → PageHeadPanel-DLs1xYME.js} +2 -2
  20. package/dist/es/Table-Cr4k_o89.js +1167 -0
  21. package/dist/es/{ToolTips-Y6yG2q7L.js → ToolTips-CSVL9wbb.js} +3 -3
  22. package/dist/es/index.js +77 -60
  23. package/dist/es/{utils-Co2iJhr8.js → utils-UjENBVnX.js} +1 -1
  24. package/dist/es/{vendor-Crdostgq.js → vendor-9390iK3y.js} +30843 -26337
  25. package/dist/index.css +1 -1
  26. package/dist/types/components/BaseItem/BaseItem.vue.d.ts +1 -1
  27. package/dist/types/components/BaseItem/index.d.ts +10 -10
  28. package/dist/types/components/BaseItem/types.d.ts +1 -1
  29. package/dist/types/components/DetailHeader/index.d.ts +3 -3
  30. package/dist/types/components/DetailHeader/types.d.ts +1 -1
  31. package/dist/types/components/Dialog/Dialog.vue.d.ts +16 -16
  32. package/dist/types/components/Dialog/index.d.ts +24 -24
  33. package/dist/types/components/DiyDataTable/DiyDataTable.vue.d.ts +386 -1
  34. package/dist/types/components/DiyDataTable/index.d.ts +1131 -0
  35. package/dist/types/components/DiyDataTable/type.d.ts +17 -1
  36. package/dist/types/components/Map/Map.vue.d.ts +138 -101
  37. package/dist/types/components/Map/components/scaleLine.vue.d.ts +1 -2
  38. package/dist/types/components/Map/components/zoomControl.vue.d.ts +3 -7
  39. package/dist/types/components/Map/index.d.ts +390 -324
  40. package/dist/types/components/Map/interface/index.d.ts +13 -6
  41. package/dist/types/components/Map/types.d.ts +13 -1
  42. package/dist/types/components/Table/types.d.ts +1 -0
  43. package/dist/types/components/ToolTips/index.d.ts +12 -12
  44. package/dist/types/components/index.d.ts +1 -0
  45. package/dist/umd/index.css +1 -1
  46. package/dist/umd/index.umd.cjs +604 -118
  47. package/package.json +1 -1
  48. package/dist/es/DatePicker-BilQVlgi.js +0 -57
  49. package/dist/es/DiyDataTable-BQaaClFf.js +0 -331
  50. package/dist/es/Map-CXkF901e.js +0 -2279
  51. package/dist/es/Table-CzNjEPnP.js +0 -1155
@@ -1,2279 +0,0 @@
1
- import { defineComponent as Ue, openBlock as Ie, createElementBlock as et, createElementVNode as _e, ref as ne, computed as Ze, h as ae, createVNode as Qe, render as Zt, reactive as At, onMounted as Gt, onUnmounted as Wt } from "vue";
2
- import { S as Yt, M as it, T as Pe, X as Fe, p as ie, V as Ht, q as Bt, t as Xt, h as ht, r as tt, s as qt, u as Se, F as oe, v as _, O as pe, P as te, w as Ve, x as vt, L as Ge, y as jt, z as ct, A as le, B as he, C as ue, D as ke, G as Ye, I as Ce, H as Kt, J as _t, K as Qt, N as Jt, Q as yt, R as We, U as Je, W as at, Y as Ut, Z as It, _ as eo } from "./vendor-Crdostgq.js";
3
- import { _ as ot } from "./Button-Dp3Eoz3O.js";
4
- import { w as to } from "./utils-Co2iJhr8.js";
5
- const oo = { id: "scale-line-container" }, no = /* @__PURE__ */ Ue({
6
- __name: "scaleLine",
7
- setup(e, { expose: r }) {
8
- return r({
9
- setScaleLine: (l, a) => {
10
- a || (a = "metric");
11
- const d = new Yt({
12
- units: a
13
- }), s = document.getElementById("scale-line-container");
14
- s && (d.setTarget(s), l.addControl(d));
15
- }
16
- }), (l, a) => (Ie(), et("div", oo));
17
- }
18
- }), ro = /* @__PURE__ */ ot(no, [["__scopeId", "data-v-2bc5dee8"]]), lo = { class: "zoom" }, so = /* @__PURE__ */ Ue({
19
- __name: "zoomControl",
20
- props: {
21
- mapInstance: {
22
- type: Object,
23
- default: () => null
24
- }
25
- },
26
- setup(e) {
27
- const r = e;
28
- console.log("props", r);
29
- const n = () => {
30
- console.log("props");
31
- const { setZoom: a, getZoom: d, getInstall: s } = r.mapInstance.methods;
32
- if (!s()) return;
33
- const x = d();
34
- x && a(x + 1);
35
- }, l = () => {
36
- const { setZoom: a, getZoom: d, getInstall: s } = r.mapInstance.methods;
37
- if (!s()) return;
38
- const x = d();
39
- x && a(x - 1);
40
- };
41
- return (a, d) => (Ie(), et("div", lo, [
42
- _e("div", {
43
- class: "button big-button",
44
- onClick: n
45
- }, " + "),
46
- _e("div", {
47
- class: "button small-button",
48
- onClick: l
49
- }, " - ")
50
- ]));
51
- }
52
- }), io = /* @__PURE__ */ ot(so, [["__scopeId", "data-v-78a81741"]]), Ae = "a6e8f78974f2581f2ca00485b40c948f", U = {
53
- // 地图默认层级
54
- default: 13,
55
- // 地图缩放最小层级
56
- min: 3,
57
- // 地图缩放最大层级
58
- max: 18,
59
- // 船形图标最小渲染层级
60
- shipModelMin: 13,
61
- // 船形图标最小渲染层级
62
- shipTriggleMin: 16,
63
- // 船形图标最大渲染层级
64
- shipModelMax: 18,
65
- //根据原系统canvas图片转换svg长宽比例计算缩放值
66
- scaleNum: 0.555
67
- }, I = {
68
- // 经纬度 源数据 地理坐标 WGS84
69
- data: "EPSG:4326",
70
- // 墨卡托投影坐标 渲染坐标
71
- mercator: "EPSG:3857"
72
- }, co = [114.84, 30.52], mt = "https://static.zhihaoscm.cn/", He = 2003750834e-2;
73
- var xe = ((e) => (e.vectorTile = `https://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${Ae}`, e.vectorTileMark = `https://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${Ae}`, e.satelliteImgTile = `https://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${Ae}`, e.satelliteImgTileMark = `https://t0.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${Ae}`, e.greenTile = `${mt}/map/tile/{z}/{x}/{y}.png`, e))(xe || {}), Ne = /* @__PURE__ */ ((e) => (e[e.M = 1] = "M", e[e.KM = 2] = "KM", e[e.NM = 3] = "NM", e))(Ne || {}), ee = /* @__PURE__ */ ((e) => (e.PORT = "port", e.SHIP = "ship", e.TRACK = "track", e))(ee || {});
74
- function ao() {
75
- const e = ne(), r = () => e.value, n = () => r().getView(), l = () => {
76
- var g;
77
- return (g = n()) == null ? void 0 : g.getZoom();
78
- }, a = (g) => {
79
- var k;
80
- (k = n()) == null || k.setZoom(g);
81
- }, d = (g, k) => {
82
- var $;
83
- ($ = n()) == null || $.setCenter(ie([g, k]));
84
- }, s = () => {
85
- var k;
86
- const g = (k = n()) == null ? void 0 : k.getCenter();
87
- return Xt(g);
88
- }, h = () => {
89
- var g;
90
- return (g = r()) == null ? void 0 : g.getSize();
91
- }, x = new it(), t = (g, k) => {
92
- o(k);
93
- const $ = {
94
- zoom: k.zoom,
95
- center: ie(k.center),
96
- minZoom: U.min,
97
- maxZoom: U.max,
98
- constrainResolution: !0,
99
- enableRotation: !1,
100
- multiWorld: !0
101
- };
102
- let C = {
103
- target: g,
104
- controls: Bt({
105
- zoom: !1
106
- }),
107
- layers: [
108
- x.get("vectorTile"),
109
- x.get("vectorTileMark"),
110
- x.get("satelliteImgTile"),
111
- x.get("satelliteImgTileMark")
112
- ],
113
- view: new Ht($)
114
- };
115
- const z = new it(C);
116
- e.value = z;
117
- }, o = (g) => {
118
- x.set("vectorTile", new Pe({
119
- source: new Fe({ url: xe.vectorTile }),
120
- visible: g.layerType === "vector",
121
- zIndex: 0,
122
- preload: 1,
123
- className: "vector"
124
- })), x.set("vectorTileMark", new Pe({
125
- source: new Fe({ url: xe.vectorTileMark }),
126
- visible: g.layerType === "vector",
127
- zIndex: 1,
128
- preload: 1,
129
- className: "vector"
130
- })), x.set("satelliteImgTile", new Pe({
131
- source: new Fe({ url: xe.satelliteImgTile }),
132
- visible: g.layerType === "satellite",
133
- zIndex: 0,
134
- preload: 1,
135
- className: "satellite"
136
- })), x.set("satelliteImgTileMark", new Pe({
137
- source: new Fe({ url: xe.satelliteImgTileMark }),
138
- visible: g.layerType === "satellite",
139
- zIndex: 1,
140
- preload: 1,
141
- className: "satellite"
142
- })), x.set("greenMark", new Pe({
143
- source: new Fe({ url: xe.greenTile }),
144
- visible: g.showGreenLayer,
145
- zIndex: 2,
146
- className: "greenTile"
147
- }));
148
- };
149
- return {
150
- getInstall: r,
151
- getView: n,
152
- getZoom: l,
153
- setZoom: a,
154
- setCenter: d,
155
- getCenter: s,
156
- getSize: h,
157
- initMap: t,
158
- setBaseLayerMap: o
159
- };
160
- }
161
- const nt = function(e, r) {
162
- const n = Number(r) / 6e5;
163
- return [Number(e) / 6e5, n];
164
- }, uo = (e, r) => {
165
- const n = ie(e), l = r * 1e3, a = [
166
- n[0] - l,
167
- n[1] - l,
168
- n[0] + l,
169
- n[1] + l
170
- ], d = qt(a, I.mercator, I.data);
171
- return {
172
- leftTopPoint: { lng: d[0], lat: d[3] },
173
- rightTopPoint: { lng: d[2], lat: d[3] },
174
- rightBottomPoint: { lng: d[2], lat: d[1] },
175
- leftBottomPoint: { lng: d[0], lat: d[1] }
176
- };
177
- }, go = function(e, r) {
178
- const l = tt(e);
179
- let a = "";
180
- switch (console.log(r, Ne), r) {
181
- case Ne.M:
182
- a = Math.round(l * 100) / 100 + " m";
183
- break;
184
- case Ne.KM:
185
- a = Math.round(l / 1e3 * 100) / 100 + " km";
186
- break;
187
- case Ne.NM:
188
- a = (Math.round(l / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
189
- break;
190
- }
191
- return a;
192
- };
193
- function fo(e) {
194
- const r = e[0] * He / 180;
195
- let n = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
196
- return n = n * He / 180, [r, n];
197
- }
198
- function be(e = "") {
199
- let r = e.replace(/&?/g, "&");
200
- return r = r.replace(/&#x([0-9a-fA-F]+);?/g, (n, l) => {
201
- const a = parseInt(l, 16);
202
- return String.fromCodePoint(a);
203
- }), r;
204
- }
205
- const dt = (e) => {
206
- const r = new Se({
207
- font: "Normal 14px map-iconfont",
208
- text: be(e),
209
- fill: new oe({ color: "#fff" }),
210
- offsetY: -14
211
- });
212
- return new _({
213
- text: r,
214
- zIndex: 100
215
- });
216
- }, ut = (e, r = "lonlat") => {
217
- const n = { lon: 0, lat: 0 }, l = e[0] / He * 180;
218
- let a = e[1] / He * 180;
219
- return a = 180 / Math.PI * (2 * Math.atan(Math.exp(a * Math.PI / 180)) - Math.PI / 2), n.lon = l, n.lat = a, r === "lonlat" ? n : [l, a];
220
- }, ho = (e) => {
221
- const r = ht.duration(e, "minutes"), n = Math.floor(r.asDays()), l = r.hours(), a = r.minutes();
222
- let d = `${String(a).padStart(2, "0")}分`;
223
- return l !== 0 && (d = `${String(l).padStart(2, "0")}时${d}`), n !== 0 && (d = `${String(n).padStart(2, "0")}天${d}`), d;
224
- }, vo = (e, r) => {
225
- let n = null;
226
- const l = async (o) => {
227
- if (!e || (console.log("vehicleInfo", o), !(o != null && o.lon && (o != null && o.lat)))) return;
228
- const g = Math.abs(Number(o.lon)) > 180 ? nt(o.lon, o.lat) : [o.lon, o.lat];
229
- a(o, ie(g));
230
- const k = e == null ? void 0 : e.getView(), $ = new te(g);
231
- k.setCenter(Ve($.getCoordinates(), I.data, I.mercator));
232
- }, a = (o, g) => {
233
- const k = `${mt}map/car-icon.gif`;
234
- n || (n = new pe({
235
- element: document.createElement("div"),
236
- positioning: "center-center",
237
- stopEvent: !1
238
- // 允许交互事件穿透
239
- }), e.addOverlay(n));
240
- const $ = n.getElement();
241
- $.style.backgroundImage = `url(${k})`, $.style.width = "80px", $.style.height = "80px";
242
- const C = (o == null ? void 0 : o.drc) || "";
243
- $.style.transform = `rotate(${C}deg)`, $.style.backgroundSize = "cover", n == null || n.setPosition(g);
244
- };
245
- return {
246
- location: l,
247
- remove: () => {
248
- const o = n == null ? void 0 : n.getElement();
249
- o && (o.innerHTML = "");
250
- },
251
- renderTrack: (o, g, k) => {
252
- r.render(o, g, k, "truck", 1e3);
253
- },
254
- setCenter: (o) => {
255
- r.setCenter(o);
256
- },
257
- closeTrack: () => {
258
- r.close();
259
- },
260
- playTrack: (o, g) => {
261
- r.play(o, g);
262
- }
263
- };
264
- };
265
- var wt = /* @__PURE__ */ ((e) => (e[e.发动机使用中 = 0] = "发动机使用中", e[e.锚泊 = 1] = "锚泊", e[e.未操作 = 2] = "未操作", e[e.操纵能力受限 = 3] = "操纵能力受限", e[e.吃水受限 = 4] = "吃水受限", e[e.系泊 = 5] = "系泊", e[e.搁浅 = 6] = "搁浅", e[e.从事捕捞 = 7] = "从事捕捞", e[e.航行中 = 8] = "航行中", e[e.留作将来修正导航状态 = 9] = "留作将来修正导航状态", e[e.高速船留用 = 10] = "高速船留用", e[e.机动船尾推作业 = 11] = "机动船尾推作业", e[e.机动船顶推或侧推作业 = 12] = "机动船顶推或侧推作业", e[e.飞翼船留用 = 13] = "飞翼船留用", e[e.现行的 = 14] = "现行的", e[e.未定义 = 15] = "未定义", e))(wt || {}), se = /* @__PURE__ */ ((e) => (e.left = "left", e.right = "right", e.front = "front", e.up = "up", e.down = "down", e.back = "back", e))(se || {});
266
- const yo = (e) => {
267
- const r = /* @__PURE__ */ new Map(), n = {};
268
- let l = null;
269
- const a = "--";
270
- let d = null;
271
- const s = document.createElement("div"), h = new pe({
272
- element: s,
273
- positioning: "top-left",
274
- className: "track-label-popup"
275
- });
276
- let x, t, o, g, k, $ = !1, C = Date.now(), z, u = 0, m = null, P = 20;
277
- const b = 8, V = [], X = (c) => {
278
- var f;
279
- for (V.unshift(c); V.length > b; ) {
280
- const v = V.pop(), p = r.get(v);
281
- p && ((f = p.getSource()) == null || f.clear(), e == null || e.removeLayer(p), r.delete(v), delete n[v]);
282
- }
283
- };
284
- let G = "";
285
- const q = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], K = vt(async () => {
286
- if (l && n[l] && r.get(l).getVisible()) {
287
- console.log("reRenderTrackLine------------"), await Lt(l);
288
- const c = M(l, n[l]);
289
- ce(l, c);
290
- }
291
- }, 100), N = () => l && n[l] && r.get(l).getVisible(), M = (c, f) => {
292
- let v = [];
293
- const p = Math.max(1, Math.floor(f.length / P));
294
- return v = f.filter((R, S) => S % p === 0).map((R, S) => {
295
- if (Number(R.lon) > 180 || Number(R.lat) > 180) {
296
- const [A, Y] = nt(R.lon, R.lat);
297
- R.lon = A, R.lat = Y;
298
- }
299
- return R.center = [R.lon, R.lat], R.centerPoint = fo(R.center), R.time = ht(R.createdAt).format("YYYY-MM-DD HH:mm:ss"), R.id = c, R.index = S, R;
300
- }), v.filter(
301
- (R, S, A) => S === A.findIndex(
302
- (Y) => Math.abs(Y.lon - R.lon) < 1e-6 && Math.abs(Y.lat - R.lat) < 1e-6
303
- )
304
- );
305
- }, i = async (c, f, v, p = "ship", y = 200) => {
306
- if (!e || JSON.stringify(n[c]) === JSON.stringify(f) && l === c || (f = f == null ? void 0 : f.reverse(), h && p === "ship" && (e != null && e.getOverlays().getArray().includes(h) || e.addOverlay(h)), (f == null ? void 0 : f.length) < 2))
307
- return;
308
- X(c), l = c, n[c] = f, P = y;
309
- const D = Object.keys(n).findIndex((R) => R === c) || 0;
310
- G = v || q[D > 10 ? 10 : D], await L(), await rt(l);
311
- }, T = (c) => {
312
- const f = new ue();
313
- return new he({
314
- source: f,
315
- visible: !1,
316
- // 默认隐藏
317
- className: `track-layer-${c}`,
318
- renderBuffer: 1024,
319
- properties: { layerType: ee.TRACK },
320
- zIndex: 10
321
- });
322
- }, w = (c) => {
323
- r.forEach((f, v) => {
324
- var y;
325
- const p = v === c;
326
- f.getVisible() !== p && (f.setVisible(p), e.getLayers().getArray().includes(f) || e.addLayer(f), p || (y = f.getSource()) == null || y.clear());
327
- }), l = c;
328
- }, L = async () => {
329
- const c = l;
330
- if (!r.has(c)) {
331
- const D = T(c);
332
- r.set(c, D);
333
- }
334
- await w(c);
335
- const f = G || "", v = n[c] || [];
336
- if (!(v && v.length > 1)) return [];
337
- let p = [];
338
- p = M(c, v);
339
- const y = p.map((D) => D.centerPoint);
340
- p.length >= 2 && await F(c, y, f);
341
- }, F = (c, f, v) => {
342
- const p = new Ge(f), y = r.get(c).getSource(), D = y.getFeatureById(c);
343
- if (D)
344
- D.setGeometry(p), D.setId(c), D.setStyle(Z(v)), m = D;
345
- else {
346
- const R = new le({ geometry: p });
347
- R.setId(c), R.set("type", "line"), R.setStyle(Z(v)), y.addFeature(R), m = R;
348
- }
349
- return m;
350
- }, Z = (c) => new _({
351
- stroke: new ke({
352
- color: c,
353
- width: 2
354
- })
355
- }), W = (c, f, v) => {
356
- try {
357
- const p = c == null ? void 0 : c.get("data");
358
- if (c && p && f === "hover") {
359
- e.getTargetElement().style.cursor = p ? "pointer" : "";
360
- const y = H(p), D = v == null ? void 0 : v.coordinate;
361
- D && (s.querySelector(".popup-content"), s.innerHTML = y, h == null || h.setPosition(D));
362
- } else
363
- h && h.setPosition(void 0);
364
- } catch (p) {
365
- console.error("handleTrackMapEvent", p);
366
- }
367
- }, H = (c) => {
368
- if (!(c != null && c.time)) return;
369
- let f = "";
370
- return c != null && c.stayTime && (f = `
371
- <div class="item w-100">
372
- <div class="item-label">停泊时间约</div>
373
- <div class="item-item">${ho(Number(c.stayTime))}</div>
374
- </div>
375
- `), `
376
- <div class="track-point-popup">
377
- <div class="item">
378
- <div class="item-label">状态</div>
379
- <div class="item-item">${c != null && c.sailStatus ? wt[c.sailStatus] : a}</div>
380
- </div>
381
- <div class="item">
382
- <div class="item-label">航速</div>
383
- <div class="item-item">${c.speed || a}</div>
384
- </div>
385
- <div class="item">
386
- <div class="item-label">艏向</div>
387
- <div class="item-item">${c.hdg || a}</div>
388
- </div>
389
- <div class="item">
390
- <div class="item-label">航向</div>
391
- <div class="item-item">${c.cog || a}</div>
392
- </div>
393
- <div class="item">
394
- <div class="item-label">经度</div>
395
- <div class="item-item">${c.lon || a}</div>
396
- </div>
397
- <div class="item">
398
- <div class="item-label">纬度</div>
399
- <div class="item-item">${c.lat || a}</div>
400
- </div>
401
- <div class="item w-100">
402
- <div class="item-label">时间</div>
403
- <div class="item-item">${c.time}</div>
404
- </div>
405
- ${f ?? f}
406
- </div>`;
407
- }, O = (c) => {
408
- const v = c.map((S) => {
409
- const A = e.getPixelFromCoordinate(ie(S.center));
410
- return {
411
- ...S,
412
- original: S,
413
- pixel: A,
414
- distance: 0
415
- // 先初始化,后续计算
416
- };
417
- });
418
- let p = 0;
419
- v[0].distance = 0;
420
- for (let S = 1; S < v.length; S++) {
421
- const A = v[S - 1].pixel, Y = v[S].pixel, J = Y[0] - A[0], E = Y[1] - A[1];
422
- p += Math.sqrt(J * J + E * E), v[S].distance = p;
423
- }
424
- const y = v.filter(
425
- (S, A) => A === 0 || A === v.length - 1
426
- ), D = [];
427
- for (let S = 0; S < y.length; S++) {
428
- const A = y[S];
429
- if (D.push(A), S < y.length - 1) {
430
- const Y = y[S + 1], J = Y.distance - A.distance, E = Math.floor(J / 100);
431
- for (let B = 1; B <= E; B++) {
432
- const j = A.distance + B * 100;
433
- if (j >= Y.distance) break;
434
- const Q = re(
435
- v,
436
- j
437
- );
438
- Q && D.push(Q);
439
- }
440
- }
441
- }
442
- return Array.from(
443
- new Map(D.map((S) => [S.distance.toFixed(2), S])).values()
444
- ).map((S) => ({
445
- ...S.original,
446
- // 优先保留原始数据
447
- ...S,
448
- // 覆盖坐标等计算属性
449
- coord: S.coord,
450
- // 确保使用插值后的坐标
451
- pixel: S.pixel,
452
- distance: S.distance
453
- }));
454
- };
455
- function re(c, f) {
456
- for (let v = 1; v < c.length; v++) {
457
- const p = c[v - 1], y = c[v];
458
- if (f >= p.distance && f <= y.distance) {
459
- const D = (f - p.distance) / (y.distance - p.distance), R = p.pixel[0] + D * (y.pixel[0] - p.pixel[0]), S = p.pixel[1] + D * (y.pixel[1] - p.pixel[1]), A = e == null ? void 0 : e.getCoordinateFromPixel([R, S]);
460
- return {
461
- ...p,
462
- // 继承前一个点的属性(可调整)
463
- coord: A,
464
- pixel: [R, S],
465
- distance: f,
466
- original: void 0
467
- // 明确标记为插值生成点
468
- };
469
- }
470
- }
471
- return null;
472
- }
473
- const ce = async (c, f) => {
474
- const v = O(f);
475
- console.log("simplifiedPoints", v.length, "list", f.length);
476
- const p = v.map((S) => de(S)), y = v.map((S) => Mt(S, G)), D = Pt(c, v, f, G);
477
- r.get(c).getSource().addFeatures([...p, ...y, ...D]);
478
- }, de = (c) => {
479
- const f = new le({
480
- geometry: new te(c.centerPoint),
481
- data: c
482
- });
483
- f.set("type", "track_point"), f.set("trackId", c.id), f.set("data", c);
484
- let v = [
485
- ...Tt(c, G)
486
- ];
487
- return (c.index === 0 || c.index === n[c.id].length - 1) && (v = [...Ft(c)], f.set("type", "track_begin")), c.state !== void 0 && c.state !== null && (v = [...Et(c)], f.set("type", "track_icon")), f.setStyle(v), f;
488
- }, Be = window.devicePixelRatio || 1, Me = /* @__PURE__ */ new Map();
489
- let ge = null, Xe = null;
490
- function Ct(c, f) {
491
- const v = `${c}`;
492
- if (Me.has(v))
493
- return Me.get(v);
494
- if (!ge) {
495
- ge = document.createElement("canvas");
496
- try {
497
- Xe = ge.getContext("2d", {
498
- willReadFrequently: !0
499
- });
500
- } catch (st) {
501
- console.log("e", st), Xe = ge.getContext("2d");
502
- }
503
- }
504
- const p = ge, y = Xe;
505
- if (!y) return "";
506
- p.width = 0, p.height = 0;
507
- const D = 2, R = 8, S = 16, A = window.devicePixelRatio || 1, Y = "500 12px Arial";
508
- y.font = Y;
509
- const E = y.measureText(c).width, B = R + E + R, j = D + 14 + D;
510
- let Q = 0, fe = 0, ye = 0, me = 0, Re = 0, Le = 0, we = 0, Te = 0;
511
- Q = S + B, fe = S + j, ye = B, me = j, Re = B + S, Le = 0, we = 0, Te = S, p.width = Math.round(Q * A), p.height = Math.round(fe * A), y.scale(A, A), y.clearRect(0, 0, Q, fe), y.beginPath(), y.moveTo(ye, me), y.lineTo(Re, Le), y.strokeStyle = f || "#FFF", y.lineWidth = 1, y.stroke(), y.fillStyle = "#FFF", y.fillRect(we, Te, B, j), y.strokeStyle = f || "#FFF", y.lineWidth = 1, y.strokeRect(we, Te, B, j), y.font = Y, y.textBaseline = "middle";
512
- const Oe = Te + D / 2 + j / 2;
513
- y.strokeStyle = "#ffffff", y.lineWidth = 1, y.strokeText(c, we + R, Oe), y.fillStyle = "#000000", y.fillText(c, we + R, Oe);
514
- const De = p.toDataURL("image/png");
515
- return Me.set(v, De), De;
516
- }
517
- const Mt = (c, f) => {
518
- const v = Ct(c.time, f), p = new le({
519
- geometry: new te(c.centerPoint),
520
- data: c
521
- });
522
- p.set("type", "track_point_label");
523
- const y = new _({
524
- image: new Ce({
525
- src: v,
526
- anchor: [1, 0],
527
- displacement: [0, 0],
528
- scale: 1 / Be,
529
- anchorXUnits: "fraction",
530
- anchorYUnits: "fraction"
531
- }),
532
- zIndex: 100
533
- });
534
- return p.setStyle(y), p;
535
- }, Lt = (c) => {
536
- const f = r.get(c).getSource();
537
- f.forEachFeature((v) => {
538
- v.get("type") !== "line" && f.removeFeature(v);
539
- });
540
- }, Tt = (c, f) => [
541
- new _({
542
- // 扩大交互热区
543
- image: new Ye({
544
- stroke: new ke({ color: "rgba(0, 0, 0, 0.01)", width: 20 }),
545
- radius: 3
546
- })
547
- }),
548
- // 轨迹点样式
549
- new _({
550
- image: new Ye({
551
- fill: new oe({ color: f }),
552
- stroke: new ke({ color: "#fff", width: 2 }),
553
- radius: 3
554
- })
555
- })
556
- // textStyle,
557
- ], Et = (c) => {
558
- const f = "#E31818", v = "#1890FF", p = "&#xe6d2", y = new _({
559
- text: new Se({
560
- font: "Normal 22px map-iconfont",
561
- text: be(p),
562
- offsetY: -10,
563
- fill: new oe({
564
- color: Number(c.state) === 0 ? f : Number(c.state) === 1 ? v : ""
565
- })
566
- }),
567
- zIndex: 99
568
- }), R = dt("&#xe6e2;"), A = dt("&#xe703;"), Y = [];
569
- return Number(c.state) === 0 ? Y.push(R) : Number(c.state) === 1 && Y.push(A), Y.push(y), Y;
570
- }, Pt = (c, f, v, p) => {
571
- const y = f || [], D = f.length;
572
- D || (y.push(v[0]), y.push(v[v.length - 1]));
573
- const R = new Set(f.map((A) => `${A.centerPoint[0]},${A.centerPoint[1]}`)), S = [];
574
- for (let A = 0; A < D - 1; A++) {
575
- let Y;
576
- const J = f[A], E = (f[A + 1].index + J.index) / 2;
577
- if (E % 2 === 0)
578
- Y = v[E].centerPoint;
579
- else {
580
- const B = v[Math.floor(E)], j = v[Math.ceil(E)];
581
- if (B && j) {
582
- const [Q, fe] = B.centerPoint, [ye, me] = j.centerPoint;
583
- Y = [(Q + ye) / 2, (fe + me) / 2];
584
- }
585
- }
586
- if (Y) {
587
- const B = `${Y[0]},${Y[1]}`;
588
- if (!R.has(B)) {
589
- const j = new le({
590
- geometry: new te(Y)
591
- });
592
- j.set("type", "track_arrow"), j.setStyle(
593
- new _({
594
- text: new Se({
595
- font: "700 12px map-iconfont",
596
- text: be("&#xe6bc;"),
597
- fill: new oe({ color: p }),
598
- rotation: lt(
599
- f[A].center,
600
- f[A + 1].center
601
- ) * (Math.PI / 180)
602
- })
603
- })
604
- ), S.push(j), R.add(B);
605
- }
606
- }
607
- }
608
- return S;
609
- }, rt = (c) => {
610
- var D, R;
611
- const f = e.getView(), v = (D = r == null ? void 0 : r.get(c)) == null ? void 0 : D.getSource(), p = m || (c ? v == null ? void 0 : v.getFeatureById(c) : null);
612
- if (!p) return;
613
- const y = (R = p == null ? void 0 : p.getGeometry()) == null ? void 0 : R.getExtent();
614
- if (!y || y[0] === y[2] || y[1] === y[3]) {
615
- console.warn("Invalid track extent");
616
- return;
617
- }
618
- try {
619
- const S = y[2] - y[0], A = y[3] - y[1], Y = 1e-4;
620
- if (S < Y || A < Y) {
621
- const E = [(y[0] + y[2]) / 2, (y[1] + y[3]) / 2];
622
- f.setCenter(E);
623
- return;
624
- }
625
- const J = jt(y, Math.max(S, A) * 0.1);
626
- f.fit(J, {
627
- maxZoom: U.max,
628
- padding: [30, 30, 30, 30]
629
- // 添加边距
630
- });
631
- } catch (S) {
632
- console.error("setTrackViewCenter error:", S);
633
- }
634
- }, Ft = (c) => {
635
- const f = "&#xe69b;", y = c.index === 0 ? "#fcdc3f" : "#ff0000";
636
- return [new _({
637
- text: new Se({
638
- font: "Normal 14px map-iconfont",
639
- text: be(f),
640
- fill: new oe({ color: y })
641
- }),
642
- zIndex: 101
643
- })];
644
- }, St = () => {
645
- console.log("清除所有的轨迹-----"), ze(), r.forEach((f) => {
646
- var v;
647
- (v = f.getSource()) == null || v.clear(), e == null || e.removeLayer(f);
648
- }), Object.keys(n).forEach((f) => {
649
- r.delete(f), delete n[f];
650
- });
651
- }, Nt = (c) => {
652
- const f = r.get(c || l);
653
- f == null || f.setVisible(!1);
654
- const v = e.getOverlays().getArray();
655
- for (let p = 0; p < v.length; ) {
656
- const y = v[p];
657
- y.get("class") === "track-label-overlay" ? (y.setPosition(void 0), y.dispose()) : p++;
658
- }
659
- ze();
660
- }, Rt = (c, f = Ne.NM) => {
661
- const v = {
662
- id: c,
663
- length: "--"
664
- }, y = (n[c] || []).map(
665
- (R) => Ve([R.lon, R.lat], I.data, I.mercator)
666
- ), D = new Ge(y);
667
- return v.length = go(D, f) || "--", v;
668
- }, $t = (c, f) => {
669
- Vt(String(c), f);
670
- }, Vt = (c, f) => {
671
- const v = n[String(c)], p = v == null ? void 0 : v.map((y) => [y.lon, y.lat]);
672
- p && Dt(p, f);
673
- }, qe = new _({
674
- text: new Se({
675
- font: "700 20px map-iconfont",
676
- text: be("&#xe657;"),
677
- fill: new oe({ color: "#ff0000" }),
678
- rotation: 0
679
- // 初始旋转角度
680
- })
681
- }), zt = (c, f) => {
682
- var E, B;
683
- const v = Number(50 * f), p = ((E = c.frameState) == null ? void 0 : E.time) ?? Date.now(), y = p - C;
684
- if (u = (u + v * y / 1e6) % 2, C = p, u >= 1) {
685
- ze();
686
- return;
687
- }
688
- const D = t.getCoordinateAt(
689
- u > 1 ? 2 - u : u
690
- ), R = t.getCoordinateAt(
691
- u > 1 ? u - 0.01 : u
692
- ), S = t.getCoordinateAt(
693
- u > 1 ? 2 - u : u + 0.01
694
- ), Y = lt(
695
- ut(R, "array"),
696
- ut(S, "array")
697
- ) * Math.PI / 180;
698
- (B = qe.getText()) == null || B.setRotation(Y), g.setCoordinates(D);
699
- const J = Kt(c);
700
- J.setStyle(qe), J.drawGeometry(g), e == null || e.render();
701
- }, Ot = () => {
702
- var c;
703
- $ = !0, C = Date.now(), u = 0, g = ((c = o.getGeometry()) == null ? void 0 : c.clone()) || new te([0, 0]), d && (z == null || z.on("postrender", d)), k == null || k.setGeometry(void 0);
704
- }, ze = () => {
705
- $ && ($ = !1, k == null || k.setGeometry(void 0), d && z && z.un("postrender", d), z && (e == null || e.removeLayer(z)), z = null, k = null);
706
- }, Dt = (c, f) => {
707
- $ && ze(), x = new ct({
708
- factor: 1e6
709
- }).writeGeometry(new Ge(c)), t = new ct({
710
- factor: 1e6
711
- }).readGeometry(x, {
712
- dataProjection: I.data,
713
- featureProjection: I.mercator
714
- }), o = new le({
715
- type: "icon",
716
- geometry: new te(t.getFirstCoordinate())
717
- });
718
- const v = o.getGeometry();
719
- g = v ? v.clone() : new te([0, 0]), k = new le({
720
- type: "geoMarker",
721
- style: qe,
722
- geometry: g
723
- }), z = new he({
724
- source: new ue({
725
- features: [k]
726
- })
727
- }), e == null || e.addLayer(z), d = (p) => zt(p, f), Ot();
728
- }, lt = (c, f, v) => {
729
- function p(E) {
730
- return 180 * (E % (2 * Math.PI)) / Math.PI;
731
- }
732
- function y(E) {
733
- return E % 360 * Math.PI / 180;
734
- }
735
- function D(E) {
736
- var B;
737
- if (!E) throw new Error("Coordinate is required");
738
- if (!Array.isArray(E)) {
739
- if ((E == null ? void 0 : E.type) === "Feature" && (E == null ? void 0 : E.geometry) !== null && ((B = E == null ? void 0 : E.geometry) == null ? void 0 : B.type) === "Point")
740
- return E == null ? void 0 : E.geometry.coordinates;
741
- if (E.type === "Point") return (E == null ? void 0 : E.coordinates) || [];
742
- }
743
- if (Array.isArray(E) && E.length >= 2 && !Array.isArray(E[0]) && !Array.isArray(E[1]))
744
- return E;
745
- throw new Error(
746
- "Coordinate must be GeoJSON Point or an Array of numbers"
747
- );
748
- }
749
- function R(E, B, j = {}) {
750
- if (j.final)
751
- return function(Oe, De) {
752
- return (R(De, Oe) + 180) % 360;
753
- }(E, B);
754
- const Q = D(E), fe = D(B), ye = y(Q[0]), me = y(fe[0]), Re = y(Q[1]), Le = y(fe[1]), we = Math.sin(me - ye) * Math.cos(Le), Te = Math.cos(Re) * Math.sin(Le) - Math.sin(Re) * Math.cos(Le) * Math.cos(me - ye);
755
- return p(Math.atan2(we, Te));
756
- }
757
- function S(E) {
758
- return !isNaN(E) && E !== null && !Array.isArray(E);
759
- }
760
- function A(E, B = {}, j = {}) {
761
- return E || console.log("Coordinates are required"), Array.isArray(E) || console.log("Coordinates must be an Array"), E.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!S(E[0]) || !S(E[1])) && console.log("Coordinates must contain numbers"), Y({ type: "Point", coordinates: E }, B, j);
762
- }
763
- function Y(E, B = {}, j = {}) {
764
- const Q = {
765
- type: "Feature",
766
- id: "",
767
- properties: {},
768
- bbox: {},
769
- geometry: {}
770
- };
771
- return j.id !== void 0 && (Q.id = j.id), j.bbox && (Q.bbox = j.bbox), Q.properties = B, Q.geometry = E, Q;
772
- }
773
- const J = R(A(c), A(f), v);
774
- return J < 0 ? 360 + J : J;
775
- };
776
- return {
777
- render: i,
778
- remove: St,
779
- play: $t,
780
- setCenter: rt,
781
- close: Nt,
782
- getLength: Rt,
783
- handleTrackMapEvent: W,
784
- reRenderTrackLine: K,
785
- getTrackStatus: N
786
- };
787
- };
788
- function mo(e) {
789
- console.log("useShipOverlay", e);
790
- const r = ne(null), n = Ze(() => ({
791
- "--overlay-color": "#FFF",
792
- "--bg-color1": e.colors && e.colors[0] ? e.colors[0] : "#ffffff",
793
- // 默认第一个颜色
794
- "--bg-color2": e.colors && e.colors[1] ? e.colors[1] : "#ffffff",
795
- "--bg-color": "#ffffff",
796
- position: "relative",
797
- "pointer-events": "none"
798
- })), l = Ze(() => {
799
- var s;
800
- return {
801
- position: "relative",
802
- "border-radius": "1px",
803
- "background-color": "var(--content-bg)",
804
- color: "#000",
805
- padding: "2px 5px 2px 0px",
806
- font: "500 Normal 12px",
807
- "font-size": "12px",
808
- "box-shadow": "0 2px 10px rgba(0, 0, 0, 0.2)",
809
- "white-space": "nowrap",
810
- border: "1px solid #FFF",
811
- "pointer-events": "auto",
812
- // 'transition': 'background-color 0.5s ease, border 0.5s ease',
813
- "z-index": "1",
814
- display: "flex",
815
- "align-items": "center",
816
- animation: e.selected ? e.colors && ((s = e.colors) == null ? void 0 : s.length) >= 2 ? "blink-dual 2s ease-in-out infinite" : "blink-single 1.5s ease-in-out infinite" : "none"
817
- // "animation": props.selected ? 'blink 1.5s ease-in-out infinite' : 'none', // 动画开关
818
- };
819
- }), a = Ze(() => ({
820
- width: "14px",
821
- height: "14px",
822
- margin: "1px 5px 1px 1px",
823
- "background-color": "var(--attention-bg)"
824
- })), d = Ze(() => ({
825
- position: "absolute",
826
- top: "0px",
827
- color: "var(--overlay-color)",
828
- "pointer-events": "none",
829
- transform: "translateY(-1px)",
830
- "z-index": "0",
831
- width: "20px",
832
- height: "20px",
833
- overflow: "visible",
834
- left: "-20px"
835
- }));
836
- return () => ae("div", {
837
- ref: r,
838
- class: "ship-overlay-container",
839
- style: n.value
840
- }, [
841
- ae(
842
- "div",
843
- {
844
- class: "ship-overlay-content",
845
- style: l.value
846
- },
847
- [
848
- ae("div", {
849
- style: e.selected ? a.value : {}
850
- }, ""),
851
- ae("div", {
852
- class: "text",
853
- style: {
854
- fontSize: "12px",
855
- fontWeight: 500,
856
- fontFamily: "Arial"
857
- }
858
- }, e.name || "未命名船舶"),
859
- ae("div", {
860
- class: "icons",
861
- style: {
862
- color: "#3370ff"
863
- }
864
- }, [
865
- e.existDevice ? ae("i", {
866
- class: "map-iconfont icon-camera",
867
- style: {
868
- fontSize: "12px"
869
- }
870
- }) : "",
871
- e.existMobile ? ae("i", {
872
- class: "map-iconfont icon-tele",
873
- style: {
874
- fontSize: "12px"
875
- }
876
- }) : "",
877
- e.existWaterGauge ? ae("i", {
878
- class: "map-iconfont icon-ruler",
879
- style: {
880
- fontSize: "12px"
881
- }
882
- }) : ""
883
- ])
884
- ]
885
- ),
886
- ae("svg", {
887
- class: "ship-overlay-line",
888
- style: d.value,
889
- viewBox: "0 0 20 20",
890
- xmlns: "http://www.w3.org/2000/svg"
891
- }, [
892
- ae("line", {
893
- x1: "0",
894
- y1: "20",
895
- x2: "20",
896
- y2: "4",
897
- stroke: "white",
898
- "stroke-width": "1"
899
- })
900
- ])
901
- ]);
902
- }
903
- const wo = (e) => {
904
- const { spd: r, hdg: n, cog: l } = e;
905
- return r ? n !== null && +n != 511 && l !== null ? l - +n >= 3 ? se.right : l - +n <= -3 ? se.left : se.front : se.front : "";
906
- }, Ee = (e, r) => {
907
- const { shipData: n } = r.getProperties(), l = xt(e), a = bt(e, n, l);
908
- return xo(r, a, l);
909
- }, xt = (e) => {
910
- const r = e == null ? void 0 : e.getView().getZoom();
911
- return r && r <= U.shipModelMax && r >= U.shipTriggleMin ? "ship" : "triangle";
912
- }, bt = (e, r, n) => {
913
- if (n === "ship") {
914
- const { len: l, wid: a } = r, d = 97, s = 20, x = 1 / (e == null ? void 0 : e.getView().getResolution()), t = l * x / d, o = a * x / s, g = Math.min(t, o);
915
- return g < 0.2 ? 0.2 : g > 2 ? 2 : g;
916
- }
917
- return U.scaleNum;
918
- }, xo = (e, r, n) => {
919
- const { color: l, direct: a, isHighlight: d, shipData: s } = e.getProperties(), h = ((s == null ? void 0 : s.cog) - 90 + 360) % 360;
920
- return new _({
921
- image: new Ce({
922
- src: x(),
923
- scale: r || U.scaleNum,
924
- anchor: [0.5, 0.5],
925
- rotation: h * Math.PI / 180,
926
- rotateWithView: !1
927
- })
928
- });
929
- function x() {
930
- return `data:image/svg+xml;utf8,${encodeURIComponent(t())}`;
931
- }
932
- function t() {
933
- switch (n) {
934
- case "triangle":
935
- return `<svg width="41" height="24" viewBox="0 0 41 24" fill="none" xmlns="http://www.w3.org/2000/svg">
936
- <path d="M30.8843 12.6777L2.21343 21.7067C1.75559 21.8509 1.28947 21.509 1.28947 21.029L1.28947 2.97103C1.28947 2.49102 1.75558 2.14913 2.21342 2.29331L30.8843 11.3223C31.5471 11.531 31.5471 12.469 30.8843 12.6777Z"
937
- fill="${l}" stroke="${d ? "#FF2424" : "black"}" stroke-width="${d ? "2" : "0.578947"}" />
938
- <!--path船航向左边或者向前-->
939
- ${a === se.left && `<path d="M30 12L40 12L40 8" stroke="${d ? "#FF2424" : "black"}" stroke-width="2"/>`}
940
- <!--path船航向右边-->
941
- ${a === se.right && `<path d="M30 12L40 12L40 16" stroke="${d ? "#FF2424" : "black"}" stroke-width="2"/>`}
942
- <!--path黑线无左右-->
943
- ${a === se.front && `<path d="M30 12L40 12" stroke="${d ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
944
- </svg>
945
- `;
946
- case "ship":
947
- return `<svg width="97" height="20" viewBox="0 0 97 20" fill="none" xmlns="http://www.w3.org/2000/svg">
948
- <path d="M0.289474 17.3433L0.289474 2.65655C0.289474 2.28572 0.574654 1.97725 0.944343 1.9482L22.0544 0.289473L67.5204 0.289473C67.6295 0.289473 67.7372 0.314613 67.835 0.362943L86.0565 9.3629C86.5844 9.6236 86.5844 10.3763 86.0565 10.637L67.835 19.6371C67.7372 19.6854 67.6295 19.7105 67.5203 19.7105L22.0544 19.7105L0.944343 18.0517C0.574653 18.0226 0.289474 17.7142 0.289474 17.3433Z"
949
- fill="${l}" stroke="${d ? "#FF2424" : "black"}" stroke-width="${d ? "4" : "0.578947"}"/>
950
- ${a === se.left && `<path d="M86 10L96 10L96 6" stroke="${d ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
951
- ${a === se.right && `<path d="M86 10L96 10L96 14" stroke="${d ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
952
- ${a === se.front && `<path d="M86 10L96 10" stroke="${d ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
953
- </svg>
954
- `;
955
- default:
956
- return "";
957
- }
958
- }
959
- }, bo = (e, r) => {
960
- const n = xt(e), l = bt(e, r, n), a = n === "ship" ? 109 : 49, d = `
961
- <svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 49 49" fill="none">
962
- <path d="M1.99982 46.9998L1.99982 1.99982L46.9998 1.99982L46.9998 46.9998L1.99982 46.9998Z" fill="#FF2424" fill-opacity="0.2"/>
963
- <path fill-rule="evenodd" clip-rule="evenodd" d="M19.9998 0.5V3.5L3.49976 3.5V20H0.499756V0.500002L19.9998 0.5ZM45.4998 3.5H28.9998V0.5H48.4998V20H45.4998V3.5ZM48.4998 29L48.4998 48.5H28.9998V45.5H45.4998L45.4998 29H48.4998ZM3.49976 45.5L3.49976 29H0.499756L0.499758 48.5L19.9998 48.5V45.5L3.49976 45.5Z" fill="#FF2424"/>
964
- </svg>
965
- `;
966
- return new _({
967
- image: new Ce({
968
- src: `data:image/svg+xml;utf8,${encodeURIComponent(d)}`,
969
- scale: l,
970
- anchorXUnits: "fraction",
971
- anchorYUnits: "fraction"
972
- })
973
- });
974
- };
975
- function ko(e, r, n, l) {
976
- if (r) {
977
- const a = new pe({
978
- element: n,
979
- positioning: "top-left",
980
- id: "label-" + (l == null ? void 0 : l.id),
981
- offset: [20, -20],
982
- autoPan: !1,
983
- position: r,
984
- className: l != null && l.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
985
- });
986
- a.set("class", "zh-map-ship-overlay"), e.addOverlay(a);
987
- }
988
- }
989
- const po = (e, r) => {
990
- const { lon: n, lat: l, blinking: a } = r, d = kt(r);
991
- n && l && ko(e, ie([n, l]), d, { ...r, blinking: a });
992
- }, kt = (e) => {
993
- const r = document.createElement("div");
994
- r.className = "ship-overlay-box", r.style.position = "relative";
995
- const { lon: n, lat: l, blinking: a, blinkingColors: d, name: s } = e, h = Qe({
996
- setup() {
997
- return mo({
998
- position: [n + 2e-3, l + 2e-3],
999
- selected: a,
1000
- name: s,
1001
- colors: d || [],
1002
- existDevice: e == null ? void 0 : e.existDevice,
1003
- existMobile: e == null ? void 0 : e.existMobile,
1004
- existWaterGauge: e == null ? void 0 : e.existWaterGauge
1005
- });
1006
- }
1007
- });
1008
- return Zt(h, r), r;
1009
- }, gt = (e) => {
1010
- const r = [];
1011
- return e.existDevice && r.push("&#xe687;"), e.existMobile && r.push("&#xe688;"), e.existWaterGauge && r.push("&#xe686;"), r;
1012
- };
1013
- function Co() {
1014
- const e = [
1015
- "left-top",
1016
- "left-middle",
1017
- "left-bottom",
1018
- "right-top",
1019
- "right-middle",
1020
- "right-bottom"
1021
- ];
1022
- return e[Math.floor(Math.random() * e.length)];
1023
- }
1024
- const Mo = window.devicePixelRatio || 1, je = /* @__PURE__ */ new Map();
1025
- let $e = null, Ke = null;
1026
- function Lo(e, r, n = "left-bottom", l = 10) {
1027
- const a = `${e}-${r.join(",")}-${n}-${l}`;
1028
- if (je.has(a))
1029
- return je.get(a);
1030
- if (!$e) {
1031
- $e = document.createElement("canvas");
1032
- try {
1033
- Ke = $e.getContext("2d", {
1034
- willReadFrequently: !0
1035
- });
1036
- } catch (Z) {
1037
- console.log("e", Z), Ke = $e.getContext("2d");
1038
- }
1039
- }
1040
- const d = $e, s = Ke;
1041
- if (!s) return "";
1042
- d.width = 0, d.height = 0;
1043
- const h = 2, x = 4, t = 16, o = window.devicePixelRatio || 1, g = "500 12px Arial", k = "12px map-iconfont";
1044
- s.font = g;
1045
- const C = s.measureText(e).width;
1046
- s.font = k;
1047
- const z = r.map((Z) => ({ width: s.measureText(be(Z)).width, height: 14 })), u = z.reduce((Z, W) => Z + W.width, 0), m = r.length * l, P = x + C + u + m + x, b = h + 14 + h * 2;
1048
- let V, X, G = 0, q = 0, K = 0, N = 0, M = 0, i = 0;
1049
- switch (V = t + P, n) {
1050
- case "right-top":
1051
- X = t + b, G = 0, q = t + b, K = t, N = 0, M = t, i = 0;
1052
- break;
1053
- case "right-middle":
1054
- X = b, G = 0, q = b / 2, K = t, N = b / 2, M = t, i = 0;
1055
- break;
1056
- case "right-bottom":
1057
- X = t + b, G = 0, q = 0, K = t, N = t, M = t, i = t;
1058
- break;
1059
- case "left-top":
1060
- X = t + b, G = P, q = t, K = P + t, N = b + t, M = 0, i = 0;
1061
- break;
1062
- case "left-middle":
1063
- X = b, G = P, q = b / 2, K = P + t, N = b / 2, M = 0, i = 0;
1064
- break;
1065
- case "left-bottom":
1066
- X = t + b, G = P, q = b, K = P + t, N = 0, M = 0, i = t;
1067
- break;
1068
- }
1069
- X = X + h, d.width = Math.round(V * o), d.height = Math.round(X * o), s.scale(o, o), s.clearRect(0, 0, V, X), s.beginPath(), s.moveTo(G, q), s.lineTo(K, N), s.strokeStyle = "#FFF", s.lineWidth = 1, s.stroke(), s.fillStyle = "#FFF", s.fillRect(M, i, P, b), s.font = g, s.textBaseline = "middle";
1070
- const T = i + h / 2 + b / 2;
1071
- s.strokeStyle = "#ffffff", s.lineWidth = 1, s.strokeText(e, M + x, T), s.fillStyle = "#000000", s.fillText(e, M + x, T), s.font = k, s.fillStyle = "#3370ff";
1072
- let w = M + x + C + l;
1073
- const L = i + b / 2;
1074
- r.length > 0 && r.forEach((Z, W) => {
1075
- s.fillText(be(Z), w, L), w += z[W].width + l;
1076
- });
1077
- const F = d.toDataURL("image/png");
1078
- return je.set(a, F), F;
1079
- }
1080
- const ft = (e, r) => {
1081
- const { name: n, rightIcons: l, selected: a } = e.getProperties(), d = r !== 1 ? Co() : "right-top", s = Lo(n, l, d);
1082
- let h = [0, 0];
1083
- switch (d) {
1084
- case "right-top":
1085
- h = [0, 1];
1086
- break;
1087
- case "right-middle":
1088
- h = [0, 0.5];
1089
- break;
1090
- case "right-bottom":
1091
- h = [0, 0];
1092
- break;
1093
- case "left-top":
1094
- h = [1, 1];
1095
- break;
1096
- case "left-middle":
1097
- h = [1, 0.5];
1098
- break;
1099
- case "left-bottom":
1100
- h = [1, 0];
1101
- break;
1102
- }
1103
- return new _({
1104
- image: new Ce({
1105
- src: s,
1106
- anchor: h,
1107
- displacement: [0, 0],
1108
- scale: 1 / Mo,
1109
- anchorXUnits: "fraction",
1110
- anchorYUnits: "fraction"
1111
- }),
1112
- zIndex: a ? 100 : 10
1113
- });
1114
- }, To = (e) => {
1115
- let r = null, n = null;
1116
- const l = new ue(), a = new _t({
1117
- source: l,
1118
- className: "zh-map--ship-layer",
1119
- renderBuffer: 300,
1120
- zIndex: 101,
1121
- properties: { layerType: ee.SHIP }
1122
- }), d = new ue(), s = new he({
1123
- source: d,
1124
- className: "zh-map--ship-label-layer",
1125
- zIndex: 102,
1126
- updateWhileInteracting: !1,
1127
- updateWhileAnimating: !1,
1128
- declutter: !0
1129
- }), h = new ue(), x = new he({
1130
- source: h,
1131
- className: "zh-map--ship-selected-layer",
1132
- zIndex: 999
1133
- });
1134
- e == null || e.addLayer(a), e == null || e.addLayer(s), e == null || e.addLayer(x);
1135
- let t = null, o = "", g = {}, k = {};
1136
- const $ = (i) => {
1137
- if (!i || !e) return;
1138
- const T = (n == null ? void 0 : n.id) || (r == null ? void 0 : r.get("id"));
1139
- if (n) {
1140
- const w = i.filter((L) => L.id === T);
1141
- w.length === 0 ? i.push(n) : n = w[0];
1142
- }
1143
- m(), M(i), z();
1144
- }, C = (i) => {
1145
- var O;
1146
- const T = (n == null ? void 0 : n.id) || (r == null ? void 0 : r.get("id")), w = ie([i == null ? void 0 : i.lon, i == null ? void 0 : i.lat]), L = ((O = k[i.id]) == null ? void 0 : O.blinkColors) || [], Z = L[L.length - 1] || i.fill || "#04C900", W = wo(i), H = new le({
1147
- geometry: new te(w),
1148
- // 船舶数据
1149
- shipData: i,
1150
- id: i.id,
1151
- name: i.cnname || i.enname || i.name || i.id || "未命名船舶",
1152
- selected: i.id === T,
1153
- // 图标
1154
- rightIcons: gt(i),
1155
- // 船舶颜色
1156
- color: Z,
1157
- // 船艏向的方向
1158
- direct: W,
1159
- // 高亮
1160
- isHighlight: !1
1161
- });
1162
- return H.set("clickGeometry", new Jt(w)), H;
1163
- }, z = () => {
1164
- if (n && e && n) {
1165
- h.getFeatures().length > 0 && h.clear();
1166
- const i = ie([n == null ? void 0 : n.lon, n == null ? void 0 : n.lat]), T = new le({
1167
- geometry: new te(i),
1168
- id: n.id
1169
- });
1170
- T.setStyle(bo(e, n)), h.addFeature(T);
1171
- }
1172
- }, u = (i) => {
1173
- if (i === "start") {
1174
- const T = () => {
1175
- const w = h.getFeatures();
1176
- l.getFeatures().forEach((L) => {
1177
- var Z, W;
1178
- const F = Ee(e, L);
1179
- if (L.setStyle(F), L.get("id") === (n == null ? void 0 : n.id) && w && w[0]) {
1180
- const H = w[0], O = H == null ? void 0 : H.getStyle();
1181
- if (O && (O != null && O.getImage())) {
1182
- const re = (Z = F.getImage()) == null ? void 0 : Z.getScale();
1183
- re && ((W = O.getImage()) == null || W.setScale(re));
1184
- }
1185
- }
1186
- }), t = requestAnimationFrame(T);
1187
- };
1188
- T();
1189
- }
1190
- i === "end" && t && (cancelAnimationFrame(t), t = null);
1191
- }, m = () => {
1192
- e && l && (P(), l.clear(), d.clear(), h.clear(), u("end"));
1193
- }, P = (i) => {
1194
- const T = e.getOverlays().getArray().filter((w) => w.get("class") == "zh-map-ship-overlay");
1195
- if (T && T.length > 0) {
1196
- for (let w = 0; w < T.length; w++)
1197
- if (T[w].get("class") !== "ship-overlay-selected") {
1198
- const L = T[w];
1199
- console.log("overlay---", L), L.setPosition(void 0), e.removeOverlay(L), L.dispose();
1200
- }
1201
- }
1202
- }, b = (i, T) => {
1203
- g = i, k = T;
1204
- const w = e.getOverlays().getArray(), L = l.getFeatures();
1205
- for (const F in g) {
1206
- const Z = g[F], W = w.find((O) => (O == null ? void 0 : O.getId()) === "label-" + F), H = L.find((O) => F === O.get("id"));
1207
- if (W && H) {
1208
- const O = T[F].blinkColors || [], { shipData: re, name: ce, color: de } = H.getProperties();
1209
- H.set("blinking", Z), O[(O == null ? void 0 : O.length) - 1] && de !== O[(O == null ? void 0 : O.length) - 1] && (H.set("color", O[(O == null ? void 0 : O.length) - 1] || ""), H.setStyle(Ee(e, H)));
1210
- const Be = {
1211
- ...re,
1212
- blinking: Z,
1213
- blinkingColors: O || [],
1214
- name: ce + "(" + T[F].shipState + ")"
1215
- }, Me = W.getElement(), ge = kt(Be);
1216
- Me && Me !== ge && W.setElement(ge);
1217
- }
1218
- }
1219
- }, V = (i) => {
1220
- if (!e) return;
1221
- const T = l.getFeatures(), w = d.getFeatures(), L = r ? r.get("id") : "", F = T.filter((O) => O.get("id") !== L), Z = w == null ? void 0 : w.filter((O) => O.get("id") !== L), W = /* @__PURE__ */ new Map();
1222
- i.forEach((O) => {
1223
- W.set(O.id, !0);
1224
- });
1225
- const H = e.getOverlays().getArray();
1226
- F.forEach((O) => {
1227
- const re = O.get("id");
1228
- if (!W.has(re))
1229
- O.setStyle([]);
1230
- else {
1231
- const de = O.getStyle();
1232
- (de == null ? void 0 : de.length) == 0 && O.setStyle(Ee(e, O));
1233
- }
1234
- const ce = H.find((de) => de.getId() === "label-" + re);
1235
- ce && ce.setPosition(void 0);
1236
- }), Z.forEach((O) => {
1237
- const re = O.get("id");
1238
- if (!W.has(re))
1239
- O.setStyle([]);
1240
- else {
1241
- const ce = O.getStyle();
1242
- (ce == null ? void 0 : ce.length) == 0 && O.setStyle(ft(O, i.length));
1243
- }
1244
- });
1245
- }, X = (i) => {
1246
- if (i) {
1247
- console.log("选中", i);
1248
- const T = l.getFeatures().find((L) => L.get("id") === i.id), w = d.getFeatures().find((L) => L.get("id") === i.id);
1249
- T && (r = T), w && w.set("selected", !0), n = i, z();
1250
- } else
1251
- console.log("取消选中"), n = null, r = null, K();
1252
- }, G = Qt((i, T, w) => {
1253
- try {
1254
- if (i) {
1255
- const L = i.get("shipData"), F = i.get("id");
1256
- if (e.getTargetElement().style.cursor = F ? "pointer" : "", T === "click" && (X(L), w && w(F)), T === "hover") {
1257
- o && o !== F && q(), o = F;
1258
- const Z = l.getFeatures().find((W) => W.get("id") === o);
1259
- Z == null || Z.set("isHighlight", !0), Z == null || Z.setStyle(Ee(e, Z));
1260
- }
1261
- } else
1262
- e.getTargetElement().style.cursor = "", q();
1263
- } catch (L) {
1264
- console.log("handleShipMapEvent", L);
1265
- }
1266
- }, 10), q = () => {
1267
- const i = o ? l.getFeatures().find((T) => T.get("id") === o) : null;
1268
- o = null, i == null || i.set("isHighlight", !1), i == null || i.setStyle(Ee(e, i));
1269
- }, K = () => {
1270
- try {
1271
- h.clear();
1272
- } catch (i) {
1273
- console.log(i);
1274
- }
1275
- }, N = (i, T) => {
1276
- const w = ie([i == null ? void 0 : i.lon, i == null ? void 0 : i.lat]), L = new le({
1277
- geometry: new te(w),
1278
- name: i.cnname || i.enname || i.name || i.id || "未命名船舶",
1279
- // 图标
1280
- rightIcons: gt(i),
1281
- selected: (i == null ? void 0 : i.id) === (n == null ? void 0 : n.id),
1282
- shipData: i
1283
- });
1284
- L.set("id", i.id);
1285
- const F = ft(L, T);
1286
- return L.setStyle(F), L;
1287
- }, M = (i) => {
1288
- const T = e.getView().getZoom();
1289
- i.forEach((w) => {
1290
- const L = C(w);
1291
- if (L.setStyle(Ee(e, L)), l.addFeature(L), (n == null ? void 0 : n.id) == w.id || T && T >= U.shipModelMin)
1292
- if (g[w.id]) {
1293
- if (w.id && k[w == null ? void 0 : w.id]) {
1294
- const F = k[w == null ? void 0 : w.id] || {}, Z = (F == null ? void 0 : F.blinkColors) || [], W = (F == null ? void 0 : F.shipState) || "", H = (w.cnname || w.enname || w.name || w.id || "未命名船舶") + "(" + W + ")", O = {
1295
- ...w,
1296
- name: H,
1297
- blinking: g[w.id],
1298
- blinkingColors: Z || []
1299
- };
1300
- po(e, O);
1301
- }
1302
- } else {
1303
- const F = N(w, i.length);
1304
- d.addFeature(F);
1305
- }
1306
- });
1307
- };
1308
- return {
1309
- render: $,
1310
- selected: X,
1311
- filter: V,
1312
- blinking: b,
1313
- clear: m,
1314
- handleShipMapEvent: G,
1315
- changeShipScale: u
1316
- };
1317
- }, Eo = (e) => {
1318
- const r = () => e == null ? void 0 : e.getLayers(), n = ne("vector"), l = () => n.value, a = (x) => {
1319
- n.value = x;
1320
- const t = r();
1321
- t && (t == null || t.getArray().forEach((o) => {
1322
- (o.className_ === "vector" || o.className_ === "satellite") && o.setVisible(o.className_ === x);
1323
- }));
1324
- }, d = ne(!1);
1325
- return {
1326
- getLayers: r,
1327
- getGreenTileVisible: () => d.value,
1328
- setGreenTileVisible: (x) => {
1329
- if (x !== d.value) {
1330
- if (x) {
1331
- const t = r();
1332
- if (!t.getArray().find((g) => g.className_ === "greenTile")) {
1333
- const g = new Pe({
1334
- source: new Fe({ url: xe.greenTile }),
1335
- visible: x,
1336
- zIndex: 2,
1337
- className: "greenTile"
1338
- });
1339
- t.push(g);
1340
- }
1341
- } else {
1342
- const t = r(), o = t.getArray().find((g) => g.className_ === "greenTile");
1343
- o && t.remove(o);
1344
- }
1345
- d.value = x;
1346
- }
1347
- },
1348
- getShowLayerType: l,
1349
- setShowLayerType: a
1350
- };
1351
- }, Po = () => {
1352
- const e = ne();
1353
- return {
1354
- setProps: (l) => {
1355
- e.value = l;
1356
- },
1357
- getProps: () => e.value
1358
- };
1359
- }, Fo = (e) => {
1360
- const r = "zh-map-location-layer";
1361
- let n, l, a = null, d = null;
1362
- const s = (C) => {
1363
- if (!(!C || C.length === 0)) {
1364
- if (l || (l = new ue()), l.clear(), d) {
1365
- const z = C.find((u) => u.id === d.id);
1366
- z ? d = z : C.push(d);
1367
- }
1368
- C.forEach((z) => {
1369
- h(z);
1370
- }), n || (n = new he({
1371
- className: r,
1372
- source: l,
1373
- zIndex: 100
1374
- }), e == null || e.addLayer(n));
1375
- }
1376
- }, h = (C) => {
1377
- const z = e == null ? void 0 : e.getView().getZoom(), [u, m] = C.latLon.split(","), P = new le({
1378
- geometry: new te(ie([Number(u), Number(m)]))
1379
- });
1380
- P.setStyle(x(C, z, C.id === (d == null ? void 0 : d.id))), P.set("loactionData", C), l.addFeature(P);
1381
- }, x = (C, z, u) => {
1382
- const m = {
1383
- image: new Ce({
1384
- src: u && C.selectedPath || C.defaultPath,
1385
- scale: 0.5 * z / 10
1386
- })
1387
- };
1388
- return C.name && (m.text = new Se({
1389
- text: C.name,
1390
- font: "12px sans-serif",
1391
- fill: new oe({
1392
- color: "#000000"
1393
- }),
1394
- backgroundFill: new oe({
1395
- color: "#FFFFFF"
1396
- }),
1397
- offsetY: 30
1398
- })), new _(m);
1399
- }, t = () => {
1400
- if (a) {
1401
- const C = a.get("loactionData").id;
1402
- l.getFeatures().forEach((z) => {
1403
- z.get("loactionData").id !== C && l.removeFeature(z);
1404
- });
1405
- } else
1406
- l.clear();
1407
- }, o = () => {
1408
- var m;
1409
- const C = a.get("loactionData"), z = (m = e == null ? void 0 : e.getView()) == null ? void 0 : m.getZoom();
1410
- l.getFeatures().forEach((P) => {
1411
- P.get("loactionData").id === C.id && (P == null || P.setStyle(x(C, z, !1)));
1412
- }), d = null, a = null;
1413
- }, g = (C) => {
1414
- C ? (k(), $(C)) : clearSelectedPort();
1415
- }, k = () => {
1416
- var C;
1417
- if (a) {
1418
- const z = a.get("loactionData"), u = (C = e == null ? void 0 : e.getView()) == null ? void 0 : C.getZoom();
1419
- a.setStyle(x(z, u, !1));
1420
- }
1421
- }, $ = (C) => {
1422
- const z = l.getFeatures();
1423
- d = C, a = z.find((u) => u.get("loactionData").id === C.id);
1424
- };
1425
- return {
1426
- render: s,
1427
- selected: g,
1428
- clearSelected: o,
1429
- clear: t
1430
- };
1431
- }, So = (e) => {
1432
- e.getInteractions().forEach((r) => {
1433
- r instanceof yt && r.setActive(!1);
1434
- });
1435
- }, No = (e) => {
1436
- e.getInteractions().forEach((r) => {
1437
- r instanceof yt && r.setActive(!0);
1438
- });
1439
- }, ve = (e, r) => {
1440
- const n = e.getViewport();
1441
- n && (n.style.cursor = r);
1442
- }, Ro = (e, r) => {
1443
- const n = ne([]), l = ne("km"), a = (N) => {
1444
- l.value = N;
1445
- };
1446
- let d;
1447
- const s = ne(!1), h = () => {
1448
- ve(e, "crosshair"), o(), So(e), e.on("pointermove", $), e.getViewport().addEventListener("mouseout", () => {
1449
- d && d.classList.add("hidden");
1450
- }), z(), s.value = !0;
1451
- };
1452
- let x, t;
1453
- const o = () => {
1454
- x = new ue(), t = new he({
1455
- source: x,
1456
- zIndex: 1e3,
1457
- style: {
1458
- "fill-color": "rgba(255, 255, 255, 0.2)",
1459
- "stroke-color": "#ffcc33",
1460
- "stroke-width": 2,
1461
- "circle-radius": 7,
1462
- "circle-fill-color": "#ffcc33"
1463
- }
1464
- }), e == null || e.addLayer(t);
1465
- };
1466
- let g, k;
1467
- const $ = (N) => {
1468
- if (N.dragging)
1469
- return;
1470
- let M = "点击选择起点";
1471
- g && (M = "单击继续,双击结束"), d && (d.innerHTML = M, k.setPosition(N.coordinate), d.classList.remove("hidden"));
1472
- };
1473
- let C;
1474
- const z = () => {
1475
- C = new We({
1476
- source: x,
1477
- type: "LineString",
1478
- style: new _({
1479
- fill: new oe({
1480
- color: "rgba(255, 255, 255, 0.2)"
1481
- }),
1482
- stroke: new ke({
1483
- color: "rgba(255,204,51)",
1484
- lineDash: [10, 10],
1485
- width: 2
1486
- }),
1487
- image: new Ye({
1488
- radius: 5,
1489
- stroke: new ke({
1490
- color: "rgba(0, 0, 0, 0.7)"
1491
- }),
1492
- fill: new oe({
1493
- color: "rgba(255, 255, 255, 0.2)"
1494
- })
1495
- })
1496
- }),
1497
- // 添加条件函数,判断是否应该出发点绘制
1498
- condition: (M) => M.originalEvent.target.tagName !== "DIV"
1499
- }), e == null || e.addInteraction(C), b(), V();
1500
- let N;
1501
- C.on("drawstart", function(M) {
1502
- var T;
1503
- g = M.feature, g.set("randomId", u());
1504
- let i;
1505
- N = (T = g.getGeometry()) == null ? void 0 : T.on("change", function(w) {
1506
- const L = w.target, F = pt(L, l.value);
1507
- i = L.getLastCoordinate(), m && F && (m.innerHTML = F), P.setPosition(i);
1508
- });
1509
- }), C.on("drawend", function() {
1510
- var M, i, T;
1511
- if (m && (m.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), m != null && m.innerHTML) {
1512
- const w = (g == null ? void 0 : g.get("randomId")) || u();
1513
- n.value.push({ id: w, value: m == null ? void 0 : m.innerHTML }), m.innerHTML = `${m.innerHTML}<div class="ol-tooltip-delete-button" data-id="${w}"><i class="map-iconfont icon-delete"></i></div>`;
1514
- }
1515
- (M = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || M.addEventListener("click", (w) => {
1516
- var F;
1517
- w.preventDefault(), w.stopPropagation();
1518
- const L = (F = w.target) == null ? void 0 : F.getAttribute("data-id");
1519
- L && G(L);
1520
- }), P.setOffset([0, -7]), g = null, m = null, b(), N && Je(N), (T = (i = r.getProps()) == null ? void 0 : i.lineDrawEnd) == null || T.call(i, n.value);
1521
- });
1522
- }, u = () => Math.random().toString(36).substring(2, 9);
1523
- let m, P;
1524
- const b = () => {
1525
- m != null && m.parentNode && m.parentNode.removeChild(m), m = document.createElement("div"), m.className = "ol-tooltip ol-tooltip-measure", P = new pe({
1526
- element: m,
1527
- offset: [0, -15],
1528
- positioning: "bottom-center",
1529
- stopEvent: !1,
1530
- insertFirst: !1
1531
- }), e == null || e.addOverlay(P);
1532
- }, V = () => {
1533
- d != null && d.parentNode && d.parentNode.removeChild(d), d = document.createElement("div"), d.className = "ol-tooltip hidden", k = new pe({
1534
- element: d,
1535
- offset: [15, 0],
1536
- positioning: "center-left"
1537
- }), e == null || e.addOverlay(k);
1538
- }, X = () => {
1539
- n.value.forEach((N, M) => {
1540
- var w, L;
1541
- const i = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1542
- i[M] && ((L = (w = i[M]) == null ? void 0 : w.parentNode) == null || L.removeChild(i[M]));
1543
- const T = x.getFeatures();
1544
- T[M] && x.removeFeature(T[M]);
1545
- }), q(), No(e), s.value = !1, ve(e, "grab");
1546
- }, G = (N) => {
1547
- var i, T, w, L;
1548
- const M = n.value.findIndex((F) => F.id === N);
1549
- if (M !== -1) {
1550
- n.value.splice(M, 1);
1551
- const F = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1552
- F[M] && ((T = (i = F[M]) == null ? void 0 : i.parentNode) == null || T.removeChild(F[M]));
1553
- const Z = x.getFeatures();
1554
- Z[M] && x.removeFeature(Z[M]);
1555
- }
1556
- (L = (w = r.getProps()) == null ? void 0 : w.lineDrawEnd) == null || L.call(w, n.value);
1557
- }, q = () => {
1558
- if (n.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((N) => {
1559
- var M;
1560
- (M = N == null ? void 0 : N.parentNode) == null || M.removeChild(N);
1561
- }), x == null || x.clear(), C) {
1562
- const N = e.getInteractions().getArray().find((M) => at(M) === at(C));
1563
- N && e.removeInteraction(N);
1564
- }
1565
- e.removeLayer(t), d != null && d.parentNode && d.parentNode.removeChild(d), m != null && m.parentNode && m.parentNode.removeChild(m);
1566
- };
1567
- return {
1568
- open: h,
1569
- close: X,
1570
- deleteLine: G,
1571
- setUnit: a,
1572
- getState: () => s.value
1573
- };
1574
- }, pt = (e, r) => {
1575
- const l = tt(e);
1576
- let a = "";
1577
- switch (r) {
1578
- case "m":
1579
- a = `${Math.round(l * 100) / 100} m`;
1580
- break;
1581
- case "km":
1582
- a = `${Math.round(l / 1e3 * 100) / 100} km`;
1583
- break;
1584
- case "nm":
1585
- a = (Math.round(l / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
1586
- break;
1587
- }
1588
- return a;
1589
- }, $o = (e, r) => {
1590
- let n, l, a = "close";
1591
- const d = () => {
1592
- q(), a = "open", s(), ve(e, "crosshair");
1593
- }, s = () => {
1594
- t(), P(), X(), C();
1595
- };
1596
- let h = null, x = null;
1597
- const t = () => {
1598
- if (h && x) return;
1599
- const N = new ue(), M = new he({
1600
- source: N,
1601
- style: new _({
1602
- stroke: new ke({
1603
- color: "#fbcc33",
1604
- width: 2
1605
- })
1606
- }),
1607
- zIndex: 1e3
1608
- });
1609
- h = M, x = N, e.on("pointermove", g), e.addLayer(M), e.on(["dblclick"], function(i) {
1610
- k && (i.stopPropagation(), i.preventDefault());
1611
- });
1612
- };
1613
- let o;
1614
- const g = (N) => {
1615
- if (N.dragging) return;
1616
- const M = o ? "单击继续,双击结束" : "点击选择起点";
1617
- b && (b.innerHTML = M, V.setPosition(N.coordinate));
1618
- };
1619
- let k, $ = !1;
1620
- const C = () => {
1621
- if (n) {
1622
- b != null && b.parentNode && b.parentNode.removeChild(b);
1623
- const N = n.getGeometry();
1624
- if (!N) return;
1625
- const M = z(N, "nm");
1626
- u && (u.innerHTML = `
1627
- <span class="text">面积:${M}${$ ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1628
- `), u && (u.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
1629
- const i = N.getCoordinates(), T = i[0][i[0].length - 2];
1630
- if (m.setPosition(T), h) {
1631
- const L = h.getSource();
1632
- L && n && (L.clear(), L.addFeature(n));
1633
- }
1634
- setTimeout(() => {
1635
- var L;
1636
- (L = document.querySelector(".delete-icon")) == null || L.addEventListener("click", () => {
1637
- var F, Z;
1638
- console.log("delete"), G(), (Z = (F = r.getProps()) == null ? void 0 : F.areaDrawEnd) == null || Z.call(F, []);
1639
- });
1640
- }, 0);
1641
- const w = It(n.getGeometry().getExtent());
1642
- e == null || e.getView().setCenter(w);
1643
- return;
1644
- }
1645
- k = new We({
1646
- type: "Polygon",
1647
- source: x,
1648
- trace: !0,
1649
- style: [new _({
1650
- stroke: new ke({
1651
- color: "rgba(255, 255, 255, 1)",
1652
- width: 1.5,
1653
- lineDash: [10, 10]
1654
- }),
1655
- fill: new oe({
1656
- color: "rgba(255, 255, 255, 0.25)"
1657
- })
1658
- }), new _({
1659
- image: new Ye({
1660
- radius: 5,
1661
- fill: new oe({
1662
- color: "rgb(51,112,255, 1)"
1663
- })
1664
- }),
1665
- geometry: function(N) {
1666
- const M = N.getGeometry().getCoordinates();
1667
- return new eo(M);
1668
- }
1669
- })]
1670
- }), e == null || e.addInteraction(k), k.on("drawstart", (N) => {
1671
- var M;
1672
- o = N.feature, l = (M = o.getGeometry()) == null ? void 0 : M.on("change", (i) => {
1673
- const T = i.target, w = z(T, "nm"), F = T.getCoordinates()[0], Z = new Ge([F[F.length - 2], F[F.length - 1]]), W = pt(Z, "nm");
1674
- if ($ = Number(tt(Z) / 1e3) > 150, !w) return;
1675
- const H = '<span class="error pl-4">超出可以绘画的距离</span>';
1676
- u && (u.innerHTML = `
1677
- <div class="text">
1678
- 面积:${w}
1679
- ${$ ? H : ""}
1680
- </div>
1681
- `), b && (b.innerHTML = `
1682
- <div class="text">
1683
- 面积:${w}
1684
- </div>
1685
- <div class="text ${$ ? "error" : ""}">
1686
- 线段 ${F.length - 2}: ${W}
1687
- ${$ ? H : ""}
1688
-
1689
- </div>
1690
- <div>
1691
- <span class="text">单击继续,双击结束</span>
1692
- </div>
1693
- `);
1694
- });
1695
- }), k.on("drawend", (N) => {
1696
- var w, L, F, Z;
1697
- if (!N.feature.getGeometry()) return;
1698
- u && !n && (u.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), n = N.feature, m.setOffset([10, 0]);
1699
- const i = N.feature.getGeometry().getCoordinates(), T = i[0][i[0].length - 2];
1700
- if (m.setPosition(T), b != null && b.parentNode && b.parentNode.removeChild(b), (w = r.getProps()) != null && w.areaDrawEnd) {
1701
- const W = i[0].map((H) => Ve(H, I.mercator, I.data));
1702
- (F = (L = r.getProps()) == null ? void 0 : L.areaDrawEnd) == null || F.call(L, W);
1703
- }
1704
- k && (k.setActive(!1), e == null || e.removeInteraction(k), (e == null ? void 0 : e.getInteractions()).forEach((H) => {
1705
- H instanceof We && (H.setActive(!1), e == null || e.removeInteraction(H));
1706
- })), l && Je(l), (Z = document.querySelector(".delete-icon")) == null || Z.addEventListener("click", () => {
1707
- var W, H;
1708
- G(), (H = (W = r.getProps()) == null ? void 0 : W.areaDrawEnd) == null || H.call(W, []);
1709
- });
1710
- });
1711
- }, z = (N, M) => {
1712
- const i = Ut(N);
1713
- switch (M) {
1714
- case "km":
1715
- return i > 1e4 ? Math.round(i / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(i * 100) / 100 + " m<sup>2</sup>";
1716
- case "nm":
1717
- return i > 1e4 ? Math.round(i / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(i * 100) / 100 + " m<sup>2</sup>";
1718
- }
1719
- };
1720
- let u, m;
1721
- const P = () => {
1722
- u != null && u.parentNode && u.parentNode.removeChild(u), u = document.createElement("div"), u.style.display = "flex", u.className = "ol-tooltip ol-tooltip-draw-polygon", m = new pe({
1723
- element: u,
1724
- offset: [0, -15],
1725
- positioning: "bottom-center",
1726
- stopEvent: !1,
1727
- insertFirst: !1
1728
- }), e == null || e.addOverlay(m);
1729
- };
1730
- let b, V;
1731
- const X = () => {
1732
- b != null && b.parentNode && b.parentNode.removeChild(b), b = document.createElement("div"), b.className = "ol-tooltip ol-help-tooltip", V = new pe({
1733
- element: b,
1734
- offset: [15, 0],
1735
- positioning: "center-left"
1736
- }), e == null || e.addOverlay(V);
1737
- }, G = () => {
1738
- n = null, d();
1739
- }, q = () => {
1740
- a = "close", e.un("pointermove", g), o = null, k && (k.abortDrawing(), console.log("abortDrawing"), k.setActive(!1), (e == null ? void 0 : e.getInteractions()).forEach((M) => {
1741
- M instanceof We && (M.setActive(!1), e == null || e.removeInteraction(M));
1742
- }), k = null), l && Je(l), l = void 0, x == null || x.clear(), x = null, h && e.getAllLayers().includes(h) && (e.removeLayer(h), h = null), b != null && b.parentElement && (b.innerHTML = "", b.parentElement.removeChild(b), b = null), u != null && u.parentElement && (u.innerHTML = "", u.parentElement.removeChild(u), u = null), V && e.removeOverlay(V), m && e.removeOverlay(m), ve(e, "grab");
1743
- };
1744
- return {
1745
- open: d,
1746
- close: q,
1747
- reset: G,
1748
- getState: () => a
1749
- };
1750
- }, Vo = "zh-map-port-layer", zo = (e) => {
1751
- const r = new ue(), n = new he({
1752
- className: Vo,
1753
- source: r,
1754
- zIndex: 100,
1755
- updateWhileInteracting: !0,
1756
- updateWhileAnimating: !0,
1757
- properties: { layerType: ee.PORT }
1758
- });
1759
- e == null || e.addLayer(n);
1760
- let l = null, a = null;
1761
- const d = (u, m = !0) => {
1762
- if (!u || u.length === 0) return;
1763
- if (r.clear(), a) {
1764
- const b = u.find((V) => V.id === (a == null ? void 0 : a.id));
1765
- b ? a = b : u.push(a);
1766
- }
1767
- const P = [];
1768
- u.forEach((b) => {
1769
- const [V, X] = b.latLon.split(","), G = new le({
1770
- geometry: new te(ie([Number(V), Number(X)])),
1771
- portData: b,
1772
- id: b.id,
1773
- select: b.id === (a == null ? void 0 : a.id),
1774
- showTitle: b.id === (a == null ? void 0 : a.id) || m
1775
- }), q = o(G);
1776
- G.setStyle(q), P.push(G);
1777
- }), r.addFeatures(P);
1778
- };
1779
- let s = null, h = null;
1780
- const x = /* @__PURE__ */ new Map(), t = (u, m) => {
1781
- s || (s = document.createElement("canvas"), h = s.getContext("2d", {
1782
- willReadFrequently: !0
1783
- }));
1784
- const P = `${u}-${m}`;
1785
- if (x.has(P))
1786
- return x.get(P);
1787
- const b = s, V = h;
1788
- if (!V) return "";
1789
- b.width = 0, b.height = 0;
1790
- const X = 2, G = 8, q = window.devicePixelRatio || 1, K = "12px sans-serif";
1791
- V.font = K;
1792
- const M = V.measureText(u).width, i = G + M + G, T = X + 12 + X * 2;
1793
- b.width = Math.round(i * q), b.height = Math.round(T * q), V.scale(q, q), V.clearRect(0, 0, i, T), V.fillStyle = m ? "#F32D2D" : "#FFF", V.beginPath(), V.roundRect(0, 0, i, T, 4), V.fill(), V.font = K, V.textBaseline = "middle";
1794
- const w = T / 2;
1795
- V.strokeStyle = m ? "#000" : "#ffffff", V.lineWidth = 1, V.strokeText(u, G, w), V.fillStyle = m ? "#FFF" : "#000000", V.fillText(u, G, w);
1796
- const L = b.toDataURL("image/png");
1797
- return x.set(P, L), L;
1798
- }, o = (u) => {
1799
- const { select: m, showTitle: P } = u.getProperties(), b = (M) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
1800
- <path fill-rule="evenodd" clip-rule="evenodd" d="M22.6563 44.9304C22.5453 44.8844 22.4445 44.817 22.3595 44.7321C22.3595 44.7321 9.36986 31.7424 9.32952 31.6913C7.09059 29.0791 5.64794 25.8802 5.17255 22.4736C4.69716 19.0671 5.20896 15.5957 6.64728 12.471C8.08561 9.34625 10.3902 6.69909 13.2878 4.84325C16.1855 2.98741 19.5548 2.00068 22.9965 2C26.4381 1.99932 29.8078 2.98473 32.7062 4.83943C35.6046 6.69414 37.9102 9.34039 39.3498 12.4646C40.7893 15.5888 41.3025 19.0599 40.8284 22.4666C40.3544 25.8734 38.913 29.0729 36.6751 31.686C36.6401 31.737 23.6531 44.7321 23.6531 44.7321C23.5682 44.817 23.4674 44.8844 23.3564 44.9304C23.2454 44.9763 23.1265 45 23.0063 45C22.8862 45 22.7673 44.9763 22.6563 44.9304Z" fill="${M}"/>
1801
- <g clip-path="url(#clip0_10059_122082)">
1802
- <path d="M34.8624 22.8687L32.5874 25.6313L33.4812 25.7125C33.4812 25.7125 30.5562 28.0687 27.9562 28.2312C25.3562 28.3937 24.1374 24.9 24.1374 24.9V19.1312H27.6312V17.425H24.2999V15.15C25.7624 14.6625 26.7374 13.2812 26.7374 11.6562C26.7374 9.625 25.1124 8 23.0812 8H22.9999C20.9687 8 19.3437 9.625 19.3437 11.6562C19.3437 13.2812 20.3999 14.6625 21.7812 15.15V17.425H18.4499V19.1312H21.9437V24.9C21.9437 24.9 20.6437 28.3125 18.0437 28.2312C15.4437 28.0687 12.5187 25.7125 12.5187 25.7125L13.4124 25.6313L11.0562 22.8687L10.2437 26.2812L11.2187 26.0375C11.2187 26.0375 13.1687 29.5313 16.1749 30.8313C19.1812 32.2125 22.1874 33.9187 22.8374 34C23.4874 33.9187 26.4937 32.2125 29.4187 30.8313C32.3437 29.45 34.3749 26.0375 34.3749 26.0375L35.3499 26.2812L34.8624 22.8687ZM23.0812 13.6875C21.9437 13.6875 21.0499 12.7937 21.0499 11.6562C21.0499 10.6 21.9437 9.70625 22.9999 9.70625H23.0812C24.1374 9.70625 25.0312 10.6 25.0312 11.6562C25.1124 12.7937 24.1374 13.6875 23.0812 13.6875Z" fill="white"/>
1803
- </g>
1804
- <defs>
1805
- <clipPath id="clip0_10059_122082">
1806
- <rect width="26" height="26" fill="white" transform="translate(10 8)"/>
1807
- </clipPath>
1808
- </defs>
1809
- </svg>
1810
- `, V = () => `data:image/svg+xml;utf8,${encodeURIComponent(b(m ? "#F32D2D" : "#3370FF"))}`, X = e.getView().getZoom(), G = u.get("portData"), q = window.devicePixelRatio || 1, K = new _({
1811
- image: new Ce({
1812
- src: V(),
1813
- scale: 0.5 * X / 10
1814
- }),
1815
- zIndex: m ? 110 : 100
1816
- }), N = new _({
1817
- image: new Ce({
1818
- src: t(G.shortName, m),
1819
- anchor: [0.5, 0.5],
1820
- displacement: [0, -30],
1821
- scale: 1 / q,
1822
- anchorXUnits: "fraction",
1823
- anchorYUnits: "fraction"
1824
- }),
1825
- zIndex: m ? 110 : 100
1826
- // text: new Text({
1827
- // text: port.shortName,
1828
- // font: '12px sans-serif',
1829
- // fill: new Fill({
1830
- // color: select ? "#ffffff" : "#000000"
1831
- // }),
1832
- // backgroundFill: new Fill({
1833
- // color: "#FFF",
1834
- // }),
1835
- // offsetY: 30,
1836
- // }),
1837
- });
1838
- return !P && !m ? K : [K, N];
1839
- }, g = () => {
1840
- if (r)
1841
- if (l) {
1842
- console.log("清除非选中的港口");
1843
- const u = l.get("portData").id;
1844
- r.getFeatures().forEach((m) => {
1845
- m.get("portData").id !== u && r.removeFeature(m);
1846
- });
1847
- } else
1848
- console.log("清除所有港口", r), r == null || r.clear();
1849
- }, k = (u) => {
1850
- if (r) {
1851
- if (!u)
1852
- return $();
1853
- (l == null ? void 0 : l.get("portData").id) !== u.id && ($(), C(u));
1854
- }
1855
- }, $ = () => {
1856
- var u;
1857
- if (l) {
1858
- const m = l == null ? void 0 : l.get("portData"), P = (u = r.getFeatures()) == null ? void 0 : u.find((b) => b.get("portData").id === m.id);
1859
- P && (P.set("select", !1), P.setStyle(o(P)), l = null, a = null);
1860
- }
1861
- }, C = (u) => {
1862
- if (!r) return;
1863
- const m = r.getFeatures();
1864
- a = u, l = m.find((P) => P.get("portData").id === u.id), l && (l.set("select", !0), l.setStyle(o(l)));
1865
- };
1866
- return {
1867
- render: d,
1868
- clear: g,
1869
- selected: k,
1870
- handlePortHover: (u) => {
1871
- u && u.get("portData") ? ve(e, "pointer") : ve(e, "grab");
1872
- }
1873
- };
1874
- }, Oo = (e, r, n, l, a, d, s) => {
1875
- const h = e.getInstall();
1876
- h.on("moveend", () => {
1877
- var g, k;
1878
- try {
1879
- const $ = e.getZoom();
1880
- (k = (g = r.getProps()).mapMoveEnd) == null || k.call(g, $), $ >= U.min && $ <= U.max && n.reRenderTrackLine(), $ >= U.shipTriggleMin && $ <= U.max && l.changeShipScale("end");
1881
- } catch ($) {
1882
- console.log("moveend---catch", $);
1883
- }
1884
- });
1885
- const x = {
1886
- [ee.PORT]: null,
1887
- [ee.SHIP]: null,
1888
- [ee.TRACK]: null
1889
- }, t = (g, k, $) => {
1890
- switch (ve(h, "pointer"), g) {
1891
- case ee.SHIP:
1892
- l == null || l.handleShipMapEvent(k, "hover");
1893
- break;
1894
- case ee.PORT:
1895
- break;
1896
- case ee.TRACK:
1897
- n == null || n.handleTrackMapEvent(k, "hover", $);
1898
- break;
1899
- }
1900
- }, o = (g) => {
1901
- switch (ve(h, "grab"), g) {
1902
- case ee.PORT:
1903
- break;
1904
- case ee.SHIP:
1905
- l == null || l.handleShipMapEvent(null, "hover");
1906
- break;
1907
- case ee.TRACK:
1908
- n == null || n.handleTrackMapEvent(null, "hover");
1909
- break;
1910
- }
1911
- };
1912
- h.on("pointermove", (g) => {
1913
- if (!h.getView().getAnimating())
1914
- try {
1915
- let k = !1;
1916
- const $ = h.getLayers().getArray().filter((C) => C.get("layerType"));
1917
- $ && $.length > 0 && $.forEach((C) => {
1918
- if (k) return;
1919
- const z = h == null ? void 0 : h.getEventPixel(g.originalEvent), u = C == null ? void 0 : C.get("layerType"), m = h == null ? void 0 : h.forEachFeatureAtPixel(z, (P) => P, {
1920
- layerFilter: (P) => P === C,
1921
- // 严格图层过滤
1922
- hitTolerance: 5
1923
- });
1924
- m !== x[u] && (x[u] && o(u, x[u]), x[u] = m, m && (t(u, m, g), k = !0));
1925
- });
1926
- } catch (k) {
1927
- console.log("pointermove----", k);
1928
- }
1929
- }), h.on("movestart", () => {
1930
- try {
1931
- const g = h == null ? void 0 : h.getView().getZoom();
1932
- g && g <= U.shipModelMax && g >= U.shipTriggleMin && l.changeShipScale("start");
1933
- } catch (g) {
1934
- console.log("movestart---catch", g);
1935
- }
1936
- }), h.on("click", vt((g) => {
1937
- if (s.getState() !== "open" && !h.getView().getAnimating())
1938
- try {
1939
- let k = !1;
1940
- const $ = h.getLayers().getArray().filter((C) => C.get("layerType"));
1941
- $ && $.length > 0 && $.forEach((C) => {
1942
- var m, P, b;
1943
- if (k) return;
1944
- const z = h == null ? void 0 : h.getEventPixel(g.originalEvent), u = h == null ? void 0 : h.forEachFeatureAtPixel(z, (V) => {
1945
- if (V.get("shipData") || V.get("portData"))
1946
- return V;
1947
- }, {
1948
- layerFilter: (V) => V === C,
1949
- // 严格图层过滤
1950
- hitTolerance: 10
1951
- });
1952
- if (u) {
1953
- if (u != null && u.get("shipData"))
1954
- console.log("trackManager.getTrackStatus()---", n.getTrackStatus()), n.getTrackStatus() || l.handleShipMapEvent(u, "click", (m = r.getProps()) == null ? void 0 : m.selectShip);
1955
- else if (u != null && u.get("portData")) {
1956
- const V = u == null ? void 0 : u.get("portData");
1957
- a.selected(V), (b = (P = r.getProps()) == null ? void 0 : P.selectPort) == null || b.call(P, V);
1958
- }
1959
- k = !0, g.preventDefault(), g.stopPropagation();
1960
- }
1961
- });
1962
- } catch (k) {
1963
- console.log("pointermove----", k);
1964
- }
1965
- }, 150));
1966
- }, Do = () => {
1967
- const e = At([]);
1968
- return {
1969
- createInstance: (l, a) => {
1970
- const d = ao();
1971
- d.initMap(l, a);
1972
- const s = d.getInstall(), h = Eo(s), x = Po();
1973
- x.setProps(a), h.setShowLayerType(a.layerType), h.setGreenTileVisible(a.showGreenLayer);
1974
- const t = yo(s), o = vo(s, t), g = To(s), k = Fo(s), $ = Ro(s, x), C = $o(s, x), z = zo(s);
1975
- Oo(d, x, t, g, z, $, C);
1976
- const u = () => {
1977
- const P = s.getView().calculateExtent(d.getSize()), b = Ve([P[0], P[1]], I.mercator, I.data), V = Ve([P[2], P[3]], I.mercator, I.data);
1978
- return [b[0], b[1], V[0], V[1]];
1979
- }, m = {
1980
- id: Symbol("map-instance"),
1981
- innerMap: null,
1982
- map: d.getInstall(),
1983
- destroy: () => {
1984
- e.splice(e.indexOf(m), 1);
1985
- },
1986
- methods: {
1987
- ...d,
1988
- layer: h,
1989
- ship: g,
1990
- track: t,
1991
- carTrack: o,
1992
- port: {
1993
- render: z.render,
1994
- clear: z.clear,
1995
- selected: z.selected
1996
- },
1997
- position: k,
1998
- drawLine: $,
1999
- drawPolygon: C,
2000
- // 子模块
2001
- utils: {
2002
- getCalculateExtent: u,
2003
- convertSixHundredThousandToLatLng: nt,
2004
- calculateCirclePoints: uo
2005
- }
2006
- }
2007
- };
2008
- return e.push(m), m;
2009
- },
2010
- destroyInstance: (l) => {
2011
- const a = e.findIndex((d) => d.id === l);
2012
- a > -1 && (e[a].destroy(), e.splice(a, 1));
2013
- },
2014
- destroyAll: () => {
2015
- e.forEach((l) => l.destroy()), e.splice(0, e.length);
2016
- },
2017
- getAllInstances: () => [...e]
2018
- };
2019
- }, Zo = { class: "zh-map-box" }, Ao = /* @__PURE__ */ Ue({
2020
- __name: "Map",
2021
- props: {
2022
- zoom: { default: U.default },
2023
- center: { default: co },
2024
- layerType: { default: "vector" },
2025
- showGreenLayer: { type: Boolean, default: !1 },
2026
- showScale: { type: Boolean, default: !0 },
2027
- scaleLineUnit: { default: "metric" },
2028
- mapMoveEnd: { type: Function, default: () => {
2029
- } },
2030
- lineDrawEnd: {},
2031
- areaDrawEnd: { type: Function, default: () => {
2032
- } },
2033
- selectShip: { type: Function, default: () => {
2034
- } },
2035
- selectPort: { type: Function, default: () => {
2036
- } }
2037
- },
2038
- setup(e, { expose: r }) {
2039
- function n() {
2040
- return new Promise((t) => {
2041
- document.fonts ? document.fonts.load("12px map-iconfont").then(t) : setTimeout(t, 300);
2042
- });
2043
- }
2044
- n();
2045
- const l = ne(), a = ne(), d = Do(), s = ne(), h = e, x = ne({
2046
- getInstall() {
2047
- }
2048
- });
2049
- return Gt(() => {
2050
- var t;
2051
- s.value = d.createInstance(l.value, h), x.value = s.value.methods, (t = a.value) == null || t.setScaleLine(s.value.map, h.scaleLineUnit);
2052
- }), Wt(() => {
2053
- var t, o;
2054
- d.destroyInstance((t = s == null ? void 0 : s.value) == null ? void 0 : t.id), (o = s.value) == null || o.destroy();
2055
- }), r({
2056
- getZoom: () => {
2057
- var t;
2058
- return (t = s.value) == null ? void 0 : t.methods.getZoom();
2059
- },
2060
- setZoom: (t) => {
2061
- var o;
2062
- return (o = s.value) == null ? void 0 : o.methods.setZoom(t);
2063
- },
2064
- getInstall: () => {
2065
- var t;
2066
- return (t = s.value) == null ? void 0 : t.methods.getInstall();
2067
- },
2068
- getView: () => {
2069
- var t;
2070
- return (t = s.value) == null ? void 0 : t.methods.getView();
2071
- },
2072
- setCenter: (t, o) => {
2073
- var g;
2074
- return (g = s.value) == null ? void 0 : g.methods.setCenter(t, o);
2075
- },
2076
- getSize: () => {
2077
- var t;
2078
- return (t = s.value) == null ? void 0 : t.methods.getSize();
2079
- },
2080
- getCenter: (t, o) => {
2081
- var g;
2082
- return (g = s.value) == null ? void 0 : g.methods.getCenter();
2083
- },
2084
- layer: {
2085
- setGreenTileVisible: (t) => {
2086
- var o;
2087
- return (o = s.value) == null ? void 0 : o.methods.layer.setGreenTileVisible(t);
2088
- },
2089
- getGreenTileVisible: () => {
2090
- var t;
2091
- return (t = s.value) == null ? void 0 : t.methods.layer.getGreenTileVisible();
2092
- },
2093
- getShowLayerType: () => {
2094
- var t;
2095
- return (t = s.value) == null ? void 0 : t.methods.layer.getShowLayerType();
2096
- },
2097
- setShowLayerType: (t) => {
2098
- var o;
2099
- return (o = s.value) == null ? void 0 : o.methods.layer.setShowLayerType(t);
2100
- }
2101
- },
2102
- ship: {
2103
- render: (...t) => {
2104
- var o;
2105
- return (o = s.value) == null ? void 0 : o.methods.ship.render(...t);
2106
- },
2107
- selected: (...t) => {
2108
- var o;
2109
- return (o = s.value) == null ? void 0 : o.methods.ship.selected(...t);
2110
- },
2111
- filter: (...t) => {
2112
- var o;
2113
- return (o = s.value) == null ? void 0 : o.methods.ship.filter(...t);
2114
- },
2115
- blinking: (...t) => {
2116
- var o;
2117
- return (o = s.value) == null ? void 0 : o.methods.ship.blinking(...t);
2118
- },
2119
- clear: () => {
2120
- var t;
2121
- return (t = s.value) == null ? void 0 : t.methods.ship.clear();
2122
- }
2123
- },
2124
- track: {
2125
- render: (...t) => {
2126
- var o;
2127
- return (o = s.value) == null ? void 0 : o.methods.track.render(...t);
2128
- },
2129
- remove: (...t) => {
2130
- var o;
2131
- return (o = s.value) == null ? void 0 : o.methods.track.remove(...t);
2132
- },
2133
- play: (...t) => {
2134
- var o;
2135
- return (o = s.value) == null ? void 0 : o.methods.track.play(...t);
2136
- },
2137
- setCenter: (...t) => {
2138
- var o;
2139
- return (o = s.value) == null ? void 0 : o.methods.track.setCenter(...t);
2140
- },
2141
- close: (...t) => {
2142
- var o;
2143
- return (o = s.value) == null ? void 0 : o.methods.track.close(...t);
2144
- },
2145
- getLength: (...t) => {
2146
- var o;
2147
- return (o = s.value) == null ? void 0 : o.methods.track.getLength(...t);
2148
- }
2149
- },
2150
- carTrack: {
2151
- location: (...t) => {
2152
- var o;
2153
- return (o = s.value) == null ? void 0 : o.methods.carTrack.location(...t);
2154
- },
2155
- remove: (...t) => {
2156
- var o;
2157
- return (o = s.value) == null ? void 0 : o.methods.carTrack.remove(...t);
2158
- },
2159
- renderTrack: (...t) => {
2160
- var o;
2161
- return (o = s.value) == null ? void 0 : o.methods.carTrack.renderTrack(...t);
2162
- },
2163
- setCenter: (...t) => {
2164
- var o;
2165
- return (o = s.value) == null ? void 0 : o.methods.carTrack.setCenter(...t);
2166
- },
2167
- closeTrack: () => {
2168
- var t;
2169
- return (t = s.value) == null ? void 0 : t.methods.carTrack.closeTrack();
2170
- },
2171
- playTrack: (...t) => {
2172
- var o;
2173
- return (o = s.value) == null ? void 0 : o.methods.carTrack.playTrack(...t);
2174
- }
2175
- },
2176
- port: {
2177
- render: (t, o) => {
2178
- var g;
2179
- return (g = s.value) == null ? void 0 : g.methods.port.render(t, o);
2180
- },
2181
- clear: () => {
2182
- var t;
2183
- return (t = s.value) == null ? void 0 : t.methods.port.clear();
2184
- },
2185
- selected: (t) => {
2186
- var o;
2187
- return (o = s.value) == null ? void 0 : o.methods.port.selected(t);
2188
- }
2189
- },
2190
- position: {
2191
- render: (...t) => {
2192
- var o;
2193
- return (o = s.value) == null ? void 0 : o.methods.position.render(...t);
2194
- },
2195
- selected: (...t) => {
2196
- var o;
2197
- return (o = s.value) == null ? void 0 : o.methods.position.selected(...t);
2198
- },
2199
- clearSelected: (...t) => {
2200
- var o;
2201
- return (o = s.value) == null ? void 0 : o.methods.position.clearSelected(...t);
2202
- },
2203
- clear: () => {
2204
- var t;
2205
- return (t = s.value) == null ? void 0 : t.methods.position.clear();
2206
- }
2207
- },
2208
- drawLine: {
2209
- open: () => {
2210
- var t;
2211
- return (t = s.value) == null ? void 0 : t.methods.drawLine.open();
2212
- },
2213
- close: () => {
2214
- var t;
2215
- return (t = s.value) == null ? void 0 : t.methods.drawLine.close();
2216
- },
2217
- deleteLine: (t) => {
2218
- var o;
2219
- return (o = s.value) == null ? void 0 : o.methods.drawLine.deleteLine(t);
2220
- },
2221
- setUnit: (t) => {
2222
- var o;
2223
- return (o = s.value) == null ? void 0 : o.methods.drawLine.setUnit(t);
2224
- },
2225
- getState: () => {
2226
- var t;
2227
- return (t = s.value) == null ? void 0 : t.methods.drawLine.getState();
2228
- }
2229
- },
2230
- drawPolygon: {
2231
- open: () => {
2232
- var t;
2233
- return (t = s.value) == null ? void 0 : t.methods.drawPolygon.open();
2234
- },
2235
- close: () => {
2236
- var t;
2237
- return (t = s.value) == null ? void 0 : t.methods.drawPolygon.close();
2238
- },
2239
- reset: () => {
2240
- var t;
2241
- return (t = s.value) == null ? void 0 : t.methods.drawPolygon.reset();
2242
- }
2243
- },
2244
- // 子模块
2245
- utils: {
2246
- getCalculateExtent: (...t) => {
2247
- var o;
2248
- return (o = s.value) == null ? void 0 : o.methods.utils.getCalculateExtent(...t);
2249
- },
2250
- convertSixHundredThousandToLatLng: (...t) => {
2251
- var o;
2252
- return (o = s.value) == null ? void 0 : o.methods.utils.convertSixHundredThousandToLatLng(...t);
2253
- },
2254
- calculateCirclePoints: (t, o) => {
2255
- var g;
2256
- return (g = s.value) == null ? void 0 : g.methods.utils.calculateCirclePoints(t, o);
2257
- }
2258
- }
2259
- }), (t, o) => (Ie(), et("div", Zo, [
2260
- _e("div", {
2261
- id: "map",
2262
- ref_key: "zhMapRef",
2263
- ref: l,
2264
- class: "zh-map"
2265
- }, null, 512),
2266
- Qe(ro, {
2267
- ref_key: "scaleLineRef",
2268
- ref: a
2269
- }, null, 512),
2270
- Qe(io, {
2271
- ref: "zoomControlRef",
2272
- "map-instance": s.value
2273
- }, null, 8, ["map-instance"])
2274
- ]));
2275
- }
2276
- }), Go = /* @__PURE__ */ ot(Ao, [["__scopeId", "data-v-6ca8f281"]]), Xo = to(Go);
2277
- export {
2278
- Xo as Z
2279
- };