zhihao-ui 1.3.54 → 1.3.56

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