zhihao-ui 1.3.58-alpha.2 → 1.3.58-alpha.4

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