zhihao-ui 1.3.58-alpha.7 → 1.3.58-alpha.8

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