zhihao-ui 1.3.5 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/es/{BaseInfo-C-n-23wy.js → BaseInfo-DFEg4oWo.js} +1 -1
  2. package/dist/es/{BaseItem-BmbN3hxP.js → BaseItem-BvdMV2Gu.js} +3 -3
  3. package/dist/es/{Button-DnAj6C7o.js → Button-NgQ5sHIG.js} +2 -2
  4. package/dist/es/{DatePicker-CLuXvVZx.js → DatePicker-B2pu6NJQ.js} +3 -3
  5. package/dist/es/{DetailHeader-CJ49WOPF.js → DetailHeader-DDDbFDig.js} +3 -3
  6. package/dist/es/{DetailSubTitle-BTe5k4Tv.js → DetailSubTitle-IqUKEU6D.js} +2 -2
  7. package/dist/es/{Dialog-Bv42gNoY.js → Dialog-DzTqitsD.js} +3 -3
  8. package/dist/es/{DiyDataTable-DDIkdXF3.js → DiyDataTable-DlgBshaZ.js} +4 -4
  9. package/dist/es/{EditInfoPair-B_1jHWIS.js → EditInfoPair-DQQoCmp8.js} +3 -3
  10. package/dist/es/{FileWrapper-Cyfnbvfq.js → FileWrapper-pzSCoy4C.js} +4 -4
  11. package/dist/es/{Grid-BziKC4j6.js → Grid-D3sfvKjP.js} +2 -2
  12. package/dist/es/{InfoPair-ggIW5r8A.js → InfoPair-O3-tZH-B.js} +3 -3
  13. package/dist/es/{Input-BEYAS5WB.js → Input-m8a-UuQp.js} +3 -3
  14. package/dist/es/{Loading-Dw6qV2j-.js → Loading-5WuhZO5j.js} +2 -2
  15. package/dist/es/{Map-CVB8icRh.js → Map-dW7d39YT.js} +504 -421
  16. package/dist/es/{MessageBox-BqcS3SpW.js → MessageBox-3q9YfNRL.js} +2 -2
  17. package/dist/es/{MoneyInput-BEZxWEKT.js → MoneyInput-DddMW7cV.js} +5 -5
  18. package/dist/es/{PageHeadPanel-DVd4kJnd.js → PageHeadPanel-BLvPIfGZ.js} +2 -2
  19. package/dist/es/{Table-CyPkm0mk.js → Table-iJRuASc3.js} +5 -5
  20. package/dist/es/{ToolTips-ev7cPDVQ.js → ToolTips-Cv8eNWyC.js} +3 -3
  21. package/dist/es/index.js +22 -22
  22. package/dist/es/{utils-B9UlcPnQ.js → utils-DSw1USoH.js} +1 -1
  23. package/dist/es/{vendor-C-yFzCvN.js → vendor-Cc_TVxUO.js} +10 -10
  24. package/dist/index.css +1 -1
  25. package/dist/types/components/Map/Map.vue.d.ts +2 -2
  26. package/dist/types/components/Map/function/shipTrack.d.ts +23 -4
  27. package/dist/types/components/Map/index.d.ts +6 -6
  28. package/dist/types/components/Map/utils/track.d.ts +2 -0
  29. package/dist/umd/index.css +1 -1
  30. package/dist/umd/index.umd.cjs +37 -37
  31. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { ref, computed, watch, onMounted, onBeforeUnmount, h, nextTick, createVNode, render, defineComponent, openBlock, createElementBlock, inject, createElementVNode, Fragment } from "vue";
2
- import { T as Text, F as Fill, S as Style, p as fromLonLat, t as transformExtent, q as getLength, R as RBush$1, O as Overlay, I as Icon, V as VectorSource, r as VectorLayer, s as debounce, i as cloneDeep, u as Feature, P as Point, h as hooks, L as LineString, v as Stroke, C as CircleStyle, w as Polyline, x as buffer, y as transform, z as getVectorContext, D as DoubleClickZoom, A as Draw, B as unByKey, G as getUid, M as Map$2, H as TileLayer, X as XYZ, J as View, K as defaults, N as toLonLat, Q as ScaleLine$1, U as getArea, W as getCenter$1, Y as MultiPoint } from "./vendor-C-yFzCvN.js";
3
- import { _ as _export_sfc } from "./Button-DnAj6C7o.js";
4
- import { w as withInstall } from "./utils-B9UlcPnQ.js";
2
+ import { h as hooks, p as fromLonLat, t as transformExtent, T as Text, F as Fill, S as Style, q as getLength, O as Overlay, P as Polyline, L as LineString, r as Feature, s as Point, V as VectorLayer, u as VectorSource, i as cloneDeep, v as buffer, w as Stroke, C as CircleStyle, x as transform, y as getVectorContext, z as debounce, R as RBush$1, I as Icon, D as DoubleClickZoom, A as Draw, B as unByKey, G as getUid, M as Map$2, H as TileLayer, X as XYZ, J as View, K as defaults, N as toLonLat, Q as ScaleLine$1, U as getArea, W as getCenter$1, Y as MultiPoint } from "./vendor-Cc_TVxUO.js";
3
+ import { _ as _export_sfc } from "./Button-NgQ5sHIG.js";
4
+ import { w as withInstall } from "./utils-DSw1USoH.js";
5
5
  const TIAN_DI_TU_KEY = "a6e8f78974f2581f2ca00485b40c948f", MAP_ZOOM = {
6
6
  // 地图默认层级
7
7
  default: 13,
@@ -10,6 +10,8 @@ const TIAN_DI_TU_KEY = "a6e8f78974f2581f2ca00485b40c948f", MAP_ZOOM = {
10
10
  // 地图缩放最大层级
11
11
  max: 18,
12
12
  // 船形图标最小渲染层级
13
+ shipModelMin: 13,
14
+ // 船形图标最小渲染层级
13
15
  shipTriggleMin: 16,
14
16
  // 船形图标最大渲染层级
15
17
  shipModelMax: 18,
@@ -77,7 +79,483 @@ const getIconStyle = (e) => {
77
79
  const n = { lon: 0, lat: 0 }, o = e[0] / equatorialCircumference * 180;
78
80
  let r = e[1] / equatorialCircumference * 180;
79
81
  return r = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2), n.lon = o, n.lat = r, t === "lonlat" ? n : [o, r];
80
- }, adjustBounds = (e, t) => t.length === 2 ? [e[0] - t[0], e[1] - t[1], e[2] + t[0], e[3] + t[1]] : [e[0] + t[0], e[1] + t[1], e[2] + t[2], e[3] + t[3]], isOverlapping$1 = (e, t) => e[0] <= t[2] && e[2] >= t[0] && e[1] <= t[3] && e[3] >= t[1], getRightIcons = (e) => {
82
+ }, formatMinutesToDDHHMM = (e) => {
83
+ const t = hooks.duration(e, "minutes"), n = Math.floor(t.asDays()), o = t.hours(), r = t.minutes();
84
+ let l = `${String(r).padStart(2, "0")}分`;
85
+ return o !== 0 && (l = `${String(o).padStart(2, "0")}时${l}`), n !== 0 && (l = `${String(n).padStart(2, "0")}天${l}`), l;
86
+ }, trackLayers = /* @__PURE__ */ new Map(), allTracks = {};
87
+ let activeTrackId = null;
88
+ const DEFAULT_VALUE = "--";
89
+ let moveFeatureHandler = null;
90
+ const popupEle = document.createElement("div"), popupOverlay = new Overlay({
91
+ element: popupEle,
92
+ positioning: "top-left",
93
+ stopEvent: !1,
94
+ className: "track-label-popup"
95
+ });
96
+ let polyline, linePath, startMarker, position, geoMarker, trackAnimating = !1, lastTime = Date.now(), vectorLayer$3, distance = 0, routeFeature = null, thresholdNum = 20;
97
+ const MAX_CACHED_LAYERS = 5, usedIds = [], manageLayerCache = (e) => {
98
+ var n;
99
+ const t = getInstall();
100
+ for (usedIds.unshift(e); usedIds.length > MAX_CACHED_LAYERS; ) {
101
+ const o = usedIds.pop(), r = trackLayers.get(o);
102
+ r && ((n = r.getSource()) == null || n.clear(), t == null || t.removeLayer(r), trackLayers.delete(o), delete allTracks[o]);
103
+ }
104
+ };
105
+ let trackColor = "";
106
+ const colors = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], reRenderTrackLine = () => {
107
+ var e;
108
+ activeTrackId && ((e = trackLayers.get(activeTrackId)) != null && e.getVisible()) && debounce(() => {
109
+ handlerRenderLine();
110
+ }, 300);
111
+ }, preprocessTrackData = (e, t) => {
112
+ let n = [];
113
+ return n = t.map((o, r) => {
114
+ if (Number(o.lon) > 180 || Number(o.lat) > 180) {
115
+ const [l, a] = convertSixHundredThousandToLatLng(o.lon, o.lat);
116
+ o.lon = l, o.lat = a;
117
+ }
118
+ return o.center = [o.lon, o.lat], o.centerPoint = lonLatToMercator(o.center), o.time = hooks(o.createdAt).format("YYYY-MM-DD HH:mm:ss"), o.id = e, o.index = r, o.bounds = [], o;
119
+ }), n;
120
+ }, renderTrackLine = async (e, t, n, o = "ship", r = 200) => {
121
+ const l = getInstall();
122
+ if (!l || (t = t == null ? void 0 : t.reverse(), popupOverlay && o === "ship" && (l != null && l.getOverlays().getArray().includes(popupOverlay) || l.addOverlay(popupOverlay)), (t == null ? void 0 : t.length) < 2))
123
+ return;
124
+ manageLayerCache(e), activeTrackId = e, allTracks[e] = t;
125
+ const a = Object.keys(allTracks).findIndex((s) => s === e) || 0;
126
+ trackColor = n || colors[a > 10 ? 10 : a], thresholdNum = r, await handlerRenderLine(), await setTrackViewCenter(activeTrackId);
127
+ }, createTrackLayer = (e) => {
128
+ const t = new VectorSource();
129
+ return new VectorLayer({
130
+ source: t,
131
+ visible: !1,
132
+ // 默认隐藏
133
+ className: `track-layer-${e}`,
134
+ renderBuffer: 1024
135
+ // 增大渲染缓冲区
136
+ });
137
+ }, setActiveLayer = (e) => {
138
+ const t = getInstall();
139
+ trackLayers.forEach((n, o) => {
140
+ var l;
141
+ const r = o === e;
142
+ n.getVisible() !== r && (n.setVisible(r), t.getLayers().getArray().includes(n) || t.addLayer(n), r || (l = n.getSource()) == null || l.clear());
143
+ }), activeTrackId = e;
144
+ }, handlerRenderLine = async () => {
145
+ const e = activeTrackId;
146
+ if (!trackLayers.has(e)) {
147
+ const c = createTrackLayer(e);
148
+ trackLayers.set(e, c);
149
+ }
150
+ setActiveLayer(e);
151
+ const t = trackLayers.get(e).getSource();
152
+ t == null || t.clear();
153
+ const n = trackColor || "", o = allTracks[e] || [];
154
+ if (!(o && o.length > 1)) return [];
155
+ const r = Math.max(1, Math.floor(o.length / thresholdNum)), l = o.filter((c, d) => d % r === 0);
156
+ let a = [];
157
+ a = preprocessTrackData(e, l);
158
+ const s = a.map((c) => c.centerPoint);
159
+ console.log("processedList", a.length), removeAllLabel(), a.length >= 2 && (await createTrackLineFeature(e, s, n), await createPointFeature(e, a, n));
160
+ }, createTrackLineFeature = (e, t, n) => {
161
+ const o = new LineString(t), r = trackLayers.get(e).getSource(), l = r.getFeatureById(e);
162
+ if (l)
163
+ l.setGeometry(o), l.setId(e), l.setStyle(createTrackLineStyle(n)), routeFeature = l;
164
+ else {
165
+ const a = new Feature({ geometry: o });
166
+ a.setId(e), a.set("type", "line"), a.setStyle(createTrackLineStyle(n)), r.addFeature(a), routeFeature = a;
167
+ }
168
+ return routeFeature;
169
+ }, createTrackLineStyle = (e) => new Style({
170
+ stroke: new Stroke({
171
+ color: e,
172
+ width: 2
173
+ })
174
+ }), handleTrackMapEvent = (e, t, n) => {
175
+ const o = e == null ? void 0 : e.get("trackId"), r = getInstall();
176
+ if (e && o && t === "hover") {
177
+ r.getTargetElement().style.cursor = o ? "pointer" : "";
178
+ const l = e.get("data"), a = renderTrackPointHtml(l), s = n == null ? void 0 : n.coordinate;
179
+ s && (popupEle.querySelector(".popup-content"), popupEle.innerHTML = a, popupOverlay == null || popupOverlay.setPosition(s));
180
+ } else
181
+ popupOverlay && popupOverlay.setPosition(void 0);
182
+ }, renderTrackPointHtml = (e) => {
183
+ if (!(e != null && e.time)) return;
184
+ let t = "";
185
+ return e != null && e.stayTime && (t = `
186
+ <div class="item w-100">
187
+ <div class="item-label">停泊时间约</div>
188
+ <div class="item-item">${formatMinutesToDDHHMM(Number(e.stayTime))}</div>
189
+ </div>
190
+ `), `
191
+ <div class="track-point-popup">
192
+ <div class="item">
193
+ <div class="item-label">状态</div>
194
+ <div class="item-item">${e != null && e.sailStatus ? SHIP_SAIL_STATUS[e.sailStatus] : DEFAULT_VALUE}</div>
195
+ </div>
196
+ <div class="item">
197
+ <div class="item-label">航速</div>
198
+ <div class="item-item">${e.speed || DEFAULT_VALUE}</div>
199
+ </div>
200
+ <div class="item">
201
+ <div class="item-label">艏向</div>
202
+ <div class="item-item">${e.hdg || DEFAULT_VALUE}</div>
203
+ </div>
204
+ <div class="item">
205
+ <div class="item-label">航向</div>
206
+ <div class="item-item">${e.cog || DEFAULT_VALUE}</div>
207
+ </div>
208
+ <div class="item">
209
+ <div class="item-label">经度</div>
210
+ <div class="item-item">${e.lon || DEFAULT_VALUE}</div>
211
+ </div>
212
+ <div class="item">
213
+ <div class="item-label">纬度</div>
214
+ <div class="item-item">${e.lat || DEFAULT_VALUE}</div>
215
+ </div>
216
+ <div class="item w-100">
217
+ <div class="item-label">时间</div>
218
+ <div class="item-item">${e.time}</div>
219
+ </div>
220
+ ${t ?? t}
221
+ </div>`;
222
+ }, createPointFeature = (e, t, n) => {
223
+ const o = getInstall(), r = o.getView().getZoom() || 10, l = {
224
+ 10: 4,
225
+ 11: 6,
226
+ 12: 8,
227
+ 13: 12,
228
+ 14: 16,
229
+ 15: 20,
230
+ 16: 24,
231
+ 17: 30,
232
+ default: 4
233
+ }, a = l[r] || l.default, s = t.filter((i) => i.index === 0 || i.index === t.length - 1 || i.state !== "0");
234
+ if (t.length <= a) {
235
+ const i = t.map((m) => createPointFeatureWithStyle(m));
236
+ trackLayers.get(e).getSource().addFeatures(i), createArrowFetaure(e, t, t, n), t.forEach((m) => {
237
+ const g = createPointLabelOverlay(e, n, m);
238
+ o.addOverlay(g);
239
+ });
240
+ return;
241
+ }
242
+ const c = douglasPeuckerSimplify(t, s, a);
243
+ if (s.forEach((i) => {
244
+ c.some((u) => u.index === i.index) || c.push(i);
245
+ }), c.length > a) {
246
+ const i = Math.floor(c.length / a), u = [];
247
+ for (let m = 0; m < c.length; m += i)
248
+ u.push(c[m]);
249
+ c.splice(1, c.length - 2, ...u.slice(1, u.length - 1));
250
+ }
251
+ console.log("pointList------", c);
252
+ const d = c.map((i) => createPointFeatureWithStyle(i));
253
+ trackLayers.get(e).getSource().addFeatures(d), createArrowFetaure(e, c, t, n), c.forEach((i) => {
254
+ const u = createPointLabelOverlay(e, n, i);
255
+ o.addOverlay(u);
256
+ });
257
+ };
258
+ function douglasPeuckerSimplify(e, t, n) {
259
+ if (e.length <= n) return [...e];
260
+ const o = e.map((a) => fromLonLat(a.centerPoint)), l = douglasPeuckerIndex(o, 0, o.length - 1).map((a) => e[a]);
261
+ if (t.forEach((a) => {
262
+ l.some((s) => s.index === a.index) || l.push(a);
263
+ }), l.length > n) {
264
+ const a = Math.floor(l.length / n), s = [];
265
+ for (let c = 0; c < l.length; c += a)
266
+ s.push(l[c]);
267
+ l.splice(1, l.length - 2, ...s.slice(1, s.length - 1));
268
+ }
269
+ return l;
270
+ }
271
+ function douglasPeuckerIndex(e, t, n) {
272
+ const o = [t];
273
+ let r = 0;
274
+ if (t < n) {
275
+ const l = e[t], a = e[n];
276
+ let s = 0;
277
+ for (let c = t + 1; c < n; c++) {
278
+ const d = pointToLineDistance(e[c], l, a);
279
+ d > s && (s = d, r = c);
280
+ }
281
+ if (s > 1e-4) {
282
+ const c = douglasPeuckerIndex(e, t, r), d = douglasPeuckerIndex(e, r, n);
283
+ o.push(...c.slice(1), ...d.slice(1));
284
+ } else
285
+ o.push(n);
286
+ }
287
+ return o;
288
+ }
289
+ function pointToLineDistance(e, t, n) {
290
+ const o = e[0] - t[0], r = e[1] - t[1], l = n[0] - t[0], a = n[1] - t[1], s = o * l + r * a, c = l * l + a * a;
291
+ let d = -1;
292
+ c !== 0 && (d = s / c);
293
+ let p, i;
294
+ d < 0 ? (p = t[0], i = t[1]) : d > 1 ? (p = n[0], i = n[1]) : (p = t[0] + d * l, i = t[1] + d * a);
295
+ const u = e[0] - p, m = e[1] - i;
296
+ return Math.sqrt(u * u + m * m);
297
+ }
298
+ const createPointFeatureWithStyle = (e) => {
299
+ const t = new Feature({
300
+ geometry: new Point(e.centerPoint),
301
+ data: e
302
+ });
303
+ t.set("type", "track_point"), t.set("trackId", e.id), t.set("data", e);
304
+ let n = [
305
+ ...createPointStyle(trackColor)
306
+ ];
307
+ return (e.index === 0 || e.index === allTracks[e.id].length - 1) && (n = [...createIconPointStyle(e)], t.set("type", "track_begin")), e.state !== void 0 && e.state !== null && (n = [...createIconStateStyle(e)], t.set("type", "track_icon")), t.setStyle(n), t;
308
+ }, createPointLabelOverlay = (e, t, n) => {
309
+ const o = document.createElement("div");
310
+ o.className = "track-overlay-label", o.style.position = "relative", o.style.backgroundColor = "rgba(255,255,255,0.8)", o.style.border = `1px solid ${t}`, o.style.fontSize = "12px", o.innerHTML = `
311
+ <span>${n.time}</span>
312
+ <svg
313
+ style="position: absolute;left: -20px;top: 0;"
314
+ viewBox="0 0 20 20"
315
+ xmlns="http://www.w3.org/2000/svg"
316
+ width="20"
317
+ height="20">
318
+ <line x1="0" y1="20"
319
+ x2="20" y2="0"
320
+ stroke="${t}"
321
+ stroke-width="1" />
322
+ `;
323
+ const r = new Overlay({
324
+ element: o,
325
+ position: fromLonLat(n.center),
326
+ positioning: "top-left",
327
+ offset: [20, -20],
328
+ stopEvent: !1,
329
+ className: "track-label-time-overlay"
330
+ });
331
+ return r.set("class", "track-label-overlay"), r.set("trackId", e), r;
332
+ }, removeAllLabel = () => {
333
+ const e = getInstall(), t = cloneDeep(e == null ? void 0 : e.getOverlays().getArray()), n = t == null ? void 0 : t.filter((o) => o.get("class") === "track-label-overlay");
334
+ n && n.length > 0 && n.forEach((o) => {
335
+ o.setPosition(void 0), e.removeOverlay(o), o.dispose();
336
+ });
337
+ }, createPointStyle = (e) => [
338
+ new Style({
339
+ // 扩大交互热区
340
+ image: new CircleStyle({
341
+ stroke: new Stroke({ color: "rgba(0, 0, 0, 0.01)", width: 20 }),
342
+ radius: 3
343
+ })
344
+ }),
345
+ // 轨迹点样式
346
+ new Style({
347
+ image: new CircleStyle({
348
+ fill: new Fill({ color: e }),
349
+ stroke: new Stroke({ color: "#fff", width: 2 }),
350
+ radius: 3
351
+ })
352
+ })
353
+ ], createIconStateStyle = (e) => {
354
+ const t = "#E31818", n = "#1890FF", o = "&#xe6d2", r = new Style({
355
+ text: new Text({
356
+ font: "Normal 22px map-iconfont",
357
+ text: getIconFont(o),
358
+ offsetY: -10,
359
+ fill: new Fill({
360
+ color: Number(e.state) === 0 ? t : Number(e.state) === 1 ? n : ""
361
+ })
362
+ }),
363
+ zIndex: 99
364
+ }), a = getIconStyle("&#xe6e2;"), c = getIconStyle("&#xe703;"), d = [];
365
+ return Number(e.state) === 0 ? d.push(a) : Number(e.state) === 1 && d.push(c), d.push(r), d;
366
+ }, createArrowFetaure = (e, t, n, o) => {
367
+ const r = t || [], l = t.length;
368
+ l || (r.push(n[0]), r.push(n[n.length - 1]));
369
+ const a = [];
370
+ for (let c = 0; c < l - 1; c++) {
371
+ let d;
372
+ const p = t[c], i = (t[c + 1].index + p.index) / 2;
373
+ if (i % 2 === 0)
374
+ d = n[i].centerPoint;
375
+ else {
376
+ const u = n[Math.floor(i)], m = n[Math.ceil(i)];
377
+ if (u && m) {
378
+ const [g, f] = u.centerPoint, [y, v] = m.centerPoint;
379
+ d = [(g + y) / 2, (f + v) / 2];
380
+ }
381
+ }
382
+ if (d) {
383
+ const u = new Feature({
384
+ geometry: new Point(d)
385
+ });
386
+ u.set("type", "track_arrow"), u.setStyle(
387
+ new Style({
388
+ text: new Text({
389
+ font: "700 12px map-iconfont",
390
+ text: getIconFont("&#xe6bc;"),
391
+ fill: new Fill({ color: o }),
392
+ // 设置箭头旋转 角度转为弧度
393
+ rotation: getRotation(
394
+ t[c].center,
395
+ t[c + 1].center
396
+ ) * (Math.PI / 180)
397
+ })
398
+ })
399
+ ), a.push(u);
400
+ }
401
+ }
402
+ const s = trackLayers.get(e).getSource();
403
+ s == null || s.addFeatures(a);
404
+ }, setTrackViewCenter = (e) => {
405
+ var a;
406
+ const n = getInstall().getView(), o = trackLayers.get(e).getSource(), r = routeFeature || (e ? o.getFeatureById(e) : null);
407
+ if (!r) return;
408
+ const l = (a = r == null ? void 0 : r.getGeometry()) == null ? void 0 : a.getExtent();
409
+ if (l != null && l.length)
410
+ try {
411
+ const s = buffer(l, Math.max(l[2] - l[0], l[3] - l[1]) * 0.02);
412
+ n.fit(s);
413
+ } catch (s) {
414
+ console.log(s);
415
+ }
416
+ }, createIconPointStyle = (e) => {
417
+ const t = "&#xe69b;", r = e.index === 0 ? "#fcdc3f" : "#ff0000";
418
+ return [new Style({
419
+ text: new Text({
420
+ font: "Normal 14px map-iconfont",
421
+ text: getIconFont(t),
422
+ fill: new Fill({ color: r })
423
+ }),
424
+ zIndex: 101
425
+ })];
426
+ }, removeAllTrackLayer = () => {
427
+ console.log("清除所有的轨迹-----");
428
+ const e = getInstall();
429
+ stopAnimation(), trackLayers.forEach((n) => {
430
+ var o;
431
+ (o = n.getSource()) == null || o.clear(), e == null || e.removeLayer(n);
432
+ }), Object.keys(allTracks).forEach((n) => {
433
+ trackLayers.delete(n), delete allTracks[n];
434
+ }), removeAllLabel();
435
+ }, closeTrack = (e) => {
436
+ const t = getInstall(), n = trackLayers.get(e || activeTrackId);
437
+ n == null || n.setVisible(!1), cloneDeep(t.getOverlays().getArray()).forEach((r) => {
438
+ r.get("class") === "track-label-overlay" && (r.setPosition(void 0), t.removeOverlay(r));
439
+ }), stopAnimation();
440
+ }, getTrackLength = (e, t = LENGTH_UNIT.NM) => {
441
+ const n = {
442
+ id: e,
443
+ length: "--"
444
+ }, r = (allTracks[e] || []).map(
445
+ (a) => transform([a.lon, a.lat], projection.data, projection.mercator)
446
+ ), l = new LineString(r);
447
+ return n.length = formatLength(l, t) || "--", console.log("showTracks", n), n;
448
+ }, playShipTrack = (e, t) => {
449
+ handlePlay(String(e), t);
450
+ }, handlePlay = (e, t) => {
451
+ const n = allTracks[String(e)], o = n == null ? void 0 : n.map((r) => [r.lon, r.lat]);
452
+ o && playAnimation(o, t);
453
+ }, geoMarkerStyle = new Style({
454
+ text: new Text({
455
+ font: "700 20px map-iconfont",
456
+ text: getIconFont("&#xe657;"),
457
+ fill: new Fill({ color: "#ff0000" }),
458
+ rotation: 0
459
+ // 初始旋转角度
460
+ })
461
+ }), moveFeature = (e, t) => {
462
+ var u, m;
463
+ const n = getInstall(), o = Number(50 * t), r = ((u = e.frameState) == null ? void 0 : u.time) ?? Date.now(), l = r - lastTime;
464
+ if (distance = (distance + o * l / 1e6) % 2, lastTime = r, distance >= 1) {
465
+ stopAnimation();
466
+ return;
467
+ }
468
+ const a = linePath.getCoordinateAt(
469
+ distance > 1 ? 2 - distance : distance
470
+ ), s = linePath.getCoordinateAt(
471
+ distance > 1 ? distance - 0.01 : distance
472
+ ), c = linePath.getCoordinateAt(
473
+ distance > 1 ? 2 - distance : distance + 0.01
474
+ ), p = getRotation(
475
+ mercatorToLonLat(s, "array"),
476
+ mercatorToLonLat(c, "array")
477
+ ) * Math.PI / 180;
478
+ (m = geoMarkerStyle.getText()) == null || m.setRotation(p), position.setCoordinates(a);
479
+ const i = getVectorContext(e);
480
+ i.setStyle(geoMarkerStyle), i.drawGeometry(position), n == null || n.render();
481
+ }, startAnimation = () => {
482
+ var e;
483
+ trackAnimating = !0, lastTime = Date.now(), distance = 0, position = ((e = startMarker.getGeometry()) == null ? void 0 : e.clone()) || new Point([0, 0]), moveFeatureHandler && (vectorLayer$3 == null || vectorLayer$3.on("postrender", moveFeatureHandler)), geoMarker == null || geoMarker.setGeometry(void 0);
484
+ }, stopAnimation = () => {
485
+ const e = getInstall();
486
+ trackAnimating && (trackAnimating = !1, geoMarker == null || geoMarker.setGeometry(void 0), moveFeatureHandler && vectorLayer$3 && vectorLayer$3.un("postrender", moveFeatureHandler), vectorLayer$3 && (e == null || e.removeLayer(vectorLayer$3)), vectorLayer$3 = null, geoMarker = null);
487
+ }, playAnimation = (e, t) => {
488
+ trackAnimating && stopAnimation(), polyline = new Polyline({
489
+ factor: 1e6
490
+ }).writeGeometry(new LineString(e)), linePath = new Polyline({
491
+ factor: 1e6
492
+ }).readGeometry(polyline, {
493
+ dataProjection: projection.data,
494
+ featureProjection: projection.mercator
495
+ }), startMarker = new Feature({
496
+ type: "icon",
497
+ geometry: new Point(linePath.getFirstCoordinate())
498
+ });
499
+ const n = startMarker.getGeometry();
500
+ position = n ? n.clone() : new Point([0, 0]), geoMarker = new Feature({
501
+ type: "geoMarker",
502
+ style: geoMarkerStyle,
503
+ geometry: position
504
+ }), vectorLayer$3 = new VectorLayer({
505
+ source: new VectorSource({
506
+ features: [geoMarker]
507
+ })
508
+ });
509
+ const o = getInstall();
510
+ o == null || o.addLayer(vectorLayer$3), moveFeatureHandler = (r) => moveFeature(r, t), startAnimation();
511
+ }, getRotation = (e, t, n) => {
512
+ function o(i) {
513
+ return 180 * (i % (2 * Math.PI)) / Math.PI;
514
+ }
515
+ function r(i) {
516
+ return i % 360 * Math.PI / 180;
517
+ }
518
+ function l(i) {
519
+ var u;
520
+ if (!i) throw new Error("Coordinate is required");
521
+ if (!Array.isArray(i)) {
522
+ if ((i == null ? void 0 : i.type) === "Feature" && (i == null ? void 0 : i.geometry) !== null && ((u = i == null ? void 0 : i.geometry) == null ? void 0 : u.type) === "Point")
523
+ return i == null ? void 0 : i.geometry.coordinates;
524
+ if (i.type === "Point") return (i == null ? void 0 : i.coordinates) || [];
525
+ }
526
+ if (Array.isArray(i) && i.length >= 2 && !Array.isArray(i[0]) && !Array.isArray(i[1]))
527
+ return i;
528
+ throw new Error(
529
+ "Coordinate must be GeoJSON Point or an Array of numbers"
530
+ );
531
+ }
532
+ function a(i, u, m = {}) {
533
+ if (m.final)
534
+ return function(k, S) {
535
+ return (a(S, k) + 180) % 360;
536
+ }(i, u);
537
+ const g = l(i), f = l(u), y = r(g[0]), v = r(f[0]), L = r(g[1]), T = r(f[1]), w = Math.sin(v - y) * Math.cos(T), E = Math.cos(L) * Math.sin(T) - Math.sin(L) * Math.cos(T) * Math.cos(v - y);
538
+ return o(Math.atan2(w, E));
539
+ }
540
+ function s(i) {
541
+ return !isNaN(i) && i !== null && !Array.isArray(i);
542
+ }
543
+ function c(i, u = {}, m = {}) {
544
+ return i || console.log("Coordinates are required"), Array.isArray(i) || console.log("Coordinates must be an Array"), i.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!s(i[0]) || !s(i[1])) && console.log("Coordinates must contain numbers"), d({ type: "Point", coordinates: i }, u, m);
545
+ }
546
+ function d(i, u = {}, m = {}) {
547
+ const g = {
548
+ type: "Feature",
549
+ id: "",
550
+ properties: {},
551
+ bbox: {},
552
+ geometry: {}
553
+ };
554
+ return m.id !== void 0 && (g.id = m.id), m.bbox && (g.bbox = m.bbox), g.properties = u, g.geometry = i, g;
555
+ }
556
+ const p = a(c(e), c(t), n);
557
+ return p < 0 ? 360 + p : p;
558
+ }, getRightIcons = (e) => {
81
559
  const t = [];
82
560
  return e.existDevice && t.push("&#xe687;"), e.existMobile && t.push("&#xe688;"), e.existWaterGauge && t.push("&#xe686;"), t;
83
561
  };
@@ -131,13 +609,13 @@ function useShipOverlay(e) {
131
609
  }, 1e3);
132
610
  }, d = () => {
133
611
  s && (clearInterval(s), s = null);
134
- }, u = () => {
612
+ }, p = () => {
135
613
  n.value && n.value.setPosition(fromLonLat(e.position));
136
614
  };
137
615
  return watch(() => e.selected, (i) => {
138
616
  i ? c() : d();
139
617
  }, { immediate: !0 }), watch(() => e.position, () => {
140
- u();
618
+ p();
141
619
  }, { deep: !0 }), onMounted(() => {
142
620
  }), onBeforeUnmount(() => {
143
621
  d();
@@ -273,8 +751,8 @@ function setLinePath(e) {
273
751
  n && o === "top-right" && (n.style.right = "-20px"), n && o === "top-left" && (n.style.left = "-20px");
274
752
  const l = POSITION_PRIORITY.filter((s) => s.positioning === o && s.offset === r), a = t == null ? void 0 : t.querySelector(".ship-overlay-line line");
275
753
  if (l.length > 0) {
276
- const { x1: s, y1: c, x2: d, y2: u } = l[0].line;
277
- a && (a.setAttribute("x1", s), a.setAttribute("y1", c), a.setAttribute("x2", d), a.setAttribute("y2", u));
754
+ const { x1: s, y1: c, x2: d, y2: p } = l[0].line;
755
+ a && (a.setAttribute("x1", s), a.setAttribute("y1", c), a.setAttribute("x2", d), a.setAttribute("y2", p));
278
756
  }
279
757
  }
280
758
  function removeLabelOverlay(e) {
@@ -390,23 +868,24 @@ let hoveredShipId = "", attentionShips = {}, attentionShipsColor = {};
390
868
  const renderShipList = (e) => {
391
869
  console.log("renderShipList", e);
392
870
  const t = getInstall();
393
- if (!t) return;
871
+ if (!e || !t) return;
394
872
  removeSelectedOverlay(), t.getLayers().getArray().includes(shipsLayer) || t.addLayer(shipsLayer);
395
873
  const n = (selectedShip == null ? void 0 : selectedShip.id) || (selectedShipFeature == null ? void 0 : selectedShipFeature.get("id"));
396
874
  removeLabelOverlay(t), shipsSource && shipsSource.clear();
397
875
  const o = [];
398
876
  if (selectedShip) {
399
- const r = e.filter((l) => l.id === n);
400
- r.length === 0 ? e.push(selectedShip) : selectedShip = r[0];
877
+ const l = e.filter((a) => a.id === n);
878
+ l.length === 0 ? e.push(selectedShip) : selectedShip = l[0];
401
879
  }
402
- e.forEach((r) => {
403
- if (r.lon && r.lat) {
404
- const l = createShipFetature(r);
405
- o.push(l), createLabelStyle(l);
880
+ const r = getZoom();
881
+ e.forEach((l) => {
882
+ if (l) {
883
+ const a = createShipFetature(l);
884
+ o.push(a), ((selectedShip == null ? void 0 : selectedShip.id) == l.id || r >= MAP_ZOOM.shipModelMin) && createLabelStyle(a);
406
885
  }
407
886
  }), shipsSource.addFeatures(o), handleChangeSelected();
408
887
  }, createShipFetature = (e) => {
409
- const t = (selectedShip == null ? void 0 : selectedShip.id) || (selectedShipFeature == null ? void 0 : selectedShipFeature.get("id")), n = fromLonLat([e.lon, e.lat]), o = new Feature({
888
+ const t = (selectedShip == null ? void 0 : selectedShip.id) || (selectedShipFeature == null ? void 0 : selectedShipFeature.get("id")), n = fromLonLat([e == null ? void 0 : e.lon, e == null ? void 0 : e.lat]), o = new Feature({
410
889
  geometry: new Point(n),
411
890
  // 船舶数据
412
891
  shipData: e,
@@ -458,8 +937,8 @@ const renderShipList = (e) => {
458
937
  const a = attentionShips[l], s = o.find((d) => d.getId() === "label-" + l), c = r.find((d) => l === d.get("id"));
459
938
  if (s && c) {
460
939
  c.set("blinking", a), c.set("blinkingColor", attentionShipsColor[l] || "");
461
- const d = s.getElement(), u = createLabelElement(c), i = u.querySelector(".ship-overlay-line"), p = d == null ? void 0 : d.querySelector(".ship-overlay-line");
462
- d && d !== u && (p && i && i.replaceWith(p), s.setElement(u));
940
+ const d = s.getElement(), p = createLabelElement(c), i = p.querySelector(".ship-overlay-line"), u = d == null ? void 0 : d.querySelector(".ship-overlay-line");
941
+ d && d !== p && (u && i && i.replaceWith(u), s.setElement(p));
463
942
  }
464
943
  }
465
944
  }, filterShipShow = (e) => {
@@ -471,13 +950,13 @@ const renderShipList = (e) => {
471
950
  });
472
951
  const a = cloneDeep(t.getOverlays().getArray());
473
952
  r.forEach((s) => {
474
- const c = s.get("id"), d = a.find((u) => u.getId() === "label-" + c);
953
+ const c = s.get("id"), d = a.find((p) => p.getId() === "label-" + c);
475
954
  if (!l.has(c))
476
955
  s.setStyle([]), d && (d.get("element").style.visibility = "hidden");
477
956
  else {
478
957
  d && (d.get("element").style.visibility = "visible");
479
- const u = s.getStyle();
480
- (u == null ? void 0 : u.length) == 0 && s.setStyle(createShipStyle(s));
958
+ const p = s.getStyle();
959
+ (p == null ? void 0 : p.length) == 0 && s.setStyle(createShipStyle(s));
481
960
  }
482
961
  });
483
962
  }, renderShipSelected = (e) => {
@@ -487,15 +966,6 @@ const renderShipList = (e) => {
487
966
  t && (selectedShipFeature = t), selectedShip = e, handleChangeSelected();
488
967
  } else
489
968
  console.log("取消选中"), selectedShip = null, selectedShipFeature = null, removeSelectedOverlay();
490
- }, renderShipSelectedChange = () => {
491
- const e = shipsSource.getFeatures().find((t) => t.get("id") === (selectedShip == null ? void 0 : selectedShip.id));
492
- if (e)
493
- e == null || e.setStyle(createShipStyle(e));
494
- else {
495
- const t = createShipFetature(selectedShip);
496
- shipsSource.addFeature(t), createLabelStyle(t);
497
- }
498
- handleChangeSelected();
499
969
  }, handleShipMapEvent = debounce((e, t, n) => {
500
970
  const o = getInstall();
501
971
  if (e) {
@@ -517,393 +987,6 @@ const renderShipList = (e) => {
517
987
  } catch (e) {
518
988
  console.log(e);
519
989
  }
520
- }, stopIcon = "&#xe6e2;", stopColor = "#E31818", slowIcon = "&#xe703;", slowColor = "#1890FF", dropletsIcon = "&#xe6d2", DEFAULT_VALUE = "--";
521
- let moveFeatureHandler = null;
522
- const stopIconStyle = getIconStyle(stopIcon), slowIconStyle = getIconStyle(slowIcon), popupEle = document.createElement("div"), popupOverlay = new Overlay({
523
- element: popupEle,
524
- positioning: "top-left",
525
- stopEvent: !1,
526
- className: "track-label-popup"
527
- });
528
- let polyline, linePath, startMarker, position, geoMarker, trackAnimating = !1, lastTime = Date.now(), vectorLayer$3, distance = 0, thresholdNum = 20;
529
- const routesSource = new VectorSource(), routeLayer = new VectorLayer({
530
- source: routesSource,
531
- className: "zh-map--track-layer",
532
- zIndex: 102
533
- });
534
- let routeFeatures = [], allTracks = {}, trackId = "", trackColor = "", trackList = [], mapInstance$1 = null, isClosing = !1;
535
- const reRenderTrackLine = () => {
536
- mapInstance$1 = getInstall(), isClosing || handlerRenderLine();
537
- }, renderTrackLine = async (e, t, n, o = "ship", r = 200) => {
538
- mapInstance$1 = getInstall(), mapInstance$1 && (routeLayer == null || routeLayer.setVisible(!0), t = t == null ? void 0 : t.reverse(), popupOverlay && o === "ship" && (mapInstance$1 != null && mapInstance$1.getOverlays().getArray().includes(popupOverlay) || mapInstance$1.addOverlay(popupOverlay)), isClosing = !1, !((t == null ? void 0 : t.length) < 2) && (t.forEach((l) => {
539
- l.state ? l.state = Number(l.state) : delete l.state;
540
- }), trackId = e, trackList = t, allTracks[e] = t, trackList = [], trackColor = n, thresholdNum = r, await handlerRenderLine(), await setTrackViewCenter(trackId)));
541
- }, handlerRenderLine = async () => {
542
- renderShipSelectedChange();
543
- const e = trackColor || "", t = trackId, n = allTracks[trackId] || [], o = thresholdNum || 200, r = Math.max(1, Math.floor(n.length / o));
544
- trackList = n.filter((s, c) => c % r === 0).map((s, c) => {
545
- if (Number(s.lon) > 180 || Number(s.lat) > 180) {
546
- const [d, u] = convertSixHundredThousandToLatLng(s.lon, s.lat);
547
- s.lon = d, s.lat = u;
548
- }
549
- return s.center = [s.lon, s.lat], s.centerPoint = lonLatToMercator(s.center), s.id = t, s.index = c, s.time = hooks(s.createdAt).format("YYYY-MM-DD HH:mm:ss"), s;
550
- });
551
- const a = trackList.map((s) => s.centerPoint);
552
- a.length >= 2 && (mapInstance$1 == null || mapInstance$1.addLayer(routeLayer), await createTrackLineFeature(t, a, e));
553
- }, createTrackLineFeature = (e, t, n) => {
554
- var a;
555
- const o = new LineString(t), r = new Feature({ geometry: o });
556
- r.setStyle(createTrackLineStyle(n)), r.setId(e), r.set("type", "line"), (a = routeLayer == null ? void 0 : routeLayer.getSource()) == null || a.clear(), removeAllLabel(), routeFeatures = [];
557
- const l = routeFeatures.findIndex((s) => s.getId() === e);
558
- l >= 0 ? routeFeatures[l] = r : routeFeatures.push(r), routesSource.addFeatures([...routeFeatures]), createPointFeature(n);
559
- }, createTrackLineStyle = (e) => new Style({
560
- stroke: new Stroke({
561
- color: e,
562
- width: 2
563
- })
564
- }), handleTrackMapEvent = (e, t, n) => {
565
- const o = e == null ? void 0 : e.get("trackId");
566
- if (e && o && t === "hover") {
567
- mapInstance$1.getTargetElement().style.cursor = o ? "pointer" : "";
568
- const r = e.get("data"), l = renderTrackPointHtml(r), a = n == null ? void 0 : n.coordinate;
569
- a && (popupEle.querySelector(".popup-content"), popupEle.innerHTML = l, popupOverlay == null || popupOverlay.setPosition(a));
570
- } else
571
- popupOverlay && popupOverlay.setPosition(void 0);
572
- }, formatMinutesToDDHHMM = (e) => {
573
- const t = hooks.duration(e, "minutes"), n = Math.floor(t.asDays()), o = t.hours(), r = t.minutes();
574
- let l = `${String(r).padStart(2, "0")}分`;
575
- return o !== 0 && (l = `${String(o).padStart(2, "0")}时${l}`), n !== 0 && (l = `${String(n).padStart(2, "0")}天${l}`), l;
576
- }, renderTrackPointHtml = (e) => {
577
- if (!(e != null && e.time)) return;
578
- let t = "";
579
- return e != null && e.stayTime && (t = `
580
- <div class="item w-100">
581
- <div class="item-label">停泊时间约</div>
582
- <div class="item-item">${formatMinutesToDDHHMM(Number(e.stayTime))}</div>
583
- </div>
584
- `), `
585
- <div class="track-point-popup">
586
- <div class="item">
587
- <div class="item-label">状态</div>
588
- <div class="item-item">${e != null && e.sailStatus ? SHIP_SAIL_STATUS[e.sailStatus] : DEFAULT_VALUE}</div>
589
- </div>
590
- <div class="item">
591
- <div class="item-label">航速</div>
592
- <div class="item-item">${e.speed || DEFAULT_VALUE}</div>
593
- </div>
594
- <div class="item">
595
- <div class="item-label">艏向</div>
596
- <div class="item-item">${e.hdg || DEFAULT_VALUE}</div>
597
- </div>
598
- <div class="item">
599
- <div class="item-label">航向</div>
600
- <div class="item-item">${e.cog || DEFAULT_VALUE}</div>
601
- </div>
602
- <div class="item">
603
- <div class="item-label">经度</div>
604
- <div class="item-item">${e.lon || DEFAULT_VALUE}</div>
605
- </div>
606
- <div class="item">
607
- <div class="item-label">纬度</div>
608
- <div class="item-item">${e.lat || DEFAULT_VALUE}</div>
609
- </div>
610
- <div class="item w-100">
611
- <div class="item-label">时间</div>
612
- <div class="item-item">${e.time}</div>
613
- </div>
614
- ${t ?? t}
615
- </div>`;
616
- }, createPointFeature = (e) => {
617
- const t = trackList || [];
618
- if (!(t && t.length > 1)) return [];
619
- const n = { 16: 24, 17: 15, default: 4 }, o = [], r = t.length;
620
- for (let a = 0; a < r; a++) {
621
- t[a].index = a;
622
- const s = mapInstance$1 == null ? void 0 : mapInstance$1.getPixelFromCoordinate(t[a].centerPoint);
623
- if (s) {
624
- let c = s.concat(s);
625
- c = adjustBounds(c, [20, 20]);
626
- const d = mapInstance$1 == null ? void 0 : mapInstance$1.getView().getZoom();
627
- if (!d) return;
628
- if (d > 15) {
629
- const i = n[d] || n.default;
630
- c = adjustBounds(c, [i, i]);
631
- }
632
- let u = !0;
633
- if (t[a].state !== "0") {
634
- for (let i = 0; i < o.length; i++)
635
- if (isOverlapping$1(c, o[i].bounds)) {
636
- u = !1;
637
- break;
638
- }
639
- }
640
- u && (t[a].bounds = c, o.push(t[a]));
641
- }
642
- }
643
- const l = [];
644
- o.forEach((a) => {
645
- const s = new Feature({
646
- geometry: new Point(a.centerPoint),
647
- time: a.time
648
- });
649
- s.set("type", "track_point"), s.set("trackId", a.id), s.set("data", a), s.setStyle(createPointStyle(e)), l.push(s), typeof a == "object" && Object.prototype.hasOwnProperty.call(a, "state") && createIconFeature(a);
650
- }), routesSource.addFeatures(l), l.forEach((a) => {
651
- const s = a.getProperties().data, c = createPointLabelOverlay(e, s);
652
- mapInstance$1 == null || mapInstance$1.addOverlay(c);
653
- }), createArrowFetaure(o, e), createIconPointFeature();
654
- }, createPointLabelOverlay = (e, t) => {
655
- const n = document.createElement("div");
656
- n.className = "track-overlay-label", n.style.position = "relative", n.style.backgroundColor = "rgba(255,255,255,0.8)", n.style.border = `1px solid ${e}`, n.style.fontSize = "12px", n.innerHTML = `
657
- <span>${t.time}</span>
658
- <svg
659
- style="position: absolute;left: -20px;top: 0;"
660
- viewBox="0 0 20 20"
661
- xmlns="http://www.w3.org/2000/svg"
662
- width="20"
663
- height="20">
664
- <line x1="0" y1="20"
665
- x2="20" y2="0"
666
- stroke="${e}"
667
- stroke-width="1" />
668
- `;
669
- const o = new Overlay({
670
- element: n,
671
- position: fromLonLat(t.center),
672
- positioning: "top-left",
673
- offset: [20, -20],
674
- stopEvent: !1,
675
- className: "track-label-time-overlay"
676
- });
677
- return o.set("class", "track-label-overlay"), o;
678
- }, removeAllLabel = () => {
679
- const e = cloneDeep(mapInstance$1 == null ? void 0 : mapInstance$1.getOverlays().getArray()), t = e == null ? void 0 : e.filter((n) => n.get("class") === "track-label-overlay");
680
- t && t.length > 0 && t.forEach((n) => {
681
- n.setPosition(void 0), n.setElement(void 0), mapInstance$1 == null || mapInstance$1.removeOverlay(n), n.dispose();
682
- });
683
- }, createPointStyle = (e) => [
684
- new Style({
685
- // 扩大交互热区
686
- image: new CircleStyle({
687
- stroke: new Stroke({ color: "rgba(0, 0, 0, 0.01)", width: 20 }),
688
- radius: 3
689
- })
690
- }),
691
- // 轨迹点样式
692
- new Style({
693
- image: new CircleStyle({
694
- fill: new Fill({ color: e }),
695
- stroke: new Stroke({ color: "#fff", width: 2 }),
696
- radius: 3
697
- })
698
- })
699
- ], createIconFeature = (e) => {
700
- const t = new Feature({
701
- //point.centerPoint
702
- geometry: new Point([e.lon, e.lat]),
703
- time: e.time
704
- });
705
- t.set("type", "track_icon");
706
- const n = new Style({
707
- text: new Text({
708
- font: "Normal 22px map-iconfont",
709
- text: getIconFont(dropletsIcon),
710
- offsetY: -10,
711
- fill: new Fill({
712
- color: Number(e.state) === 0 ? stopColor : Number(e.state) === 1 ? slowColor : ""
713
- })
714
- }),
715
- zIndex: 99
716
- }), o = [];
717
- Number(e.state) === 0 ? o.push(stopIconStyle) : Number(e.state) === 1 && o.push(slowIconStyle), o.push(n), t.setStyle(o), routesSource.addFeature(t);
718
- }, createArrowFetaure = (e, t) => {
719
- const n = e || [], o = e.length;
720
- o || (n.push(trackList[0]), n.push(trackList[trackList.length - 1]));
721
- for (let r = 0; r < o - 1; r++) {
722
- let l;
723
- const a = e[r], s = (e[r + 1].index + a.index) / 2;
724
- if (s % 2 === 0)
725
- l = trackList[s].centerPoint;
726
- else {
727
- const c = trackList[Math.floor(s)], d = trackList[Math.ceil(s)];
728
- if (c && d) {
729
- const [u, i] = c.centerPoint, [p, m] = d.centerPoint;
730
- l = [(u + p) / 2, (i + m) / 2];
731
- }
732
- }
733
- if (l) {
734
- const c = new Feature({
735
- geometry: new Point(l)
736
- });
737
- c.set("type", "track_arrow"), c.setStyle(
738
- new Style({
739
- text: new Text({
740
- font: "700 14px map-iconfont",
741
- text: getIconFont("&#xe6bc;"),
742
- fill: new Fill({ color: t }),
743
- // 设置箭头旋转 角度转为弧度
744
- rotation: getRotation(
745
- e[r].center,
746
- e[r + 1].center
747
- ) * (Math.PI / 180)
748
- })
749
- })
750
- ), routesSource == null || routesSource.addFeature(c);
751
- }
752
- }
753
- }, setTrackViewCenter = (e) => {
754
- var r;
755
- const t = mapInstance$1.getView(), n = e ? routeFeatures.find((l) => l.getId() === e) : routeFeatures[0];
756
- if (!n) return;
757
- const o = (r = n == null ? void 0 : n.getGeometry()) == null ? void 0 : r.getExtent();
758
- if (o != null && o.length)
759
- try {
760
- const l = buffer(o, Math.max(o[2] - o[0], o[3] - o[1]) * 0.02);
761
- t.fit(l);
762
- } catch (l) {
763
- console.log(l);
764
- }
765
- }, createIconPointFeature = () => {
766
- const e = "&#xe69b;", t = "#fcdc3f", n = "#ff0000";
767
- (trackList.length < 2 ? [trackList[0]] : [trackList[0], trackList[trackList.length - 1]]).forEach((r) => {
768
- const l = new Feature({
769
- geometry: new Point(r.centerPoint)
770
- });
771
- l.set("type", "track_begin"), l.set("data", r);
772
- const a = r.index === 0 && trackList.length >= 2 ? t : n;
773
- l.setStyle(
774
- new Style({
775
- text: new Text({
776
- font: "Normal 14px map-iconfont",
777
- text: getIconFont(e),
778
- fill: new Fill({ color: a })
779
- }),
780
- zIndex: 101
781
- })
782
- ), routesSource.addFeature(l);
783
- });
784
- }, geoMarkerStyle = new Style({
785
- text: new Text({
786
- font: "700 20px map-iconfont",
787
- text: getIconFont("&#xe657;"),
788
- fill: new Fill({ color: "#ff0000" }),
789
- rotation: 0
790
- // 初始旋转角度
791
- })
792
- }), playShipTrack = (e, t) => {
793
- handlePlay(String(e), t);
794
- }, removeAllTrackLayer = () => {
795
- allTracks = {}, routesSource == null || routesSource.clear(), stopAnimation(), isClosing = !0;
796
- }, closeTrack = (e = !1) => {
797
- routeLayer == null || routeLayer.setVisible(!1);
798
- const t = getInstall();
799
- cloneDeep(t.getOverlays().getArray()).forEach((o) => {
800
- o.get("class") === "track-label-overlay" && (o.setPosition(void 0), t.removeOverlay(o), o.dispose());
801
- }), e && removeAllTrackLayer(), stopAnimation(), isClosing = !0;
802
- }, getTrackLength = (e, t = LENGTH_UNIT.NM) => {
803
- const n = {
804
- id: e,
805
- length: "--"
806
- }, r = (allTracks[e] || []).map(
807
- (a) => transform([a.lon, a.lat], projection.data, projection.mercator)
808
- ), l = new LineString(r);
809
- return n.length = formatLength(l, t) || "--", console.log("showTracks", n), n;
810
- }, handlePlay = (e, t) => {
811
- const n = allTracks[String(e)], o = n == null ? void 0 : n.map((r) => [r.lon, r.lat]);
812
- o && playAnimation(o, t);
813
- }, moveFeature = (e, t) => {
814
- var i, p;
815
- const n = Number(50 * t), o = ((i = e.frameState) == null ? void 0 : i.time) ?? Date.now(), r = o - lastTime;
816
- if (distance = (distance + n * r / 1e6) % 2, lastTime = o, distance >= 1) {
817
- stopAnimation();
818
- return;
819
- }
820
- const l = linePath.getCoordinateAt(
821
- distance > 1 ? 2 - distance : distance
822
- ), a = linePath.getCoordinateAt(
823
- distance > 1 ? distance - 0.01 : distance
824
- ), s = linePath.getCoordinateAt(
825
- distance > 1 ? 2 - distance : distance + 0.01
826
- ), d = getRotation(
827
- mercatorToLonLat(a, "array"),
828
- mercatorToLonLat(s, "array")
829
- ) * Math.PI / 180;
830
- (p = geoMarkerStyle.getText()) == null || p.setRotation(d), position.setCoordinates(l);
831
- const u = getVectorContext(e);
832
- u.setStyle(geoMarkerStyle), u.drawGeometry(position), mapInstance$1 == null || mapInstance$1.render();
833
- }, startAnimation = () => {
834
- var e;
835
- trackAnimating = !0, lastTime = Date.now(), distance = 0, position = ((e = startMarker.getGeometry()) == null ? void 0 : e.clone()) || new Point([0, 0]), moveFeatureHandler && (vectorLayer$3 == null || vectorLayer$3.on("postrender", moveFeatureHandler)), geoMarker == null || geoMarker.setGeometry(void 0);
836
- }, stopAnimation = () => {
837
- trackAnimating && (trackAnimating = !1, geoMarker == null || geoMarker.setGeometry(void 0), moveFeatureHandler && vectorLayer$3 && vectorLayer$3.un("postrender", moveFeatureHandler), vectorLayer$3 && (mapInstance$1 == null || mapInstance$1.removeLayer(vectorLayer$3)), vectorLayer$3 = null, geoMarker = null);
838
- }, playAnimation = (e, t) => {
839
- trackAnimating && stopAnimation(), polyline = new Polyline({
840
- factor: 1e6
841
- }).writeGeometry(new LineString(e)), linePath = new Polyline({
842
- factor: 1e6
843
- }).readGeometry(polyline, {
844
- dataProjection: projection.data,
845
- featureProjection: projection.mercator
846
- }), startMarker = new Feature({
847
- type: "icon",
848
- geometry: new Point(linePath.getFirstCoordinate())
849
- });
850
- const n = startMarker.getGeometry();
851
- position = n ? n.clone() : new Point([0, 0]), geoMarker = new Feature({
852
- type: "geoMarker",
853
- style: geoMarkerStyle,
854
- geometry: position
855
- }), vectorLayer$3 = new VectorLayer({
856
- source: new VectorSource({
857
- features: [geoMarker]
858
- })
859
- }), mapInstance$1 == null || mapInstance$1.addLayer(vectorLayer$3), moveFeatureHandler = (o) => moveFeature(o, t), startAnimation();
860
- }, getRotation = (e, t, n) => {
861
- function o(i) {
862
- return 180 * (i % (2 * Math.PI)) / Math.PI;
863
- }
864
- function r(i) {
865
- return i % 360 * Math.PI / 180;
866
- }
867
- function l(i) {
868
- var p;
869
- if (!i) throw new Error("Coordinate is required");
870
- if (!Array.isArray(i)) {
871
- if ((i == null ? void 0 : i.type) === "Feature" && (i == null ? void 0 : i.geometry) !== null && ((p = i == null ? void 0 : i.geometry) == null ? void 0 : p.type) === "Point")
872
- return i == null ? void 0 : i.geometry.coordinates;
873
- if (i.type === "Point") return (i == null ? void 0 : i.coordinates) || [];
874
- }
875
- if (Array.isArray(i) && i.length >= 2 && !Array.isArray(i[0]) && !Array.isArray(i[1]))
876
- return i;
877
- throw new Error(
878
- "Coordinate must be GeoJSON Point or an Array of numbers"
879
- );
880
- }
881
- function a(i, p, m = {}) {
882
- if (m.final)
883
- return function(k, S) {
884
- return (a(S, k) + 180) % 360;
885
- }(i, p);
886
- const g = l(i), y = l(p), v = r(g[0]), L = r(y[0]), w = r(g[1]), f = r(y[1]), T = Math.sin(L - v) * Math.cos(f), E = Math.cos(w) * Math.sin(f) - Math.sin(w) * Math.cos(f) * Math.cos(L - v);
887
- return o(Math.atan2(T, E));
888
- }
889
- function s(i) {
890
- return !isNaN(i) && i !== null && !Array.isArray(i);
891
- }
892
- function c(i, p = {}, m = {}) {
893
- return i || console.log("Coordinates are required"), Array.isArray(i) || console.log("Coordinates must be an Array"), i.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!s(i[0]) || !s(i[1])) && console.log("Coordinates must contain numbers"), d({ type: "Point", coordinates: i }, p, m);
894
- }
895
- function d(i, p = {}, m = {}) {
896
- const g = {
897
- type: "Feature",
898
- id: "",
899
- properties: {},
900
- bbox: {},
901
- geometry: {}
902
- };
903
- return m.id !== void 0 && (g.id = m.id), m.bbox && (g.bbox = m.bbox), g.properties = p, g.geometry = i, g;
904
- }
905
- const u = a(c(e), c(t), n);
906
- return u < 0 ? 360 + u : u;
907
990
  }, PORT_LAYER_CLASS_NAME = "zh-map-port-layer";
908
991
  let vectorLayer$2, vectorSource$2;
909
992
  const renderPortList = (e) => {
@@ -1401,11 +1484,11 @@ const initDraw = () => {
1401
1484
  sketch = t.feature, e = (n = sketch.getGeometry()) == null ? void 0 : n.on("change", (o) => {
1402
1485
  const r = o.target, l = computedArea(r, "nm"), s = r.getCoordinates()[0], c = new LineString([s[s.length - 2], s[s.length - 1]]), d = computedDistance(c, "nm");
1403
1486
  if (lineLimitError = Number(getLength(c) / 1e3) > 150, !l) return;
1404
- const u = '<span class="error pl-4">超出可以绘画的距离</span>';
1487
+ const p = '<span class="error pl-4">超出可以绘画的距离</span>';
1405
1488
  measureTooltipElement && (measureTooltipElement.innerHTML = `
1406
1489
  <div class="text">
1407
1490
  面积:${l}
1408
- ${lineLimitError ? u : ""}
1491
+ ${lineLimitError ? p : ""}
1409
1492
  </div>
1410
1493
  `), helpTooltipElement && (helpTooltipElement.innerHTML = `
1411
1494
  <div class="text">
@@ -1413,7 +1496,7 @@ const initDraw = () => {
1413
1496
  </div>
1414
1497
  <div class="text ${lineLimitError ? "error" : ""}">
1415
1498
  线段 ${s.length - 2}: ${d}
1416
- ${lineLimitError ? u : ""}
1499
+ ${lineLimitError ? p : ""}
1417
1500
 
1418
1501
  </div>
1419
1502
  <div>
@@ -1597,7 +1680,7 @@ const locationTruck = async (e) => {
1597
1680
  createVNode(ZoomControl, { ref: "zoomControlRef" }, null, 512)
1598
1681
  ], 64));
1599
1682
  }
1600
- }), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-16d189cd"]]), ZhMap = withInstall(Map$1);
1683
+ }), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5da7190c"]]), ZhMap = withInstall(Map$1);
1601
1684
  export {
1602
1685
  ZhMap as Z
1603
1686
  };