zhihao-ui 1.2.20 → 1.2.21

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 (58) hide show
  1. package/dist/es/{BaseInfo-Dr298ctb.js → BaseInfo-DCB7xgRw.js} +1 -1
  2. package/dist/es/{Button-CYr52jII.js → Button-Va8xfPJd.js} +2 -2
  3. package/dist/es/{DatePicker-vGQGWrmB.js → DatePicker-BrD1XS6-.js} +2 -2
  4. package/dist/es/DetailHeader-B9ttfBlv.js +59 -0
  5. package/dist/es/{DetailSubTitle-Cgs5HrKC.js → DetailSubTitle-BgbefcLD.js} +2 -2
  6. package/dist/es/{Dialog-stUaKQ4m.js → Dialog-CnqJMaPI.js} +31 -34
  7. package/dist/es/{DiyDataTable-A1P5k0Eh.js → DiyDataTable-uIkGrO_i.js} +80 -78
  8. package/dist/es/{EditInfoPair-DwwAGFc6.js → EditInfoPair-XiseN2F2.js} +3 -3
  9. package/dist/es/{FileWrapper-brjp8Thj.js → FileWrapper-CAwHicjK.js} +4 -4
  10. package/dist/es/{Grid-CIMCXeIw.js → Grid-CshEwvAH.js} +1 -1
  11. package/dist/es/{InfoPair-DZL6Vegw.js → InfoPair-DhVT8u-f.js} +3 -3
  12. package/dist/es/{Input-C4aIqSby.js → Input-CeiPnMtt.js} +3 -3
  13. package/dist/es/{Loading-DhEOgvVz.js → Loading-bv2DpqBO.js} +2 -2
  14. package/dist/es/Map-DhceUygQ.js +2020 -0
  15. package/dist/es/{MessageBox-d6upGeyX.js → MessageBox-2Vpy3Mva.js} +2 -2
  16. package/dist/es/{MoneyInput-DLMJRug1.js → MoneyInput-Deg1aj66.js} +7 -7
  17. package/dist/es/{PageHeadPanel-CldjeRYl.js → PageHeadPanel-BWjWkx8n.js} +2 -2
  18. package/dist/es/{Table-DwDzhuHY.js → Table-KSl_JT2q.js} +94 -94
  19. package/dist/es/{ToolTips-CLcRoFO4.js → ToolTips-Bw2lHQxC.js} +3 -3
  20. package/dist/es/index.js +21 -21
  21. package/dist/es/{utils-CbI5IWJJ.js → utils-D-zYpBSZ.js} +3 -3
  22. package/dist/es/{vendor-AIl6iHcE.js → vendor-gTOtiVzA.js} +6895 -6495
  23. package/dist/index.css +1 -1
  24. package/dist/types/components/DetailHeader/index.d.ts +9 -0
  25. package/dist/types/components/DetailHeader/types.d.ts +1 -0
  26. package/dist/types/components/Dialog/Dialog.vue.d.ts +2 -4
  27. package/dist/types/components/Dialog/index.d.ts +5 -10
  28. package/dist/types/components/DiyDataTable/DiyDataTable.vue.d.ts +2 -1
  29. package/dist/types/components/DiyDataTable/index.d.ts +3 -0
  30. package/dist/types/components/DiyDataTable/type.d.ts +3 -1
  31. package/dist/types/components/Map/Map.vue.d.ts +60 -5
  32. package/dist/types/components/Map/components/scaleLine.vue.d.ts +3 -1
  33. package/dist/types/components/Map/components/toolPanel.vue.d.ts +4 -0
  34. package/dist/types/components/Map/config.d.ts +2 -0
  35. package/dist/types/components/Map/index.d.ts +174 -9
  36. package/dist/types/components/Map/interface/entity/render.d.ts +12 -0
  37. package/dist/types/components/Map/interface/entity/shipInfoVo.d.ts +21 -3
  38. package/dist/types/components/Map/interface/entity/shipMapData.d.ts +2 -1
  39. package/dist/types/components/Map/render/canvasRender/canvasRender.d.ts +2 -1
  40. package/dist/types/components/Map/render/canvasRender/geometry.d.ts +3 -0
  41. package/dist/types/components/Map/render/canvasRender/renderCustomOverlay.d.ts +3 -1
  42. package/dist/types/components/Map/render/canvasRender/renderShipStyle.d.ts +3 -1
  43. package/dist/types/components/Map/render/canvasRender/renderTrackStyle.d.ts +5 -1
  44. package/dist/types/components/Map/render/drawPolygon.d.ts +4 -0
  45. package/dist/types/components/Map/render/renderDashboard.d.ts +3 -0
  46. package/dist/types/components/Map/render/renderMarker.d.ts +4 -3
  47. package/dist/types/components/Map/render/renderShip.d.ts +5 -2
  48. package/dist/types/components/Map/render/renderTrack.d.ts +3 -4
  49. package/dist/types/components/Map/render/renderTruck.d.ts +3 -1
  50. package/dist/types/components/Map/utils/common.d.ts +4 -8
  51. package/dist/types/components/Map/utils/format.d.ts +6 -14
  52. package/dist/types/components/Map/utils/store.d.ts +7 -1
  53. package/dist/types/components/Map/utils/transform.d.ts +13 -5
  54. package/dist/umd/index.css +1 -1
  55. package/dist/umd/index.umd.cjs +23 -23
  56. package/package.json +1 -1
  57. package/dist/es/DetailHeader-oqCdup4q.js +0 -58
  58. package/dist/es/Map-DGFoAMyH.js +0 -1803
@@ -0,0 +1,2020 @@
1
+ var B = Object.defineProperty;
2
+ var R = (e, t, o) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var I = (e, t, o) => R(e, typeof t != "symbol" ? t + "" : t, o);
4
+ import { defineComponent, inject, useModel, ref, watch, openBlock, createElementBlock, createElementVNode, createVNode, unref, withCtx, Fragment, renderList, toDisplayString, createCommentVNode, mergeModels, nextTick, onMounted, normalizeClass, renderSlot, createBlock, provide } from "vue";
5
+ import { n as getArea, o as getLength, V as VectorSource, p as VectorLayer, S as Style, C as CircleStyle, F as Fill, q as Stroke, D as Draw, O as Overlay, u as unByKey, r as ElSelect, s as ElOption, T as Text, t as fromLonLat, v as transformExtent, h as hooks, L as LineString, w as Feature, P as Point, x as Polyline, y as getVectorContext, e as cloneDeep, G as GeoJSON, W as WebGLPointsLayer, z as transform, A as buffer, B as ScaleLine$1, I as Icon, H as Translate, J as toLonLat, M as MultiPoint, K as getCenter, N as TileLayer, X as XYZ, Q as Map$1, R as View } from "./vendor-gTOtiVzA.js";
6
+ import { _ as _export_sfc } from "./Button-Va8xfPJd.js";
7
+ import { w as withInstall } from "./utils-D-zYpBSZ.js";
8
+ var BaseMapType = /* @__PURE__ */ ((e) => (e[e.vector = 0] = "vector", e[e.satellite = 1] = "satellite", e))(BaseMapType || {}), CAR_COLOR = /* @__PURE__ */ ((e) => (e[e.BLUE = 1] = "BLUE", e[e.YELLOW = 2] = "YELLOW", e[e.Y_GREEN = 3] = "Y_GREEN", e))(CAR_COLOR || {}), DEVICE_TYPE = /* @__PURE__ */ ((e) => (e[e.HOST = 1] = "HOST", e[e.TALK = 2] = "TALK", e[e.STORAGE = 3] = "STORAGE", e[e.INTERNET = 4] = "INTERNET", e[e.CAMERA = 5] = "CAMERA", e[e.LOAD = 6] = "LOAD", e))(DEVICE_TYPE || {}), LENGTH_UNIT = /* @__PURE__ */ ((e) => (e[e.M = 1] = "M", e[e.KM = 2] = "KM", e[e.NM = 3] = "NM", e))(LENGTH_UNIT || {}), SWITCH_BTN = /* @__PURE__ */ ((e) => (e.Camera = "camera", e.Mobile = "mobile", e.WaterGauge = "waterGauge", e))(SWITCH_BTN || {});
9
+ class ShipMapData {
10
+ constructor(t, o, n, r, l, i, s, c, d, m, u, f, p, y, h, g, L, T, b, C, F, v, S) {
11
+ I(this, "id");
12
+ // mmsi
13
+ I(this, "mmsi");
14
+ // 船舶三角形填充色
15
+ I(this, "fill");
16
+ // 船类型 "7": "货船",
17
+ I(this, "shipType");
18
+ // 船名
19
+ I(this, "name");
20
+ // 长度
21
+ I(this, "length");
22
+ // 宽度
23
+ I(this, "breadth");
24
+ // 经度
25
+ I(this, "lon");
26
+ // 纬度
27
+ I(this, "lat");
28
+ // 时间
29
+ I(this, "createdAt");
30
+ // 速度
31
+ I(this, "speed");
32
+ // 来源
33
+ I(this, "from");
34
+ // 船状态 "stop":"静止","sail":"航行","work":"作业","danger":"危险","other":"其他"
35
+ I(this, "sailStatus");
36
+ // 船艏向
37
+ I(this, "hdg");
38
+ // 航迹向
39
+ I(this, "cog");
40
+ // 设备定位类型
41
+ I(this, "posType");
42
+ I(this, "type");
43
+ // 航向角度
44
+ I(this, "angle");
45
+ // 左侧是否显示色块
46
+ I(this, "leftIconColor");
47
+ I(this, "existDevice");
48
+ I(this, "existMobile");
49
+ I(this, "existWaterGauge");
50
+ I(this, "selected");
51
+ this.id = t, this.mmsi = o, this.fill = n, this.shipType = r, this.name = l, this.length = i, this.breadth = s, this.lon = c, this.lat = d, this.createdAt = m, this.speed = u, this.from = f, this.sailStatus = p, this.hdg = y, this.cog = h, this.posType = g, this.type = L, this.angle = T, this.leftIconColor = b, this.existDevice = C, this.existMobile = F, this.existWaterGauge = v, this.selected = S;
52
+ }
53
+ }
54
+ const formatLength = function(e, t) {
55
+ const n = getLength(e);
56
+ let r = "";
57
+ switch (t) {
58
+ case LENGTH_UNIT.M:
59
+ r = Math.round(n * 100) / 100 + " m";
60
+ break;
61
+ case LENGTH_UNIT.KM:
62
+ r = Math.round(n / 1e3 * 100) / 100 + " km";
63
+ break;
64
+ case LENGTH_UNIT.NM:
65
+ r = (Math.round(n / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
66
+ break;
67
+ }
68
+ return r;
69
+ }, convertSixHundredThousandToLatLng = function(e, t) {
70
+ const o = Number(t) / 6e5;
71
+ return [Number(e) / 6e5, o];
72
+ }, formatArea = (e, t) => {
73
+ const n = getArea(e);
74
+ let r;
75
+ switch (t) {
76
+ case LENGTH_UNIT.KM:
77
+ n > 1e4 ? r = Math.round(n / 1e6 * 100) / 100 + " km<sup>2</sup>" : r = Math.round(n * 100) / 100 + " m<sup>2</sup>";
78
+ break;
79
+ case LENGTH_UNIT.NM:
80
+ const l = Math.pow(1.852, 2);
81
+ n > 1e4 ? r = Math.round(n / 1e6 / l * 100) / 100 + " nm<sup>2</sup>" : r = Math.round(n * 100) / 100 + " m<sup>2</sup>";
82
+ break;
83
+ }
84
+ return r;
85
+ }, convertShipMapData = (e) => {
86
+ const t = (o) => new ShipMapData(
87
+ o.id,
88
+ o.id,
89
+ // 船舶三角形填充色
90
+ o.fill || "#04C900",
91
+ "70",
92
+ (o.cnname || o.enname || o.name) + `${o.existName ? o.existName : ""}`,
93
+ o.len || o.length,
94
+ o.wid || o.breadth,
95
+ o.lon,
96
+ o.lat,
97
+ (/* @__PURE__ */ new Date()).getTime(),
98
+ o.spd,
99
+ o.from,
100
+ o.status,
101
+ Number(o.hdg),
102
+ o.cog,
103
+ Number(o.postype),
104
+ "other",
105
+ o.cog,
106
+ o.leftIconColor,
107
+ o.existDevice,
108
+ o.existMobile,
109
+ o.existWaterGauge
110
+ );
111
+ return Array.isArray(e) ? e.map((o) => t(o)) : t(e);
112
+ }, formatUtils = {
113
+ formatLength,
114
+ convertSixHundredThousandToLatLng,
115
+ formatArea
116
+ }, _hoisted_1$4 = {
117
+ key: 0,
118
+ class: "measure-panel"
119
+ }, _hoisted_2$2 = { class: "d-flex justify-content-between align-content-start w-100" }, _hoisted_3$2 = { class: "measure-history-list" }, _hoisted_4 = { class: "left-panel" }, _hoisted_5 = { class: "text index" }, _hoisted_6 = { class: "text" }, _hoisted_7 = ["onClick"], _sfc_main$5 = /* @__PURE__ */ defineComponent({
120
+ __name: "measure",
121
+ props: /* @__PURE__ */ mergeModels({
122
+ viewMode: {}
123
+ }, {
124
+ visible: { type: Boolean },
125
+ visibleModifiers: {}
126
+ }),
127
+ emits: /* @__PURE__ */ mergeModels(["close"], ["update:visible"]),
128
+ setup(e, { expose: t, emit: o }) {
129
+ const n = inject("mapInstance"), r = o, l = useModel(e, "visible"), i = ref("3"), s = ref([]), c = ref(!1), d = new VectorSource();
130
+ let m, u, f, p, y;
131
+ const h = new VectorLayer({
132
+ source: d,
133
+ style: {
134
+ "fill-color": "rgba(255, 255, 255, 0.2)",
135
+ "stroke-color": "#ffcc33",
136
+ "stroke-width": 2,
137
+ "circle-radius": 7,
138
+ "circle-fill-color": "#ffcc33"
139
+ }
140
+ }), g = function(k) {
141
+ if (k.dragging)
142
+ return;
143
+ let M = "点击选择起点";
144
+ m && (M = "单击继续,双击结束"), u && (u.innerHTML = M, f.setPosition(k.coordinate), u.classList.remove("hidden"));
145
+ }, L = () => {
146
+ n.value && (n.value.on("pointermove", g), n.value.getViewport().addEventListener("mouseout", function() {
147
+ var k;
148
+ (k = u == null ? void 0 : u.classList) == null || k.add("hidden");
149
+ }), c.value = !0);
150
+ };
151
+ let T;
152
+ const b = new Style({
153
+ fill: new Fill({
154
+ color: "rgba(255, 255, 255, 0.2)"
155
+ }),
156
+ stroke: new Stroke({
157
+ color: "rgba(255,204,51)",
158
+ lineDash: [10, 10],
159
+ width: 2
160
+ }),
161
+ image: new CircleStyle({
162
+ radius: 5,
163
+ stroke: new Stroke({
164
+ color: "rgba(0, 0, 0, 0.7)"
165
+ }),
166
+ fill: new Fill({
167
+ color: "rgba(255, 255, 255, 0.2)"
168
+ })
169
+ })
170
+ });
171
+ function C() {
172
+ var k, M;
173
+ if (n.value) {
174
+ if (s.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((E) => {
175
+ var x;
176
+ (x = E == null ? void 0 : E.parentNode) == null || x.removeChild(E);
177
+ }), d.clear(), T) {
178
+ const E = n.value.getInteractions().getArray().find((x) => x.ol_uid === T.ol_uid);
179
+ E && ((k = n.value) == null || k.removeInteraction(E));
180
+ }
181
+ (M = n.value) == null || M.removeLayer(h), u != null && u.parentNode && u.parentNode.removeChild(u), p != null && p.parentNode && p.parentNode.removeChild(p);
182
+ }
183
+ }
184
+ function F() {
185
+ var M, E;
186
+ C(), (M = n.value) == null || M.addLayer(h), T = new Draw({
187
+ source: d,
188
+ type: "LineString",
189
+ style: function() {
190
+ return b;
191
+ }
192
+ }), (E = n.value) == null || E.addInteraction(T), S(), v();
193
+ let k;
194
+ T.on("drawstart", function(x) {
195
+ var N;
196
+ m = x.feature;
197
+ let P;
198
+ k = (N = m.getGeometry()) == null ? void 0 : N.on("change", function(A) {
199
+ const $ = A.target;
200
+ let _ = formatUtils.formatLength($, Number(i.value));
201
+ P = $.getLastCoordinate(), p && _ && (p.innerHTML = _), y.setPosition(P);
202
+ });
203
+ }), T.on("drawend", function() {
204
+ p && (p.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), p != null && p.innerHTML && s.value.push(p == null ? void 0 : p.innerHTML), y.setOffset([0, -7]), m = null, p = null, S(), k && unByKey(k);
205
+ });
206
+ }
207
+ function v() {
208
+ var k;
209
+ u != null && u.parentNode && u.parentNode.removeChild(u), u = document.createElement("div"), u.className = "ol-tooltip hidden", f = new Overlay({
210
+ element: u,
211
+ offset: [15, 0],
212
+ positioning: "center-left"
213
+ }), (k = n.value) == null || k.addOverlay(f);
214
+ }
215
+ function S() {
216
+ var k;
217
+ p != null && p.parentNode && p.parentNode.removeChild(p), p = document.createElement("div"), p.className = "ol-tooltip ol-tooltip-measure", y = new Overlay({
218
+ element: p,
219
+ offset: [0, -15],
220
+ positioning: "bottom-center",
221
+ stopEvent: !1,
222
+ insertFirst: !1
223
+ }), (k = n.value) == null || k.addOverlay(y);
224
+ }
225
+ const w = (k) => {
226
+ var x, P;
227
+ s.value[k] && s.value.splice(k, 1);
228
+ const M = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
229
+ M[k] && ((P = (x = M[k]) == null ? void 0 : x.parentNode) == null || P.removeChild(M[k]));
230
+ const E = d.getFeatures();
231
+ E[k] && d.removeFeature(E[k]);
232
+ }, V = () => {
233
+ r("close");
234
+ };
235
+ return watch(() => l, () => {
236
+ l && !c.value && (L(), F());
237
+ }, { deep: !0, immediate: !0 }), t({
238
+ addInteraction: F,
239
+ removeInteraction: C
240
+ }), (k, M) => l.value && k.viewMode !== "WxMiniprogram" ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
241
+ createElementVNode("div", { class: "header" }, [
242
+ M[1] || (M[1] = createElementVNode("div", { class: "title" }, "测量", -1)),
243
+ createElementVNode("i", {
244
+ onClick: V,
245
+ class: "map-iconfont icon-close"
246
+ })
247
+ ]),
248
+ createElementVNode("div", _hoisted_2$2, [
249
+ M[2] || (M[2] = createElementVNode("div", { class: "tips" }, "在地图上点击多个点测量距离,距离单位", -1)),
250
+ createVNode(unref(ElSelect), {
251
+ class: "select-length-unit",
252
+ modelValue: i.value,
253
+ "onUpdate:modelValue": M[0] || (M[0] = (E) => i.value = E)
254
+ }, {
255
+ default: withCtx(() => [
256
+ createVNode(unref(ElOption), {
257
+ label: "m",
258
+ value: "1"
259
+ }),
260
+ createVNode(unref(ElOption), {
261
+ label: "km",
262
+ value: "2"
263
+ }),
264
+ createVNode(unref(ElOption), {
265
+ label: "nm",
266
+ value: "3"
267
+ })
268
+ ]),
269
+ _: 1
270
+ }, 8, ["modelValue"])
271
+ ]),
272
+ createElementVNode("div", _hoisted_3$2, [
273
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(s.value, (E, x) => (openBlock(), createElementBlock("div", {
274
+ class: "measure-history-item",
275
+ key: x
276
+ }, [
277
+ createElementVNode("div", _hoisted_4, [
278
+ M[3] || (M[3] = createElementVNode("i", { class: "map-iconfont icon-line" }, null, -1)),
279
+ createElementVNode("span", _hoisted_5, "线段" + toDisplayString(x + 1), 1),
280
+ createElementVNode("span", _hoisted_6, toDisplayString(E), 1)
281
+ ]),
282
+ createElementVNode("div", {
283
+ class: "delete-button",
284
+ onClick: (P) => w(x)
285
+ }, M[4] || (M[4] = [
286
+ createElementVNode("i", { class: "map-iconfont icon-delete" }, null, -1)
287
+ ]), 8, _hoisted_7)
288
+ ]))), 128))
289
+ ])
290
+ ])) : createCommentVNode("", !0);
291
+ }
292
+ }), Measure = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-d566fd81"]]), CDN_URL = "https://static.zhihaoscm.cn/", tiandituKey = "a6e8f78974f2581f2ca00485b40c948f", baseMap = {
293
+ // 矢量底图
294
+ tiandituTile: `http://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=${tiandituKey}`,
295
+ // 矢量注记
296
+ tiandituTileMark: `http://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=${tiandituKey}`,
297
+ // 影像底图
298
+ tiandituImgTile: `http://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=${tiandituKey}`,
299
+ // 影像注记
300
+ tiandituImgTileMark: `http://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=${tiandituKey}`,
301
+ // 绿点图
302
+ greenTile: `${CDN_URL}/map/tile/{z}/{x}/{y}.png`
303
+ }, mapZoom = {
304
+ // 地图默认层级
305
+ default: 6,
306
+ // 地图缩放最小层级
307
+ min: 3,
308
+ // 地图缩放最大层级
309
+ max: 18,
310
+ // 查看船舶详情时地图缩放层级
311
+ findShipMin: 10,
312
+ findShip: 13,
313
+ // 查看车辆详情时地图缩放层级
314
+ findTruck: 14,
315
+ // 船舶绿点图最大显示层级
316
+ shipGreenDotMax: 11,
317
+ // 查车图标显示层级
318
+ truckDefault: 14,
319
+ // 统计图标显示层级
320
+ truckStatistics: 8,
321
+ // 船形图标最小渲染层级
322
+ shipModelMin: 13,
323
+ // 船形图标最大渲染层级
324
+ shipModelMax: 18
325
+ }, renderShipsLimit = 200, mapDefaultCenter = [114.84, 30.52], projection = {
326
+ // 经纬度 源数据 地理坐标 WGS84
327
+ data: "EPSG:4326",
328
+ // 墨卡托投影坐标 渲染坐标
329
+ mercator: "EPSG:3857"
330
+ };
331
+ ref();
332
+ const shipsLayer = ref(), largeAmountShipsLayer = ref(), selectShipsLayer = ref(), allShips = ref([]), selectSingleShipData = ref();
333
+ ref();
334
+ const trucksLayer = ref(), shipTrackLineFeatures = ref([]), trackLineVectorSource = ref(), shipTrackVectorLayer = ref();
335
+ ref();
336
+ ref();
337
+ const shipLabels = ref([]), trackLabels = ref([]), showTrackLayer = ref(!1), allTracks = ref([]), currentTrackId = ref(""), showTrackAnimatMarker = ref(!1), hiddenOrther = ref(!1);
338
+ function getIconFont(unicode = "") {
339
+ return unicode.indexOf("&amp;") !== -1 && (unicode = unicode.replace("&amp;", "&")), unicode.indexOf("&amp") !== -1 && (unicode = unicode.replace("&amp", "&")), eval('("' + unicode.replace("&#x", "\\u").replace(";", "") + '")');
340
+ }
341
+ const multiplyPixelRatio = (e) => {
342
+ const t = window.devicePixelRatio || 1;
343
+ return e.map((o) => o.map((n) => n * t));
344
+ }, 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 = (e, t) => e[0] <= t[2] && e[2] >= t[0] && e[1] <= t[3] && e[3] >= t[1], getIconStyle = (e) => new Style({
345
+ text: new Text({
346
+ font: "Normal 14px map-iconfont",
347
+ text: getIconFont(e),
348
+ fill: new Fill({ color: "#fff" }),
349
+ offsetY: -14
350
+ }),
351
+ zIndex: 100
352
+ }), getRotation = (e, t, o) => {
353
+ function n(u) {
354
+ return 180 * (u % (2 * Math.PI)) / Math.PI;
355
+ }
356
+ function r(u) {
357
+ return u % 360 * Math.PI / 180;
358
+ }
359
+ function l(u) {
360
+ if (!u) throw new Error("Coordinate is required");
361
+ if (!Array.isArray(u)) {
362
+ if (u.type === "Feature" && u.geometry !== null && u.geometry.type === "Point")
363
+ return u.geometry.coordinates;
364
+ if (u.type === "Point") return u.coordinates;
365
+ }
366
+ if (Array.isArray(u) && u.length >= 2 && !Array.isArray(u[0]) && !Array.isArray(u[1]))
367
+ return u;
368
+ throw new Error(
369
+ "Coordinate must be GeoJSON Point or an Array of numbers"
370
+ );
371
+ }
372
+ function i(u, f, p = {}) {
373
+ if (p.final)
374
+ return function(v, S) {
375
+ return (i(S, v) + 180) % 360;
376
+ }(u, f);
377
+ const y = l(u), h = l(f), g = r(y[0]), L = r(h[0]), T = r(y[1]), b = r(h[1]), C = Math.sin(L - g) * Math.cos(b), F = Math.cos(T) * Math.sin(b) - Math.sin(T) * Math.cos(b) * Math.cos(L - g);
378
+ return n(Math.atan2(C, F));
379
+ }
380
+ function s(u) {
381
+ return !isNaN(u) && u !== null && !Array.isArray(u);
382
+ }
383
+ function c(u, f = {}, p = {}) {
384
+ return u || console.log("Coordinates are required"), Array.isArray(u) || console.log("Coordinates must be an Array"), u.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!s(u[0]) || !s(u[1])) && console.log("Coordinates must contain numbers"), d({ type: "Point", coordinates: u }, f, p);
385
+ }
386
+ function d(u, f = {}, p = {}) {
387
+ const y = { type: "Feature" };
388
+ return p.id !== void 0 && (y.id = p.id), p.bbox && (y.bbox = p.bbox), y.properties = f || {}, y.geometry = u, y;
389
+ }
390
+ const m = i(c(e), c(t), o);
391
+ return m < 0 ? 360 + m : m;
392
+ }, labelAlpha = 0.8, labelFont = "500 12px Arial", labelOutSize = 2, labelHeight = 10, fillRectRadius = (e, t, o, n, r, l, i = 4) => {
393
+ e.beginPath(), e.moveTo(t + i, o), e.arcTo(t + n, o, t + n, o + i, i), e.arcTo(t + n, o + r, t + n - i, o + r, i), e.arcTo(t, o + r, t, o + r - i, i), e.arcTo(t, o, t + i, o, i), e.closePath(), e.fillStyle = l, e.fill();
394
+ }, getPixelFromCoordinate = (e) => {
395
+ if (!e || e.length === 0)
396
+ throw new Error("Points array is empty or invalid.");
397
+ let t = 1 / 0, o = 1 / 0, n = -1 / 0, r = -1 / 0;
398
+ for (const [l, i] of e)
399
+ l < t && (t = l), i < o && (o = i), l > n && (n = l), i > r && (r = i);
400
+ return [t, o, n, r];
401
+ }, calculatePolygonCentroid = (e) => {
402
+ if (!Array.isArray(e) || e.length < 3)
403
+ throw new Error("A polygon must have at least 3 coordinates.");
404
+ let t = 0, o = 0, n = 0;
405
+ const r = e.length;
406
+ for (let s = 0; s < r - 1; s++) {
407
+ const [c, d] = e[s], [m, u] = e[s + 1], f = c * u - m * d;
408
+ n += f, t += (c + m) * f, o += (d + u) * f;
409
+ }
410
+ if (n *= 0.5, n === 0)
411
+ throw new Error("多边形面积为零");
412
+ const l = t / (6 * n), i = o / (6 * n);
413
+ return [l, i];
414
+ }, rotateShapeModel = (e, t) => {
415
+ const [o, n] = calculatePolygonCentroid(e), r = t * Math.PI / 180, l = Math.cos(r), i = Math.sin(r);
416
+ return e.map(([s, c]) => {
417
+ const d = s - o, m = c - n, u = d * l - m * i + o, f = d * i + m * l + n;
418
+ return [u, f];
419
+ });
420
+ }, getTopLeftPoint = (e) => [e[0], e[3]], getBottomLeftPoint = (e) => [e[2], e[3]], getBottomRightPoint = (e) => [e[2], e[1]], getTopRighttPoint = (e) => [e[0], e[1]];
421
+ function calculateBounds(e, t, o, n, r) {
422
+ let l, i, s, c, d = e[0], m = e[1];
423
+ switch (t) {
424
+ case 0:
425
+ l = d + r, i = l + o, c = m - r, s = c - n;
426
+ break;
427
+ case 1:
428
+ l = d + r, i = l + o, c = m + n / 2, s = c - n;
429
+ break;
430
+ case 2:
431
+ l = d + r, i = l + o, c = m + r + n, s = c - n;
432
+ break;
433
+ case 3:
434
+ l = d - o / 2, i = l + o, c = m + r + n, s = c - n;
435
+ break;
436
+ case 4:
437
+ i = d, l = i - o, c = m + r + n, s = c - n;
438
+ break;
439
+ case 5:
440
+ i = d - r, l = i - o, c = m + n / 2, s = c - n;
441
+ break;
442
+ case 6:
443
+ i = d, l = i - o, c = m - r, s = c - n;
444
+ break;
445
+ case 7:
446
+ l = d - o / 2, i = l + o, c = m - r, s = c - n;
447
+ }
448
+ if (!(!l || !s || !i || !c))
449
+ return [Math.min(l, i), Math.min(s, c), Math.max(l, i), Math.max(s, c) + 1];
450
+ }
451
+ function calculateAnchorPoint(e, t, o = 70, n = 20, r = 20) {
452
+ let l = [0, 0];
453
+ switch (t) {
454
+ case 0:
455
+ l[0] = e[0] + r, l[1] = e[1] - r - n / 2;
456
+ break;
457
+ case 1:
458
+ l[0] = e[0] + r, l[1] = e[1];
459
+ break;
460
+ case 2:
461
+ l[0] = e[0] + r, l[1] = e[1] + r + n / 2;
462
+ break;
463
+ case 3:
464
+ l[0] = e[0], l[1] = e[1] + r + n / 4;
465
+ break;
466
+ case 4:
467
+ l[0] = Math.max(e[0] - r, e[0] - o / 2), l[1] = e[1] + r + n / 4;
468
+ break;
469
+ case 5:
470
+ l[0] = e[0] - r, l[1] = e[1];
471
+ break;
472
+ case 6:
473
+ l[0] = Math.max(e[0] - r, e[0] - o / 2), l[1] = e[1] - r - n / 4;
474
+ break;
475
+ case 7:
476
+ l[0] = e[0], l[1] = e[1] - r - n / 4;
477
+ }
478
+ return l;
479
+ }
480
+ function drawLabelBody(e, t, o) {
481
+ if (!e) return;
482
+ const {
483
+ font: n,
484
+ labelOutSize: r = 2,
485
+ labelHeight: l,
486
+ center: i,
487
+ text: s,
488
+ leftIcon: c,
489
+ shipColor: d,
490
+ lineLength: m = 20,
491
+ selected: u
492
+ } = o;
493
+ e.save(), n && (e.font = n);
494
+ let f = e.measureText(s).width + 2 * r;
495
+ (c || d) && (f += l + 4 * r), e.restore();
496
+ let p, y = 20, h = -1, g = l + 3 * r;
497
+ if (m)
498
+ for (let L = 0; L < 8; L++) {
499
+ p = calculateBounds(i, L, f, g, m);
500
+ let T = !1;
501
+ for (let b = 0; b < t.length; ++b) {
502
+ let C = t[b].bounds, F = [
503
+ C[0] - y,
504
+ C[1] - y,
505
+ C[2] + y,
506
+ C[3] + y
507
+ ];
508
+ if (p && isOverlapping(p, F)) {
509
+ T = !0;
510
+ break;
511
+ }
512
+ }
513
+ if (!T) {
514
+ h = L;
515
+ break;
516
+ }
517
+ }
518
+ else
519
+ h = 0, p = calculateBounds(i, h, f, g, m);
520
+ if (u && h === -1 && (h = 0), p && h > -1) {
521
+ let L = getBottomLeftPoint(p), T = getTopRighttPoint(p);
522
+ return {
523
+ center: i,
524
+ x: calculateAnchorPoint(i, h, f, g, m),
525
+ l: T,
526
+ r: L,
527
+ bounds: p,
528
+ position: h,
529
+ name: s
530
+ };
531
+ } else
532
+ return null;
533
+ }
534
+ const drawText = (e, t) => {
535
+ if (!e) return;
536
+ const { center: o, text: n, textColor: r, leftIcon: l, rightIcons: i, font: s } = t;
537
+ e.save(), e.setTransform(1, 0, 0, 1, 0, 0);
538
+ let [c, d] = o;
539
+ if (l) {
540
+ e.font = "22px map-iconfont";
541
+ let m = getIconFont(l.icon);
542
+ e.fillStyle = l.color, e.fillText(m, c + labelOutSize - 4, d + 4), c += 22;
543
+ }
544
+ if (i != null && i.length) {
545
+ e.font = "12px map-iconfont", e.fillStyle = "#3370ff";
546
+ let m = e.measureText(n).width + 6;
547
+ i.forEach((u, f) => {
548
+ let p = getIconFont(u), y = 20 * f;
549
+ e.fillText(p, c + m + y, d);
550
+ });
551
+ }
552
+ e.font = s || labelFont, e.fillStyle = r, e.fillText(n, c, d), e.restore();
553
+ }, drawPolygon = (e, t) => {
554
+ let {
555
+ points: o,
556
+ strokeColor: n,
557
+ fillColor: r,
558
+ shouldClosePath: l,
559
+ translation: i,
560
+ rotation: s,
561
+ rotationCenter: c,
562
+ scale: d,
563
+ globalAlpha: m
564
+ } = t;
565
+ if (m || (m = 1), o && e) {
566
+ e.save(), e.beginPath(), s && s !== 0 && c == null && e.rotate(s), i && e.translate(i[0], i[1]), s && (c != null && c.length) && e.rotate(s), d && e.scale(d, d), e.moveTo(o[0][0], o[0][1]);
567
+ for (let u = 1; u < o.length; u++)
568
+ e.lineTo(o[u][0], o[u][1]);
569
+ l && e.closePath(), n && (e.strokeStyle = n, e.stroke()), r && l && (m && (e.globalAlpha = m), e.fillStyle = r, e.fill()), e.restore();
570
+ }
571
+ }, drawLabel = (e, t, o) => {
572
+ const { center: n, text: r, color: l, textColor: i, bgColor: s, leftIcon: c, rightIcons: d, type: m } = t;
573
+ if (n && r) {
574
+ let u = {
575
+ font: labelFont,
576
+ labelOutSize,
577
+ labelHeight,
578
+ center: n,
579
+ text: r,
580
+ leftIcon: c,
581
+ selected: t.selected
582
+ }, f = drawLabelBody(e, o, u);
583
+ if (f) {
584
+ const { x: p, bounds: y, l: h } = f;
585
+ let g = [getTopLeftPoint(y), getBottomLeftPoint(y), getBottomRightPoint(y), getTopRighttPoint(y)];
586
+ o.find((v) => v.name === r) || o.push(f), drawPolygon(e, {
587
+ points: [n, p],
588
+ strokeColor: l,
589
+ fillColor: "#000",
590
+ shouldClosePath: !0,
591
+ translation: void 0,
592
+ rotation: void 0,
593
+ rotationCenter: void 0,
594
+ scale: void 0,
595
+ globalAlpha: labelAlpha
596
+ }), d != null && d.length && d.forEach(() => {
597
+ g[1][0] += 20, g[2][0] += 20;
598
+ }), drawPolygon(e, {
599
+ points: g,
600
+ strokeColor: l,
601
+ fillColor: s,
602
+ shouldClosePath: !0
603
+ });
604
+ const [b, C] = h, F = {
605
+ center: [b, C + labelOutSize + labelHeight + 1],
606
+ text: r,
607
+ textColor: i,
608
+ leftIcon: c,
609
+ rightIcons: d
610
+ };
611
+ drawText(e, F);
612
+ }
613
+ }
614
+ return null;
615
+ }, PI = Math.PI, a = 6378245, ee = 0.006693421622965943;
616
+ function transformLat(e, t) {
617
+ let o = -100 + 2 * e + 3 * t + 0.2 * t * t + 0.1 * e * t + 0.2 * Math.sqrt(Math.abs(e));
618
+ return o += (20 * Math.sin(6 * e * PI) + 20 * Math.sin(2 * e * PI)) * 2 / 3, o += (20 * Math.sin(t * PI) + 40 * Math.sin(t / 3 * PI)) * 2 / 3, o += (160 * Math.sin(t / 12 * PI) + 320 * Math.sin(t * PI / 30)) * 2 / 3, o;
619
+ }
620
+ function transformLng(e, t) {
621
+ let o = 300 + e + 2 * t + 0.1 * e * e + 0.1 * e * t + 0.1 * Math.sqrt(Math.abs(e));
622
+ return o += (20 * Math.sin(6 * e * PI) + 20 * Math.sin(2 * e * PI)) * 2 / 3, o += (20 * Math.sin(e * PI) + 40 * Math.sin(e / 3 * PI)) * 2 / 3, o += (150 * Math.sin(e / 12 * PI) + 300 * Math.sin(e / 30 * PI)) * 2 / 3, o;
623
+ }
624
+ function outOfChina(e, t) {
625
+ return !(e > 73.66 && e < 135.05 && t > 3.86 && t < 53.55);
626
+ }
627
+ function gcj02ToWgs84(e) {
628
+ const [t, o] = e.split(",").map(Number);
629
+ if (outOfChina(t, o))
630
+ return `${t.toFixed(6)}, ${o.toFixed(6)}`;
631
+ {
632
+ let n = transformLat(t - 105, o - 35), r = transformLng(t - 105, o - 35), l = o / 180 * PI, i = Math.sin(l);
633
+ i = 1 - ee * i * i;
634
+ let s = Math.sqrt(i);
635
+ n = n * 180 / (a * (1 - ee) / (i * s) * PI), r = r * 180 / (a / s * Math.cos(l) * PI);
636
+ let c = o + n, d = t + r;
637
+ return `${(t * 2 - d).toFixed(6)}, ${(o * 2 - c).toFixed(6)}`;
638
+ }
639
+ }
640
+ function calculateCirclePoints(e, t) {
641
+ const o = fromLonLat(e), n = t * 1e3, r = [
642
+ o[0] - n,
643
+ o[1] - n,
644
+ o[0] + n,
645
+ o[1] + n
646
+ ], l = transformExtent(r, projection.mercator, projection.data);
647
+ return {
648
+ leftTopPoint: { lng: l[0], lat: l[3] },
649
+ rightTopPoint: { lng: l[2], lat: l[3] },
650
+ rightBottomPoint: { lng: l[2], lat: l[1] },
651
+ leftBottomPoint: { lng: l[0], lat: l[1] }
652
+ };
653
+ }
654
+ const equatorialCircumference = 2003750834e-2;
655
+ function lonLatToMercator(e) {
656
+ const t = e[0] * equatorialCircumference / 180;
657
+ let o = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
658
+ return o = o * equatorialCircumference / 180, [t, o];
659
+ }
660
+ function mercatorToLonLat(e, t = "lonlat") {
661
+ let o = { lon: 0, lat: 0 }, n = e[0] / equatorialCircumference * 180, r = e[1] / equatorialCircumference * 180;
662
+ return r = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2), o.lon = n, o.lat = r, t === "lonlat" ? o : [n, r];
663
+ }
664
+ function calculateBoundingBox(e) {
665
+ let t = 1 / 0, o = -1 / 0, n = 1 / 0, r = -1 / 0;
666
+ e.forEach((h) => {
667
+ const [g, L] = h;
668
+ t = Math.min(t, L), o = Math.max(o, L), n = Math.min(n, g), r = Math.max(r, g);
669
+ });
670
+ const l = r - n, i = o - t, s = Math.max(l, i), c = (n + r) / 2, d = (t + o) / 2, m = s / 2, u = c - m, f = c + m, p = d - m, y = d + m;
671
+ return [f, p, u, y];
672
+ }
673
+ const transformUtils = {
674
+ gcj02ToWgs84,
675
+ calculateCirclePoints,
676
+ lonLatToMercator,
677
+ mercatorToLonLat,
678
+ calculateBoundingBox
679
+ }, mapInstance$8 = ref(), renderTrackStyleSetInstance = (e) => mapInstance$8.value = e, stopIcon = "&#xe6e2;", stopColor = "#E31818", slowIcon = "&#xe703;", slowColor = "#1890FF", dropletsIcon = "&#xe6d2", trackList$1 = ref([]), renderTrackLine = (e, t, o) => {
680
+ var l, i, s;
681
+ const n = e[t];
682
+ if (!n) return;
683
+ allTracks.value[t] = n, trackList$1.value = [], trackList$1.value = n.map((c, d) => (c.center = [c.lon, c.lat], c.centerPoint = transformUtils.lonLatToMercator(c.center), c.id = t, c.index = d, c.time = hooks(c.createdAt).format("YYYY-MM-DD HH:mm:ss"), c));
684
+ let r = trackList$1.value.map((c) => c.centerPoint);
685
+ if (r.length >= 2) {
686
+ let c = new LineString(r);
687
+ const d = new Feature({ geometry: c });
688
+ d.setStyle(
689
+ new Style({
690
+ stroke: new Stroke({
691
+ color: o,
692
+ width: 2
693
+ })
694
+ })
695
+ ), d.setId(t), d.set("type", "line"), (i = (l = shipTrackVectorLayer.value) == null ? void 0 : l.getSource()) == null || i.clear(), shipTrackLineFeatures.value = [];
696
+ const m = shipTrackLineFeatures.value.findIndex((u) => u.getId() === t);
697
+ m >= 0 ? shipTrackLineFeatures.value[m] = d : shipTrackLineFeatures.value.push(d), createAnimatedIconFeature(o, r), trackLineVectorSource.value = new VectorSource({
698
+ features: [...shipTrackLineFeatures.value]
699
+ }), shipTrackVectorLayer.value = new VectorLayer({
700
+ source: trackLineVectorSource.value
701
+ }), renderPoint(o), (s = mapInstance$8.value) == null || s.addLayer(shipTrackVectorLayer.value);
702
+ }
703
+ }, handlePlay = (e, t) => {
704
+ const o = allTracks.value[e];
705
+ playAnimation(o.map((n) => [n.lon, n.lat]), t);
706
+ }, removeShipTrackLineFeatureByIndex = (e) => {
707
+ e >= 0 && e < shipTrackLineFeatures.value.length && (shipTrackLineFeatures.value.splice(e, 1), allTracks.value.splice(e, 1)), trackLineVectorSource.value = new VectorSource({
708
+ features: [...shipTrackLineFeatures.value]
709
+ }), shipTrackVectorLayer.value && shipTrackVectorLayer.value.setSource(trackLineVectorSource.value);
710
+ }, createAnimatedIconFeature = (e, t) => {
711
+ const o = new Feature({
712
+ geometry: new Point(fromLonLat([t[0][0], t[0][1]]))
713
+ // 初始位置
714
+ }), n = new Style({
715
+ text: new Text({
716
+ font: "700 14px map-iconfont",
717
+ text: getIconFont("&#xe6bc;"),
718
+ fill: new Fill({ color: e })
719
+ })
720
+ });
721
+ return o.setStyle(n), o;
722
+ }, geoMarkerStyle = new Style({
723
+ text: new Text({
724
+ font: "700 20px map-iconfont",
725
+ text: getIconFont("&#xe657;"),
726
+ fill: new Fill({ color: "#ff0000" }),
727
+ rotation: 0
728
+ // 初始旋转角度
729
+ })
730
+ });
731
+ let polyline, linePath, startMarker, position, geoMarker, vectorLayer;
732
+ const trackAnimating = ref(!1);
733
+ let distance = 0, lastTime = Date.now(), moveFeatureHandler = null;
734
+ const moveFeature = (e, t) => {
735
+ var u;
736
+ const o = Number(50 * t), n = e.frameState.time, r = n - lastTime;
737
+ if (distance = (distance + o * r / 1e6) % 2, lastTime = n, distance >= 1) {
738
+ stopAnimation();
739
+ return;
740
+ }
741
+ const l = linePath.getCoordinateAt(
742
+ distance > 1 ? 2 - distance : distance
743
+ ), i = linePath.getCoordinateAt(
744
+ distance > 1 ? distance - 0.01 : distance
745
+ ), s = linePath.getCoordinateAt(
746
+ distance > 1 ? 2 - distance : distance + 0.01
747
+ ), d = getRotation(transformUtils.mercatorToLonLat(i, "array"), transformUtils.mercatorToLonLat(s, "array")) * Math.PI / 180;
748
+ geoMarkerStyle.getText().setRotation(d), position.setCoordinates(l);
749
+ const m = getVectorContext(e);
750
+ m.context_.save(), m.setStyle(geoMarkerStyle), m.drawGeometry(position), m.context_.restore(), (u = mapInstance$8.value) == null || u.render();
751
+ }, startAnimation = () => {
752
+ trackAnimating.value = !0, showTrackAnimatMarker.value = !0, lastTime = Date.now(), distance = 0, position = startMarker.getGeometry().clone(), vectorLayer.on("postrender", moveFeatureHandler), geoMarker.setGeometry(null);
753
+ }, stopAnimation = () => {
754
+ var e;
755
+ trackAnimating.value && (trackAnimating.value = !1, geoMarker.setGeometry(null), vectorLayer.un("postrender", moveFeatureHandler), (e = mapInstance$8.value) == null || e.removeLayer(vectorLayer), vectorLayer = null, geoMarker = null);
756
+ }, playAnimation = (e, t) => {
757
+ var o;
758
+ trackAnimating.value && stopAnimation(), polyline = new Polyline({
759
+ factor: 1e6
760
+ }).writeGeometry(new LineString(e)), linePath = new Polyline({
761
+ factor: 1e6
762
+ }).readGeometry(polyline, {
763
+ dataProjection: projection.data,
764
+ featureProjection: projection.mercator
765
+ }), startMarker = new Feature({
766
+ type: "icon",
767
+ geometry: new Point(linePath.getFirstCoordinate())
768
+ }), position = startMarker.getGeometry().clone(), geoMarker = new Feature({
769
+ type: "geoMarker",
770
+ style: geoMarkerStyle,
771
+ geometry: position
772
+ }), vectorLayer = new VectorLayer({
773
+ source: new VectorSource({
774
+ features: [geoMarker]
775
+ })
776
+ }), (o = mapInstance$8.value) == null || o.addLayer(vectorLayer), moveFeatureHandler = (n) => moveFeature(n, t), startAnimation();
777
+ }, renderPoint = (e) => {
778
+ if (!mapInstance$8.value) return;
779
+ let t = trackList$1.value || [];
780
+ if (!(t && t.length > 1)) return [];
781
+ let o = { 16: 24, 17: 15, default: 4 }, n = [], r = t.length;
782
+ for (let s = 0; s < r; s++) {
783
+ t[s].index = s;
784
+ let c = mapInstance$8.value.getPixelFromCoordinate(t[s].centerPoint);
785
+ if (c) {
786
+ let d = c.concat(c);
787
+ d = adjustBounds(d, [20, 20]);
788
+ let m = mapInstance$8.value.getView().getZoom();
789
+ if (!m) return;
790
+ if (m > 15) {
791
+ let f = o[m] || o.default;
792
+ d = adjustBounds(d, [f, f]);
793
+ }
794
+ let u = !0;
795
+ if (t[s].state !== "0") {
796
+ for (let f = 0; f < n.length; f++)
797
+ if (isOverlapping(d, n[f].bounds)) {
798
+ u = !1;
799
+ break;
800
+ }
801
+ }
802
+ u && (t[s].bounds = d, n.push(t[s]));
803
+ }
804
+ }
805
+ const l = getIconStyle(stopIcon), i = getIconStyle(slowIcon);
806
+ n.forEach((s, c) => {
807
+ var u, f;
808
+ let d = new Feature({
809
+ geometry: new Point(s.centerPoint)
810
+ });
811
+ d.set("type", "track_point"), d.set("data", s), d.setStyle(
812
+ new Style({
813
+ image: new CircleStyle({
814
+ fill: new Fill({ color: e }),
815
+ stroke: new Stroke({ color: "#fff", width: 2 }),
816
+ radius: 3
817
+ })
818
+ })
819
+ ), trackLineVectorSource.value.addFeature(d);
820
+ const m = new Feature({
821
+ geometry: new Point(fromLonLat(s.center))
822
+ });
823
+ if (m.set("type", "track_label"), m.set("track_label_index", c), m.setStyle(
824
+ setTrackLabelStyle(s, e)
825
+ ), trackLineVectorSource.value.addFeature(m), typeof s == "object" && s.hasOwnProperty("state")) {
826
+ let p = new Feature({
827
+ geometry: new Point(s.centerPoint)
828
+ });
829
+ p.set("type", "track_icon");
830
+ let y = new Style({
831
+ text: new Text({
832
+ font: "Normal 22px map-iconfont",
833
+ text: getIconFont(dropletsIcon),
834
+ offsetY: -10
835
+ }),
836
+ zIndex: 99
837
+ }), h = [];
838
+ s.state === "0" ? ((u = y.getText()) == null || u.setFill(new Fill({ color: stopColor })), h.push(l)) : ((f = y.getText()) == null || f.setFill(new Fill({ color: slowColor })), h.push(i)), h.push(y), p.setStyle(h), trackLineVectorSource.value.addFeature(p);
839
+ }
840
+ }), renderArrow(n, e), renderIconPoint();
841
+ }, renderArrow = (e, t) => {
842
+ const o = e.length;
843
+ o || (e.push(trackList$1.value[0]), e.push(trackList$1.value[trackList$1.value.length - 1]));
844
+ for (let n = 0; n < o - 1; n++) {
845
+ let r, l = e[n], i = (e[n + 1].index + l.index) / 2;
846
+ if (i % 2 === 0)
847
+ r = trackList$1.value[i].centerPoint;
848
+ else {
849
+ let s = trackList$1.value[Math.floor(i)], c = trackList$1.value[Math.ceil(i)];
850
+ if (s && c) {
851
+ let [d, m] = s.centerPoint, [u, f] = c.centerPoint;
852
+ r = [(d + u) / 2, (m + f) / 2];
853
+ }
854
+ }
855
+ if (r) {
856
+ let s = new Feature({
857
+ geometry: new Point(r)
858
+ });
859
+ s.set("type", "track_arrow"), s.setStyle(
860
+ new Style({
861
+ text: new Text({
862
+ font: "700 14px map-iconfont",
863
+ text: getIconFont("&#xe6bc;"),
864
+ fill: new Fill({ color: t }),
865
+ // 设置箭头旋转 角度转为弧度
866
+ rotation: getRotation(
867
+ e[n].center,
868
+ e[n + 1].center
869
+ ) * (Math.PI / 180)
870
+ })
871
+ })
872
+ ), trackLineVectorSource.value.addFeature(s);
873
+ }
874
+ }
875
+ }, renderIconPoint = () => {
876
+ const e = "&#xe69b;", t = "#fcdc3f", o = "#ff0000";
877
+ (trackList$1.value.length < 2 ? [trackList$1.value[0]] : [trackList$1.value[0], trackList$1.value[trackList$1.value.length - 1]]).forEach((r) => {
878
+ let l = new Feature({
879
+ geometry: new Point(r.centerPoint)
880
+ });
881
+ l.set("type", "track_begin"), l.set("data", r);
882
+ const i = r.index === 0 && trackList$1.value.length >= 2 ? t : o;
883
+ l.setStyle(
884
+ new Style({
885
+ text: new Text({
886
+ font: "Normal 14px map-iconfont",
887
+ text: getIconFont(e),
888
+ fill: new Fill({ color: i })
889
+ }),
890
+ zIndex: 101
891
+ })
892
+ ), trackLineVectorSource.value.addFeature(l);
893
+ });
894
+ }, setTrackLabelStyle = (e, t) => new Style({
895
+ renderer: (o, n) => {
896
+ const r = n.context, s = {
897
+ center: o,
898
+ text: e.time,
899
+ color: t,
900
+ textColor: "#000",
901
+ bgColor: "rgba(255,255,255,.8)",
902
+ selected: !0,
903
+ type: "TrackTime"
904
+ };
905
+ drawLabel(r, s, trackLabels.value);
906
+ }
907
+ }), triangleModel = multiplyPixelRatio([
908
+ [0, -8],
909
+ [5, 8],
910
+ [-5, 8]
911
+ ]), shipShapeModel = multiplyPixelRatio([
912
+ [0, -4.545],
913
+ [-0.56, -3.909],
914
+ [-1, -2.727],
915
+ [-1, 3.636],
916
+ [-0.8, 4.545],
917
+ [0.8, 4.545],
918
+ [1, 3.636],
919
+ [1, -2.727],
920
+ [0.56, -3.909],
921
+ [0, -4.545]
922
+ ]), shipDirectPath = {
923
+ left: {
924
+ 0: [
925
+ [0, 0],
926
+ [0, -8],
927
+ [-4, -8]
928
+ ],
929
+ 1: [
930
+ [0, 0],
931
+ [0, -16],
932
+ [-6, -16]
933
+ ],
934
+ 2: [
935
+ [0, 0],
936
+ [0, -24],
937
+ [-8, -24]
938
+ ]
939
+ },
940
+ right: {
941
+ 0: [
942
+ [0, 0],
943
+ [0, -8],
944
+ [-4, -8]
945
+ ],
946
+ 1: [
947
+ [0, 0],
948
+ [0, -16],
949
+ [-6, -16]
950
+ ],
951
+ 2: [
952
+ [0, 0],
953
+ [0, -24],
954
+ [-8, -24]
955
+ ]
956
+ },
957
+ front: {
958
+ 0: [
959
+ [0, 0],
960
+ [0, -8]
961
+ ],
962
+ 1: [
963
+ [0, 0],
964
+ [0, -16]
965
+ ],
966
+ 2: [
967
+ [0, 0],
968
+ [0, -24]
969
+ ]
970
+ }
971
+ }, setBlankStyle = () => new Style({
972
+ image: new CircleStyle({
973
+ radius: 0
974
+ })
975
+ }), mapInstance$7 = ref(), renderShipStyleSetInstance = (e) => mapInstance$7.value = e, speedCondition = [[1, 10], [10, 20], [20, 1 / 0]], drawShipModelByZoom = { 14: [200, 30], 15: [115, 15], 16: [55, 8], 17: [25, 5], 18: [1, 1] }, setShipStyle = (e) => new Style({
976
+ renderer: (t, o) => {
977
+ const n = o.context, r = o.feature.get("data");
978
+ o.feature.get("index") === 0 && (shipLabels.value = []);
979
+ try {
980
+ const i = drawShipBody(n, r, t);
981
+ i && (drawHeading(n, r, i), e && (drawSelectBounds(n, i), r.selected = !0)), drawShipLabel(n, r, t);
982
+ } catch {
983
+ return !1;
984
+ }
985
+ }
986
+ }), drawShipBody = (e, t, o) => {
987
+ if (!mapInstance$7.value) return;
988
+ const n = Math.round(Number(mapInstance$7.value.getView().getZoom()));
989
+ if (!n) return;
990
+ let r = [];
991
+ const [l, i] = drawShipModelByZoom[n] || [0, 0], [s, c] = o;
992
+ if (n <= mapZoom.shipModelMax && n > mapZoom.shipModelMin && t.length >= l && t.breadth >= i)
993
+ r = rotateShapeModel(drawCurrentShipShapeModel(t, n), t.angle).map((m) => {
994
+ const [u, f] = m;
995
+ return [s + u, c + f];
996
+ });
997
+ else {
998
+ const d = rotateShapeModel(triangleModel, t.angle);
999
+ o.length === 2 && (r = d.map((m) => {
1000
+ const [u, f] = m;
1001
+ return [s + u, c + f];
1002
+ }));
1003
+ }
1004
+ if (!(r.length > 2)) return !1;
1005
+ e.save(), e.beginPath(), e.moveTo(r[0][0], r[0][1]);
1006
+ for (let d = 1; d < r.length; d++)
1007
+ e.lineTo(r[d][0], r[d][1]);
1008
+ return e.closePath(), e.strokeStyle = "#000", e.lineWidth = 1, e.stroke(), e.fillStyle = t.fill, e.fill(), e.restore(), r;
1009
+ }, drawHeading = (e, t, o) => {
1010
+ const [n, r] = o[0], l = getShipDirectPath(t);
1011
+ if (l) {
1012
+ let i = l.map(function(s) {
1013
+ let [c, d] = s;
1014
+ return [c + n, d + r];
1015
+ });
1016
+ if (e.save(), e.beginPath(), t.angle > 0) {
1017
+ e.translate(n, r);
1018
+ const s = t.angle * Math.PI / 180;
1019
+ e.rotate(s), e.translate(-n, -r);
1020
+ }
1021
+ e.moveTo(n, r);
1022
+ for (let s = 1; s < i.length; s++) {
1023
+ let [c, d] = i[s];
1024
+ e.lineTo(c, d);
1025
+ }
1026
+ e.strokeStyle = "#000", e.lineWidth = 1, e.stroke(), e.restore();
1027
+ }
1028
+ }, drawSelectBounds = (e, t) => {
1029
+ let [o, n, r, l] = getPixelFromCoordinate(t);
1030
+ const i = 4;
1031
+ o -= i, n -= i, r += i, l += i, e.save(), e.strokeStyle = "#ff0000", e.lineWidth = 4;
1032
+ const s = 8;
1033
+ e.beginPath(), e.moveTo(o + s, l), e.lineTo(o, l), e.lineTo(o, l - s), e.moveTo(o, n + s), e.lineTo(o, n), e.lineTo(o + s, n), e.moveTo(r - s, n), e.lineTo(r, n), e.lineTo(r, n + s), e.moveTo(r, l - s), e.lineTo(r, l), e.lineTo(r - s, l), e.stroke(), e.restore();
1034
+ }, drawShipLabel = (e, t, o) => {
1035
+ const [n, r] = o, l = n - 0, i = r - 0, s = t.name;
1036
+ let c;
1037
+ t.leftIconColor && (c = { color: t.leftIconColor, icon: "&#xe599;" });
1038
+ let d = getShipCustomIcon(t);
1039
+ const m = {
1040
+ center: [l, i],
1041
+ text: s,
1042
+ color: "#fff",
1043
+ textColor: "#000",
1044
+ bgColor: "#fff",
1045
+ leftIcon: c,
1046
+ rightIcons: d,
1047
+ selected: t.selected,
1048
+ type: "ShipName"
1049
+ };
1050
+ drawLabel(e, m, shipLabels.value);
1051
+ }, drawCurrentShipShapeModel = (e, t) => {
1052
+ let o = 0;
1053
+ t <= 14 ? o = 0.058 : t === 15 ? o = 0.12 : t === 16 ? o = 0.22 : t === 17 ? o = 0.435 : t === 18 && (o = 0.857);
1054
+ const n = e.length / 4 * o, r = e.breadth * o;
1055
+ let l = cloneDeep(shipShapeModel);
1056
+ return l = l.map(([i, s]) => [i * r, s * n]), l;
1057
+ }, getShipDirectPath = (e) => {
1058
+ let { speed: t, hdg: o, cog: n } = e, r = "", l = null;
1059
+ if (t && t > 1 && (o !== null && o != 511 && n !== null ? n - o >= 3 ? r = "left" : n - o <= -3 ? r = "right" : r = "front" : r = "front", r && t))
1060
+ for (let i in speedCondition) {
1061
+ let s = speedCondition[i];
1062
+ if (t >= s[0] && t < s[1]) {
1063
+ l = shipDirectPath[r][i];
1064
+ break;
1065
+ }
1066
+ }
1067
+ return l;
1068
+ }, getShipCustomIcon = (e) => {
1069
+ let t = [];
1070
+ return e.existDevice && t.push("&#xe687;"), e.existMobile && t.push("&#xe688;"), e.existWaterGauge && t.push("&#xe686;"), t || [];
1071
+ }, mapInstance$6 = ref(), renderShipSetInstance = (e) => mapInstance$6.value = e;
1072
+ let shipsMarkerList = [], shipsVectorSource, largeAmountShipsSource;
1073
+ const selectedShipData = ref(null);
1074
+ let selectShipsVectorSource;
1075
+ const renderShips = (e) => {
1076
+ var o, n, r, l;
1077
+ if (!mapInstance$6.value || showTrackLayer.value) return;
1078
+ const t = Math.round(Number(mapInstance$6.value.getView().getZoom()));
1079
+ if (selectedShipData.value && nextTick(() => {
1080
+ selectSingleShipMarker(selectedShipData.value);
1081
+ }).then((i) => {
1082
+ }), !(!t || t < mapZoom.shipGreenDotMax) && (allShips.value = e, !hiddenOrther.value))
1083
+ return t >= mapZoom.shipGreenDotMax && t < mapZoom.shipModelMin || e.length > renderShipsLimit ? ((o = shipsLayer.value) == null || o.setVisible(!1), (n = largeAmountShipsLayer.value) == null || n.setVisible(!0), renderLargeAmountShips(e)) : ((r = largeAmountShipsLayer.value) == null || r.setVisible(!1), (l = shipsLayer.value) == null || l.setVisible(!0), renderShipsMarker(e));
1084
+ }, renderLargeAmountShips = (e) => {
1085
+ if (!mapInstance$6.value) return;
1086
+ const t = e.map((n) => ({
1087
+ type: "Feature",
1088
+ geometry: {
1089
+ type: "Point",
1090
+ coordinates: [n.lon, n.lat]
1091
+ },
1092
+ properties: n
1093
+ }));
1094
+ largeAmountShipsSource == null || largeAmountShipsSource.clear(), largeAmountShipsSource = new VectorSource({
1095
+ features: new GeoJSON().readFeatures({
1096
+ type: "FeatureCollection",
1097
+ features: t
1098
+ }, {
1099
+ featureProjection: projection.mercator
1100
+ })
1101
+ });
1102
+ const o = [
1103
+ "case",
1104
+ ["==", ["get", "existMobile"], 1],
1105
+ // 假设 type1 对应红色
1106
+ "#D9001C",
1107
+ "#04C900"
1108
+ ];
1109
+ return largeAmountShipsLayer.value = new WebGLPointsLayer({
1110
+ source: largeAmountShipsSource,
1111
+ style: {
1112
+ "shape-points": 3,
1113
+ "shape-radius": 9,
1114
+ "shape-fill-color": o,
1115
+ // 'shape-fill-color': ['get', 'data.fill'],
1116
+ "shape-rotate-with-view": !1,
1117
+ "shape-rotation": [
1118
+ "+",
1119
+ ["get", "cog"],
1120
+ // 获取 'cog' 属性值
1121
+ 180
1122
+ // 将值旋转 180 度
1123
+ ],
1124
+ "shape-scale": [0.8, 1.2],
1125
+ "shape-stroke-color": "#000000",
1126
+ // 边框颜色为黑色
1127
+ "shape-stroke-width": 0.5
1128
+ // 边框宽度为0.5px
1129
+ }
1130
+ }), mapInstance$6.value.addLayer(largeAmountShipsLayer.value), largeAmountShipsLayer.value;
1131
+ }, renderShipsMarker = (e) => {
1132
+ if (!mapInstance$6.value) return;
1133
+ deleteAllShipMarkers();
1134
+ let t = convertShipMapData(e);
1135
+ if (t = customFilterShips(t), !!(t != null && t.length))
1136
+ return t.forEach((o, n) => {
1137
+ const r = [o.lon, o.lat], l = new Feature({
1138
+ geometry: new Point(fromLonLat(r))
1139
+ });
1140
+ l.set("data", o), l.set("index", n), l.setStyle(
1141
+ setShipStyle(!1, o.id)
1142
+ ), shipsMarkerList.push({
1143
+ ship: o,
1144
+ lonlat: r,
1145
+ feature: l
1146
+ });
1147
+ }), shipsVectorSource = new VectorSource({
1148
+ features: shipsMarkerList.map((o) => o.feature)
1149
+ }), shipsLayer.value = new VectorLayer({
1150
+ source: shipsVectorSource
1151
+ }), mapInstance$6.value.addLayer(shipsLayer.value), shipsLayer.value;
1152
+ }, customFilterShips = (e) => {
1153
+ let t = cloneDeep(e);
1154
+ return t = t.filter((o) => {
1155
+ var r;
1156
+ let n = getFilterItem(o).every(({ btnShow: l, value: i }) => l ? !!i : !0);
1157
+ return (switchBtnShow.value.camera || switchBtnShow.value.mobile || switchBtnShow.value.waterGauge) && ((r = selectedShipData.value) == null ? void 0 : r.id) === o.id && clearSelectFeature(), n;
1158
+ }), t;
1159
+ }, getFilterItem = (e) => [
1160
+ { btnShow: switchBtnShow.value.camera, value: e == null ? void 0 : e.existDevice },
1161
+ { btnShow: switchBtnShow.value.mobile, value: e == null ? void 0 : e.existMobile },
1162
+ { btnShow: switchBtnShow.value.waterGauge, value: e == null ? void 0 : e.existWaterGauge }
1163
+ ], deleteAllShipMarkers = () => {
1164
+ shipsMarkerList.forEach((e) => {
1165
+ e.feature && (shipsVectorSource == null || shipsVectorSource.removeFeature(e.feature));
1166
+ }), shipsMarkerList = [];
1167
+ }, selectSingleShipMarker = (e) => {
1168
+ var l;
1169
+ if (!mapInstance$6.value) return;
1170
+ const t = cloneDeep(selectSingleShipData.value);
1171
+ selectSingleShipData.value = convertShipMapData(e);
1172
+ const o = [selectSingleShipData.value.lon, selectSingleShipData.value.lat], n = new Feature({
1173
+ geometry: new Point(fromLonLat(o))
1174
+ });
1175
+ n.set("data", selectSingleShipData.value), n.setStyle(
1176
+ setShipStyle(!0)
1177
+ ), shipsMarkerList.push({
1178
+ ship: selectSingleShipData.value,
1179
+ lonlat: o,
1180
+ feature: n
1181
+ }), selectShipsVectorSource == null || selectShipsVectorSource.clear(), selectShipsVectorSource = new VectorSource({
1182
+ features: [n]
1183
+ }), selectShipsLayer.value = new VectorLayer({
1184
+ source: selectShipsVectorSource
1185
+ }), setVisibleFeatureById(shipsVectorSource, selectSingleShipData.value.id, !0);
1186
+ const r = (l = shipsLayer.value) == null ? void 0 : l.getSource();
1187
+ return r && (t && setVisibleFeatureById(r, t.id, !0), setVisibleFeatureById(r, selectSingleShipData.value.id, !1)), mapInstance$6.value.addLayer(selectShipsLayer.value), selectShipsLayer.value.setVisible(!0), selectShipsLayer.value;
1188
+ }, setVisibleFeatureById = (e, t, o) => {
1189
+ e && e.forEachFeature((n) => {
1190
+ const r = n.get("data");
1191
+ r && r.id === t && n.setStyle(o ? setShipStyle(!1, r.id) : setBlankStyle());
1192
+ });
1193
+ }, findShip = (e, t, o = !0) => {
1194
+ var r, l, i, s, c;
1195
+ if (console.log(mapInstance$6.value.ol_uid), !e || !mapInstance$6.value) return;
1196
+ const n = (i = (l = (r = shipsLayer.value) == null ? void 0 : r.getSource()) == null ? void 0 : l.getFeatures()) == null ? void 0 : i.find((d) => {
1197
+ var m;
1198
+ return ((m = d.get("data")) == null ? void 0 : m.id) === e;
1199
+ });
1200
+ if (n ? selectedShipData.value = n.get("data") : t && (selectedShipData.value = t), !t) {
1201
+ console.error("找不到船舶");
1202
+ return;
1203
+ }
1204
+ if (o && ((s = selectedShipData.value) != null && s.lon) && ((c = selectedShipData.value) != null && c.lat)) {
1205
+ const d = mapInstance$6.value.getView(), m = new Point([selectedShipData.value.lon, selectedShipData.value.lat]);
1206
+ d.setCenter(transform(m.getCoordinates(), projection.data, projection.mercator));
1207
+ const u = d.getZoom(), f = u < mapZoom.findShipMin ? mapZoom.findShip : u;
1208
+ d.setZoom(f);
1209
+ }
1210
+ return selectSingleShipMarker(t), n;
1211
+ }, clearSelectFeature = () => {
1212
+ var e;
1213
+ if (selectedShipData.value) {
1214
+ setVisibleFeatureById(shipsVectorSource, selectSingleShipData.value.id, !1);
1215
+ const t = (e = shipsLayer.value) == null ? void 0 : e.getSource();
1216
+ t && setVisibleFeatureById(t, selectSingleShipData.value.id, !0);
1217
+ }
1218
+ selectedShipData.value = null, mapInstance$6.value && (selectShipsVectorSource == null || selectShipsVectorSource.clear(), selectShipsLayer.value = new VectorLayer({
1219
+ source: selectShipsVectorSource
1220
+ }), mapInstance$6.value.addLayer(selectShipsLayer.value), selectShipsLayer.value.setVisible(!1));
1221
+ }, hiddenAllShips = () => {
1222
+ var e, t;
1223
+ (e = shipsLayer.value) == null || e.setVisible(!1), (t = largeAmountShipsLayer.value) == null || t.setVisible(!1);
1224
+ }, switchBtnShow = ref({
1225
+ // 船舶摄像头过滤开关
1226
+ [SWITCH_BTN.Camera]: !1,
1227
+ // 船舶联系方式过滤开关
1228
+ [SWITCH_BTN.Mobile]: !1,
1229
+ // 船舶水尺过滤开关
1230
+ [SWITCH_BTN.WaterGauge]: !1
1231
+ }), switchFilterItem = (e, t) => {
1232
+ switchBtnShow.value[e] = t, renderShips(allShips.value);
1233
+ }, rerenderShip = () => {
1234
+ renderShips(allShips.value);
1235
+ }, mapInstance$5 = ref(), renderTrackSetInstance = (e) => mapInstance$5.value = e, showTracks = ref([]), trackList = ref([]);
1236
+ ref(null);
1237
+ const trackId = ref(""), cursor = ref(0), renderTrack = (e, t, o, n, r = "ship") => {
1238
+ var m;
1239
+ if (nextTick(() => {
1240
+ hiddenAllShips();
1241
+ }).then((u) => {
1242
+ }), (t == null ? void 0 : t.length) < 2) {
1243
+ ((m = showTracks.value) == null ? void 0 : m.findIndex((u) => u.id === e)) < 0 && showTracks.value.push({ id: e, length: "" });
1244
+ return;
1245
+ }
1246
+ let l = {};
1247
+ t.forEach((u) => {
1248
+ u.state ? u.state = Number(u.state) : delete u.state;
1249
+ }), trackId.value = e, l[e] = t, trackList.value = t;
1250
+ const i = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], s = l[e].map(
1251
+ (u) => transform([u.lon, u.lat], projection.data, projection.mercator)
1252
+ ), c = new LineString(s), d = formatUtils.formatLength(c, n) || "--";
1253
+ nextTick(() => {
1254
+ var f, p;
1255
+ const u = (f = showTracks.value) == null ? void 0 : f.findIndex((y) => y.id === e);
1256
+ u < 0 ? showTracks.value.push({ id: e, length: d }) : showTracks.value[u].length = d, ++cursor.value, cursor.value > i.length && (cursor.value = 0), renderTrackLine(l, e, o), nextTick(() => {
1257
+ resetTrackView(e);
1258
+ }).then(() => {
1259
+ }), (p = mapInstance$5.value) == null || p.on("moveend", () => {
1260
+ showTrackLayer.value && (trackLabels.value = [], renderTrackLine(l, e, o));
1261
+ });
1262
+ }).then(() => {
1263
+ });
1264
+ }, removeAllTrackLayer = () => {
1265
+ var e;
1266
+ showTracks.value = [], (e = trackLineVectorSource.value) == null || e.clear();
1267
+ }, playTrack = (e, t) => {
1268
+ handlePlay(String(e), t);
1269
+ }, resetTrackView = (e) => {
1270
+ var r;
1271
+ const t = mapInstance$5.value.getView(), o = e ? shipTrackLineFeatures.value.find((l) => l.getId() === e) : shipTrackLineFeatures.value[0];
1272
+ if (!o) return;
1273
+ const n = (r = o == null ? void 0 : o.getGeometry()) == null ? void 0 : r.getExtent();
1274
+ if (n != null && n.length)
1275
+ try {
1276
+ const l = buffer(n, Math.max(n[2] - n[0], n[3] - n[1]) * 0.02);
1277
+ t.fit(l);
1278
+ } catch (l) {
1279
+ console.log(l);
1280
+ }
1281
+ }, _hoisted_1$3 = {
1282
+ key: 0,
1283
+ class: "more-tool-panel"
1284
+ }, _hoisted_2$1 = { class: "switch-buttons" }, _hoisted_3$1 = { class: "tool-components" }, _sfc_main$4 = /* @__PURE__ */ defineComponent({
1285
+ __name: "toolPanel",
1286
+ props: {
1287
+ vehicleMode: {},
1288
+ viewMode: {},
1289
+ disableGreenDot: { type: Boolean },
1290
+ showTrackLayer: { type: Boolean },
1291
+ mapTileMode: {}
1292
+ },
1293
+ emits: ["switchGreenDot", "switchMapTile"],
1294
+ setup(e, { emit: t }) {
1295
+ var p, y;
1296
+ const o = inject("mapInstance"), n = e, r = t, l = ref(((y = (p = o.value) == null ? void 0 : p.getView()) == null ? void 0 : y.getZoom()) || mapZoom.default), i = ref(!1), s = ref(null), c = ref(!0), d = () => {
1297
+ n.disableGreenDot || l.value >= mapZoom.shipGreenDotMax || (c.value = !c.value, r("switchGreenDot", c.value));
1298
+ }, m = () => {
1299
+ r("switchMapTile", n.mapTileMode === BaseMapType.vector ? BaseMapType.satellite : BaseMapType.vector);
1300
+ }, u = () => {
1301
+ var h, g;
1302
+ i.value ? (h = s.value) == null || h.removeInteraction() : (g = s.value) == null || g.addInteraction(), i.value = !i.value;
1303
+ }, f = () => {
1304
+ var h;
1305
+ (h = s.value) == null || h.removeInteraction(), i.value = !1;
1306
+ };
1307
+ return onMounted(() => {
1308
+ nextTick(() => {
1309
+ var h;
1310
+ (h = o.value) == null || h.on("moveend", () => {
1311
+ var L, T;
1312
+ const g = (T = (L = o.value) == null ? void 0 : L.getView()) == null ? void 0 : T.getZoom();
1313
+ g && (l.value = g);
1314
+ });
1315
+ });
1316
+ }), (h, g) => (openBlock(), createElementBlock(Fragment, null, [
1317
+ createElementVNode("div", {
1318
+ class: normalizeClass(`tool-panel ${h.viewMode}`)
1319
+ }, [
1320
+ h.viewMode === "WxMiniprogram" ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
1321
+ createElementVNode("div", _hoisted_2$1, [
1322
+ h.vehicleMode === "ship" ? (openBlock(), createElementBlock("div", {
1323
+ key: 0,
1324
+ class: normalizeClass(["switch-btn", `${i.value && "active"}`]),
1325
+ onClick: u
1326
+ }, g[5] || (g[5] = [
1327
+ createElementVNode("i", { class: "map-iconfont icon-measure" }, null, -1),
1328
+ createElementVNode("div", { class: "button-text" }, "测距", -1)
1329
+ ]), 2)) : createCommentVNode("", !0),
1330
+ h.vehicleMode === "ship" ? (openBlock(), createElementBlock("div", {
1331
+ key: 1,
1332
+ class: normalizeClass(`switch-btn ${c.value && "active"} ${(h.disableGreenDot || l.value >= unref(mapZoom).shipGreenDotMax) && "disabled"}`),
1333
+ onClick: d
1334
+ }, g[6] || (g[6] = [
1335
+ createElementVNode("i", { class: "map-iconfont icon-ship" }, null, -1),
1336
+ createElementVNode("div", { class: "button-text" }, "绿点", -1)
1337
+ ]), 2)) : createCommentVNode("", !0),
1338
+ h.vehicleMode === "ship" ? (openBlock(), createElementBlock("div", {
1339
+ key: 2,
1340
+ class: normalizeClass(`switch-btn ${h.mapTileMode === unref(BaseMapType).satellite && "active"}`),
1341
+ onClick: g[0] || (g[0] = (L) => m())
1342
+ }, g[7] || (g[7] = [
1343
+ createElementVNode("i", { class: "map-iconfont icon-space" }, null, -1),
1344
+ createElementVNode("div", { class: "button-text" }, "图层", -1)
1345
+ ]), 2)) : createCommentVNode("", !0),
1346
+ h.vehicleMode === "truck" ? (openBlock(), createElementBlock("div", {
1347
+ key: 3,
1348
+ class: normalizeClass(`switch-btn ${h.mapTileMode === unref(BaseMapType).satellite && "active"}`),
1349
+ onClick: g[1] || (g[1] = (L) => m())
1350
+ }, g[8] || (g[8] = [
1351
+ createElementVNode("i", { class: "map-iconfont icon-space" }, null, -1),
1352
+ createElementVNode("div", { class: "button-text" }, "卫星", -1)
1353
+ ]), 2)) : createCommentVNode("", !0),
1354
+ h.showTrackLayer ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
1355
+ createElementVNode("div", {
1356
+ class: "switch-btn multiple",
1357
+ onClick: g[2] || (g[2] = (L) => unref(playTrack)(unref(currentTrackId), 1))
1358
+ }, g[9] || (g[9] = [
1359
+ createElementVNode("i", { class: "map-iconfont icon-play" }, null, -1),
1360
+ createElementVNode("div", { class: "button-text" }, "播放轨迹", -1)
1361
+ ])),
1362
+ createElementVNode("div", {
1363
+ class: "switch-btn multiple",
1364
+ onClick: g[3] || (g[3] = (L) => unref(resetTrackView)())
1365
+ }, g[10] || (g[10] = [
1366
+ createElementVNode("i", { class: "map-iconfont icon-center" }, null, -1),
1367
+ createElementVNode("div", { class: "button-text" }, "轨迹居中", -1)
1368
+ ]))
1369
+ ], 64)) : createCommentVNode("", !0),
1370
+ renderSlot(h.$slots, "toolPanel", {}, void 0, !0)
1371
+ ])
1372
+ ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1373
+ h.vehicleMode === "ship" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1374
+ createElementVNode("div", {
1375
+ class: normalizeClass(["switch-btn", `${i.value && "active"}`]),
1376
+ onClick: u
1377
+ }, g[11] || (g[11] = [
1378
+ createElementVNode("i", { class: "map-iconfont icon-measure" }, null, -1),
1379
+ createElementVNode("div", { class: "button-text" }, "测距", -1)
1380
+ ]), 2),
1381
+ h.vehicleMode === "ship" ? (openBlock(), createElementBlock("div", {
1382
+ key: 0,
1383
+ class: normalizeClass(`switch-btn ${c.value && "active"} ${(h.disableGreenDot || l.value >= unref(mapZoom).shipGreenDotMax) && "disabled"}`),
1384
+ onClick: d
1385
+ }, g[12] || (g[12] = [
1386
+ createElementVNode("i", { class: "map-iconfont icon-ship" }, null, -1),
1387
+ createElementVNode("div", { class: "button-text" }, "绿点", -1)
1388
+ ]), 2)) : createCommentVNode("", !0)
1389
+ ], 64)) : createCommentVNode("", !0),
1390
+ createElementVNode("div", {
1391
+ class: normalizeClass(["switch-btn", { active: h.mapTileMode === unref(BaseMapType).satellite }]),
1392
+ onClick: m
1393
+ }, g[13] || (g[13] = [
1394
+ createElementVNode("i", { class: "map-iconfont icon-space" }, null, -1),
1395
+ createElementVNode("div", { class: "button-text" }, "卫星", -1)
1396
+ ]), 2)
1397
+ ], 64))
1398
+ ], 2),
1399
+ createElementVNode("div", _hoisted_3$1, [
1400
+ i.value ? (openBlock(), createBlock(Measure, {
1401
+ key: 0,
1402
+ ref_key: "measureRef",
1403
+ ref: s,
1404
+ visible: i.value,
1405
+ "onUpdate:visible": g[4] || (g[4] = (L) => i.value = L),
1406
+ onClose: f,
1407
+ "view-mode": h.viewMode
1408
+ }, null, 8, ["visible", "view-mode"])) : createCommentVNode("", !0)
1409
+ ])
1410
+ ], 64));
1411
+ }
1412
+ }), ToolPanel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-ef931f65"]]), _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
1413
+ __name: "scaleLine",
1414
+ setup(e, { expose: t }) {
1415
+ const o = inject("mapInstance");
1416
+ return t({
1417
+ setScaleLine: (r) => {
1418
+ var s;
1419
+ const l = new ScaleLine$1({
1420
+ units: r || "metric"
1421
+ }), i = document.getElementById("scale-line-container");
1422
+ i && (l.setTarget(i), (s = o.value) == null || s.addControl(l));
1423
+ }
1424
+ }), (r, l) => (openBlock(), createElementBlock("div", _hoisted_1$2));
1425
+ }
1426
+ }), ScaleLine = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-46a928b4"]]), _hoisted_1$1 = { class: "zoom" }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
1427
+ __name: "zoomControl",
1428
+ props: {
1429
+ map: {
1430
+ type: Object
1431
+ }
1432
+ },
1433
+ setup(e) {
1434
+ const t = inject("mapInstance"), o = () => {
1435
+ if (!t.value) return;
1436
+ const r = t.value.getView(), l = r.getZoom();
1437
+ l && r.setZoom(l + 1);
1438
+ }, n = () => {
1439
+ if (!t.value) return;
1440
+ const r = t.value.getView(), l = r.getZoom();
1441
+ l && r.setZoom(l - 1);
1442
+ };
1443
+ return (r, l) => (openBlock(), createElementBlock("div", _hoisted_1$1, [
1444
+ createElementVNode("div", {
1445
+ onClick: o,
1446
+ class: "button big-button"
1447
+ }, "+"),
1448
+ createElementVNode("div", {
1449
+ onClick: n,
1450
+ class: "button small-button"
1451
+ }, "-")
1452
+ ]));
1453
+ }
1454
+ }), ZoomControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-602b1c0f"]]), _hoisted_1 = { class: "copyright" }, _hoisted_2 = { class: "tdt-control-copyright tdt-control" }, _hoisted_3 = ["src"], _sfc_main$1 = /* @__PURE__ */ defineComponent({
1455
+ __name: "copyright",
1456
+ setup(e) {
1457
+ return (t, o) => (openBlock(), createElementBlock("div", _hoisted_1, [
1458
+ createElementVNode("div", _hoisted_2, [
1459
+ createElementVNode("img", {
1460
+ src: unref(CDN_URL) + "map/tdt-logo.png",
1461
+ width: "53px",
1462
+ height: "22px",
1463
+ class: "logo",
1464
+ alt: ""
1465
+ }, null, 8, _hoisted_3),
1466
+ o[0] || (o[0] = createElementVNode("div", { class: "copyright-text" }, "GS(2024)0568号 - 甲测资字1100471", -1))
1467
+ ]),
1468
+ o[1] || (o[1] = createElementVNode("div", {
1469
+ id: "dataSource",
1470
+ class: "tdt-control data-source"
1471
+ }, "数据来源:自然资源部 & NavInfo", -1))
1472
+ ]));
1473
+ }
1474
+ }), Copyright = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9c5c2f7b"]]), dotImage = new Image();
1475
+ dotImage.src = `${CDN_URL}/map/truck-dot.svg`;
1476
+ dotImage.crossOrigin = "anonymous";
1477
+ const dotActiveImage = new Image();
1478
+ dotActiveImage.src = `${CDN_URL}/map/truck-dot-active.svg`;
1479
+ dotActiveImage.crossOrigin = "anonymous";
1480
+ const cameraImage = new Image();
1481
+ cameraImage.src = `${CDN_URL}/map/map-camera.svg`;
1482
+ cameraImage.crossOrigin = "anonymous";
1483
+ const loadImage = new Image();
1484
+ loadImage.src = `${CDN_URL}/map/map-load.svg`;
1485
+ loadImage.crossOrigin = "anonymous";
1486
+ const setTruckStyle = (e, t, o, n) => new Style({
1487
+ renderer: (r, l) => {
1488
+ const i = l.context;
1489
+ i.save();
1490
+ let s = 1;
1491
+ i.scale(s, s);
1492
+ let [c, d] = r;
1493
+ c = c / s - 20, d = d / s;
1494
+ const m = c - 70, u = d - 68;
1495
+ let f = 180;
1496
+ const p = 56, y = "#FFFFFF";
1497
+ let h = 176;
1498
+ const g = 52;
1499
+ let L = "#164AFF", T = "#FFFFFF";
1500
+ o === CAR_COLOR.YELLOW ? (h = 176, L = "#FFC81E", T = "rgba(0,0,0,0.88)") : o === CAR_COLOR.Y_GREEN && (f = 200, h = 196, L = "#8FED7C", T = "rgba(0,0,0,0.88)"), n != null && n.length && (f += n.length * 56), fillRectRadius(i, m, u, f, p, y), fillRectRadius(i, m + 2, u + 2, h, g, L), o === CAR_COLOR.Y_GREEN && fillRectRadius(i, m + 2, u + 2, 68, g, "#FFC81E"), i.save(), i.restore(), i.fillStyle = T, i.font = "bold 28px Arial", i.textAlign = "left", i.textBaseline = "middle";
1501
+ const b = `${t.slice(0, 2) + " · " + t.slice(2)}`;
1502
+ if (i.fillText(b, m + 12, u + 32), i.save(), i.restore(), n != null && n.length) {
1503
+ const F = i.measureText(b).width + 12;
1504
+ let v = 0;
1505
+ n.forEach((S) => {
1506
+ S === DEVICE_TYPE.CAMERA && (i.drawImage(cameraImage, c - 54 + F + v * 56, d - 64, 50, 50), ++v), S === DEVICE_TYPE.LOAD && (i.drawImage(loadImage, c - 54 + F + v * 56, d - 64, 50, 50), ++v);
1507
+ });
1508
+ }
1509
+ const C = dotImage;
1510
+ i.drawImage(C, c + f / 2 - 90, d, 50 / s, 50 / s), i.restore();
1511
+ }
1512
+ }), mapInstance$4 = ref(), renderDashboardSetInstance = (e) => mapInstance$4.value = e;
1513
+ ref([]);
1514
+ let truckMarkerList = [], trucksVectorSource;
1515
+ const renderTrucksMarker = (e) => {
1516
+ if (deleteAllTruckMarkers(), !!mapInstance$4.value)
1517
+ return e.forEach((t) => {
1518
+ const o = formatUtils.convertSixHundredThousandToLatLng(t.lon, t.lat), n = new Feature({
1519
+ geometry: new Point(fromLonLat(o))
1520
+ });
1521
+ n.set("data", t), n.setStyle(
1522
+ setTruckStyle(!1, t.vno, t == null ? void 0 : t.vclColor, t == null ? void 0 : t.icons)
1523
+ ), truckMarkerList.push({
1524
+ name: t.vno,
1525
+ lonlat: o,
1526
+ feature: n
1527
+ });
1528
+ }), trucksVectorSource = new VectorSource({
1529
+ features: truckMarkerList.map((t) => t.feature)
1530
+ }), trucksLayer.value = new VectorLayer({
1531
+ source: trucksVectorSource
1532
+ }), mapInstance$4.value.addLayer(trucksLayer.value), trucksLayer.value;
1533
+ }, deleteAllTruckMarkers = () => {
1534
+ truckMarkerList.forEach((e) => {
1535
+ e.feature && (trucksVectorSource == null || trucksVectorSource.removeFeature(e.feature));
1536
+ }), truckMarkerList = [];
1537
+ }, mapInstance$3 = ref(), renderCustomOverlaySetInstance = (e) => mapInstance$3.value = e, drawCustomContent = (e, t, o, n = "top-left", r = !1) => {
1538
+ var m, u;
1539
+ if (!t || !mapInstance$3.value) return;
1540
+ document.querySelectorAll(".truck-custom-content").forEach((f) => f.parentNode.removeChild(f));
1541
+ const l = document.createElement("div");
1542
+ l.innerHTML = o;
1543
+ const i = new Overlay({
1544
+ element: l,
1545
+ position: t,
1546
+ // 初始位置
1547
+ positioning: n,
1548
+ stopEvent: r
1549
+ // 设置不阻拦事件
1550
+ });
1551
+ if (r) {
1552
+ let f = !1, p = [0, 0], y = [0, 0];
1553
+ l.addEventListener("mousedown", function(h) {
1554
+ var g;
1555
+ f = !0, h.clientX, h.clientY, p = (g = mapInstance$3.value) == null ? void 0 : g.getCoordinateFromPixel([h.clientX - 200, h.clientY - 200]), y = [
1556
+ h.clientX - l.getBoundingClientRect().left + 160,
1557
+ h.clientY - l.getBoundingClientRect().top + 84
1558
+ ], h.preventDefault();
1559
+ }), document.addEventListener("mousemove", function(h) {
1560
+ var g;
1561
+ if (f) {
1562
+ let L = (g = mapInstance$3.value) == null ? void 0 : g.getCoordinateFromPixel([h.clientX - y[0], h.clientY - y[1]]), T = L[0] - p[0], b = L[1] - p[1];
1563
+ i.setPosition([p[0] + T, p[1] + b]);
1564
+ }
1565
+ }), document.addEventListener("mouseup", function() {
1566
+ f = !1;
1567
+ });
1568
+ }
1569
+ (m = mapInstance$3.value) == null || m.addOverlay(i);
1570
+ const s = l.querySelector(".close-button");
1571
+ s && s.addEventListener("click", () => {
1572
+ var f, p;
1573
+ (f = mapInstance$3.value) == null || f.removeOverlay(i), (p = l.parentNode) == null || p.removeChild(l);
1574
+ });
1575
+ let c = JSON.parse(JSON.stringify(t));
1576
+ const d = (u = mapInstance$3.value) == null ? void 0 : u.getCoordinateFromPixel(c);
1577
+ return i.setPosition(d), i;
1578
+ }, mapInstance$2 = ref(), renderTruckSetInstance = (e) => mapInstance$2.value = e, vehicle = ref(null), focusShipData = ref(), currentTruckOverlay = ref(null), findTruck = async (e) => {
1579
+ if (!mapInstance$2.value) return;
1580
+ focusShipData.value = e;
1581
+ const t = formatUtils.convertSixHundredThousandToLatLng(e.lon, e.lat), o = mapInstance$2.value.getPixelFromCoordinate(transform(t, projection.data, projection.mercator));
1582
+ currentTruckOverlay.value = drawTruckIcon(e.vno, o, e == null ? void 0 : e.drc);
1583
+ const n = mapInstance$2.value.getView(), r = new Point(t);
1584
+ n.setCenter(transform(r.getCoordinates(), projection.data, projection.mercator));
1585
+ }, clearAllTruck = () => {
1586
+ vehicle.value.clearAllShip();
1587
+ }, drawTruckIcon = (e, t, o) => {
1588
+ const n = `<div id="${e}" class="ol-custom-content truck-custom-content" style="width: 80px; height: 80px; transform: rotate(${o}deg);">
1589
+ <img src="${CDN_URL}map/car-icon.gif" width="100%" height="100%" />
1590
+ </div>`;
1591
+ return drawCustomContent(e, t, n, "center-center");
1592
+ }, removeTruckIcon = () => {
1593
+ var t;
1594
+ const e = (t = currentTruckOverlay.value) == null ? void 0 : t.getElement();
1595
+ e && (e.innerHTML = "");
1596
+ }, zoomTruckIcon = () => {
1597
+ var l;
1598
+ if (!mapInstance$2.value) return;
1599
+ const e = mapInstance$2.value.getView().getZoom(), t = 120, o = 60;
1600
+ function n(i) {
1601
+ return i < 14 ? o : i >= 14 && i <= 18 ? Math.round((i - 14) * (t - o) / 4 + o) : t;
1602
+ }
1603
+ const r = n(e);
1604
+ (l = document.querySelectorAll(".truck-custom-content")) == null || l.forEach((i) => {
1605
+ i.style.width = `${r}px`, i.style.height = `${r}px`;
1606
+ });
1607
+ }, mapInstance$1 = ref(), renderMarkerSetInstance = (e) => mapInstance$1.value = e, markerPosition = ref(""), marker = ref(), createIconStyle = (e) => new Style({
1608
+ image: new Icon({
1609
+ src: CDN_URL + "map/poi-marker-default.png",
1610
+ anchor: [0.5, 1]
1611
+ }),
1612
+ text: new Text({
1613
+ text: e,
1614
+ offsetY: -90,
1615
+ // 调整文本位置,使其位于标记上方
1616
+ font: "12px",
1617
+ fill: new Fill({
1618
+ color: "#000"
1619
+ }),
1620
+ stroke: new Stroke({
1621
+ color: "#fff",
1622
+ width: 2
1623
+ }),
1624
+ backgroundFill: new Fill({
1625
+ color: "#fff"
1626
+ // 设置文本背景填充颜色
1627
+ }),
1628
+ backgroundStroke: new Stroke({
1629
+ color: "#000",
1630
+ // 设置文本背景描边颜色
1631
+ width: 1
1632
+ }),
1633
+ padding: [2, 2, 2, 2]
1634
+ // 设置文本背景的内边距
1635
+ })
1636
+ }), renderMarker = (e, t = !0, o = !0) => {
1637
+ var m;
1638
+ if (!mapInstance$1.value || !e || e.split(",").length !== 2) return;
1639
+ const [n, r] = e.split(",").map(Number);
1640
+ marker.value = new Feature({
1641
+ geometry: new Point(fromLonLat([n, r]))
1642
+ });
1643
+ const l = o ? `${n}, ${r}` : "";
1644
+ (m = marker.value) == null || m.setStyle(createIconStyle(l));
1645
+ const i = new VectorSource({
1646
+ features: [marker.value]
1647
+ }), s = new VectorLayer({
1648
+ source: i
1649
+ }), c = mapInstance$1.value.getView();
1650
+ if (mapInstance$1.value.addLayer(s), t) {
1651
+ const u = new Translate({
1652
+ layers: [s]
1653
+ });
1654
+ u.on("translating", function(f) {
1655
+ var h;
1656
+ const p = f.features.item(0).getGeometry().getCoordinates(), y = toLonLat(p);
1657
+ markerPosition.value = `${y[0].toFixed(6)}, ${y[1].toFixed(6)}`, (h = marker.value) == null || h.setStyle(createIconStyle(markerPosition.value));
1658
+ }), mapInstance$1.value.addInteraction(u);
1659
+ }
1660
+ const d = new Point([n, r]);
1661
+ c.setCenter(transform(d.getCoordinates(), projection.data, projection.mercator)), c.setZoom(mapZoom.findShip);
1662
+ }, setMarkerPosition = (e) => {
1663
+ var r, l;
1664
+ if (!mapInstance$1.value) return;
1665
+ const t = mapInstance$1.value.getView(), o = e.split(",").map(Number);
1666
+ (l = (r = marker.value) == null ? void 0 : r.getGeometry()) == null || l.setCoordinates(fromLonLat([o[0], o[1]]));
1667
+ const n = new Point([o[0], o[1]]);
1668
+ t.setCenter(transform(n.getCoordinates(), projection.data, projection.mercator));
1669
+ }, mapInstance = ref(), drawPolygonSetInstance = (e) => mapInstance.value = e;
1670
+ let layerState = "drawn", drawnState = "undrawn";
1671
+ const source = new VectorSource();
1672
+ let sketch, helpTooltipElement, helpTooltip, measureTooltipElement, measureTooltip, circleStyle, drawVector, draw;
1673
+ function createMeasureTooltip() {
1674
+ var e;
1675
+ measureTooltipElement != null && measureTooltipElement.parentNode && measureTooltipElement.parentNode.removeChild(measureTooltipElement), measureTooltipElement = document.createElement("div"), measureTooltipElement.className = "ol-tooltip ol-tooltip-draw-polygon", measureTooltip = new Overlay({
1676
+ element: measureTooltipElement,
1677
+ offset: [0, -15],
1678
+ positioning: "bottom-center",
1679
+ stopEvent: !1,
1680
+ insertFirst: !1
1681
+ }), (e = mapInstance.value) == null || e.addOverlay(measureTooltip);
1682
+ }
1683
+ function createHelpTooltip() {
1684
+ var e;
1685
+ helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), helpTooltipElement = document.createElement("div"), helpTooltipElement.className = "ol-tooltip ol-help-tooltip hidden", helpTooltip = new Overlay({
1686
+ element: helpTooltipElement,
1687
+ offset: [15, 0],
1688
+ positioning: "center-left"
1689
+ }), (e = mapInstance.value) == null || e.addOverlay(helpTooltip);
1690
+ }
1691
+ let squareLimitError = !1, lineLimitError = !1;
1692
+ const validateSquareLimit = (e) => {
1693
+ let o = 1 / 0, n = -1 / 0, r = 1 / 0, l = -1 / 0;
1694
+ e == null || e.forEach((c) => {
1695
+ const d = transform(c, projection.mercator, projection.data), m = d[0], u = d[1];
1696
+ o = Math.min(o, u), n = Math.max(n, u), r = Math.min(r, m), l = Math.max(l, m);
1697
+ });
1698
+ const i = (n - o) * 111, s = (l - r) * 111;
1699
+ squareLimitError = i > 150 || s > 150;
1700
+ };
1701
+ let storeFeature;
1702
+ const addInteraction = (e) => {
1703
+ var n, r;
1704
+ drawVector || init(), drawnState = "undrawn", layerState = "drawn", (n = mapInstance.value) == null || n.addLayer(drawVector);
1705
+ const t = new Style({
1706
+ stroke: new Stroke({
1707
+ color: "rgba(255, 255, 255, 1)",
1708
+ width: 1.5,
1709
+ lineDash: [10, 10]
1710
+ }),
1711
+ fill: new Fill({
1712
+ color: "rgba(255, 255, 255, 0.25)"
1713
+ })
1714
+ });
1715
+ draw = new Draw({
1716
+ type: "Polygon",
1717
+ source,
1718
+ trace: !0,
1719
+ style: [t, circleStyle]
1720
+ }), (r = mapInstance.value) == null || r.addInteraction(draw), createMeasureTooltip(), createHelpTooltip();
1721
+ let o;
1722
+ draw.on("drawstart", function(l) {
1723
+ var i;
1724
+ layerState = "drawn", sketch = l.feature, o = (i = sketch.getGeometry()) == null ? void 0 : i.on("change", function(s) {
1725
+ const c = s.target;
1726
+ let d = formatUtils.formatArea(c, LENGTH_UNIT.NM);
1727
+ const u = c.getCoordinates()[0], f = new LineString([u[u.length - 2], u[u.length - 1]]);
1728
+ let p = formatUtils.formatLength(f, LENGTH_UNIT.NM);
1729
+ if (lineLimitError = Number(getLength(f) / 1e3) > 150, validateSquareLimit(u), measureTooltipElement && d && (measureTooltipElement.innerHTML = `
1730
+ <span class="text">面积:${d}${lineLimitError || squareLimitError ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1731
+ `), helpTooltipElement && d) {
1732
+ let y = "";
1733
+ parseFloat(d) > 0 && (y = `
1734
+ <div class="text ${squareLimitError ? "error" : ""}">面积:${d}${squareLimitError ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</div>`), helpTooltipElement.innerHTML = `${y}
1735
+ <span class="text ${lineLimitError ? "error" : ""}">线段${u.length - 2}:${p}${lineLimitError ? '<span class="error pl-4">超出可以绘画的距离</span>' : ""}</span>
1736
+ <div><span class="text">单击继续,双击结束</span></div>
1737
+ `;
1738
+ }
1739
+ }), drawnState = "drawing";
1740
+ }), draw.on("drawend", function(l) {
1741
+ var i;
1742
+ if (l.feature.getGeometry()) {
1743
+ storeFeature = l.feature;
1744
+ const s = endFn(l.feature);
1745
+ s != null && s.length && e && e(s);
1746
+ }
1747
+ if (sketch = null, measureTooltipElement = null, createMeasureTooltip(), o && unByKey(o), drawnState = "drawend", draw) {
1748
+ const s = mapInstance.value.getInteractions().getArray().find((c) => c.ol_uid === draw.ol_uid);
1749
+ s && ((i = mapInstance.value) == null || i.removeInteraction(s)), helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement);
1750
+ }
1751
+ });
1752
+ }, removeInteraction = () => {
1753
+ var e, t, o;
1754
+ if (mapInstance.value) {
1755
+ if (document.querySelectorAll(".ol-tooltip.ol-tooltip-draw-polygon").forEach((n) => {
1756
+ var r;
1757
+ (r = n == null ? void 0 : n.parentNode) == null || r.removeChild(n);
1758
+ }), source.clear(), (e = mapInstance.value) == null || e.removeLayer(drawVector), helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), ((t = mapInstance.value) == null ? void 0 : t.getTargetElement()).style.cursor = "", document.querySelector("#map").style.cursor = "", draw) {
1759
+ const n = mapInstance.value.getInteractions().getArray().find((r) => r.ol_uid === draw.ol_uid);
1760
+ n && ((o = mapInstance.value) == null || o.removeInteraction(n));
1761
+ }
1762
+ drawnState = "undrawn", layerState = "destroyed";
1763
+ }
1764
+ }, endFn = (e) => {
1765
+ var t, o, n;
1766
+ if (e.getGeometry()) {
1767
+ const r = [], i = e.getGeometry().getCoordinates();
1768
+ (t = i[0]) == null || t.forEach((c) => {
1769
+ r.push(transform(c, projection.mercator, projection.data));
1770
+ });
1771
+ const s = i[0][i[0].length - 2];
1772
+ if (s && measureTooltip.setPosition(s), measureTooltip.setOffset([10, 0]), measureTooltipElement && (measureTooltipElement.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), (o = document.querySelector(".delete-icon")) == null || o.addEventListener("click", () => {
1773
+ reset();
1774
+ }), !lineLimitError && !squareLimitError)
1775
+ return r;
1776
+ draw && ((n = mapInstance.value) == null || n.removeInteraction(draw)), helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement);
1777
+ }
1778
+ }, initFeature = (e) => {
1779
+ var t, o;
1780
+ if (layerState = "drawn", storeFeature) {
1781
+ const n = storeFeature.getGeometry();
1782
+ if (!n) return;
1783
+ const r = formatUtils.formatArea(n, LENGTH_UNIT.NM);
1784
+ measureTooltipElement && (measureTooltipElement.innerHTML = `
1785
+ <span class="text">面积:${r}${lineLimitError || squareLimitError ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1786
+ `), (t = drawVector.getSource()) == null || t.addFeature(storeFeature);
1787
+ const l = endFn(storeFeature);
1788
+ l != null && l.length && e && e(l);
1789
+ const i = getCenter(storeFeature.getGeometry().getExtent());
1790
+ (o = mapInstance.value) == null || o.getView().setCenter(i);
1791
+ }
1792
+ }, pointerMoveHandler = function(e) {
1793
+ var o;
1794
+ if (e.dragging)
1795
+ return;
1796
+ let t = "点击选择起点";
1797
+ sketch && (t = "单击继续,双击结束"), helpTooltipElement && (helpTooltipElement.innerHTML = t, helpTooltip.setPosition(e.coordinate), helpTooltipElement.classList.remove("hidden")), layerState === "drawn" && (((o = mapInstance.value) == null ? void 0 : o.getTargetElement()).style.cursor = "crosshair");
1798
+ }, init = () => {
1799
+ mapInstance.value && (circleStyle = new Style({
1800
+ image: new CircleStyle({
1801
+ radius: 5,
1802
+ fill: new Fill({
1803
+ color: "rgb(51,112,255, 1)"
1804
+ })
1805
+ }),
1806
+ geometry: function(e) {
1807
+ const t = e.getGeometry().getCoordinates();
1808
+ return new MultiPoint(t);
1809
+ }
1810
+ }), drawVector = new VectorLayer({
1811
+ source,
1812
+ style: new Style({
1813
+ stroke: new Stroke({
1814
+ color: "rgba(255, 255, 255, 1)",
1815
+ width: 2
1816
+ }),
1817
+ fill: new Fill({
1818
+ color: "rgba(255, 255, 255, 0.3)"
1819
+ })
1820
+ })
1821
+ }), mapInstance.value.on("pointermove", pointerMoveHandler), mapInstance.value.getViewport().addEventListener("mouseout", function() {
1822
+ var e;
1823
+ (e = helpTooltipElement == null ? void 0 : helpTooltipElement.classList) == null || e.add("hidden");
1824
+ }), mapInstance.value.on("dblclick", function(e) {
1825
+ drawnState !== "undrawn" && (e.stopPropagation(), e.preventDefault());
1826
+ }));
1827
+ }, reset = () => {
1828
+ removeInteraction(), addInteraction(), storeFeature = null;
1829
+ }, drawPolygonTool = {
1830
+ addInteraction,
1831
+ removeInteraction,
1832
+ initFeature,
1833
+ reset
1834
+ }, _sfc_main = /* @__PURE__ */ defineComponent({
1835
+ __name: "Map",
1836
+ props: {
1837
+ zoom: {},
1838
+ center: {},
1839
+ vehicleMode: {},
1840
+ viewMode: {},
1841
+ mmsi: {},
1842
+ shipData: {}
1843
+ },
1844
+ emits: ["zoomChanged", "extentChanged"],
1845
+ setup(e, { expose: t, emit: o }) {
1846
+ const n = ref();
1847
+ provide("mapInstance", n);
1848
+ const r = ref(null), l = ref(null), i = ref(null), s = o, c = e, d = ref(c.zoom || mapZoom.default), m = ref(!1), u = ref(!0), f = ref(!0);
1849
+ let p;
1850
+ ((v) => {
1851
+ v[v.tiandituTile = new TileLayer({ source: new XYZ({ url: baseMap.tiandituTile }) })] = "tiandituTile", v[v.tiandituTileMark = new TileLayer({ source: new XYZ({ url: baseMap.tiandituTileMark }) })] = "tiandituTileMark", v[v.tiandituImgTile = new TileLayer({ source: new XYZ({ url: baseMap.tiandituImgTile }), visible: !1 })] = "tiandituImgTile", v[v.tiandituImgTileMark = new TileLayer({ source: new XYZ({ url: baseMap.tiandituImgTileMark }), visible: !1 })] = "tiandituImgTileMark", v[v.greenMark = new TileLayer({ source: new XYZ({ url: baseMap.greenTile }) })] = "greenMark";
1852
+ })(p || (p = {}));
1853
+ const y = () => {
1854
+ var S, w;
1855
+ const v = {
1856
+ projection: projection.mercator,
1857
+ // 地图投影坐标系
1858
+ zoom: c.zoom || (c.vehicleMode === "ship" ? mapZoom.default : mapZoom.truckDefault),
1859
+ // 地图缩放级别(打开页面时默认级别)
1860
+ minZoom: mapZoom.min,
1861
+ // 地图缩放最小级别
1862
+ maxZoom: mapZoom.max,
1863
+ // 地图缩放最大级别
1864
+ center: transformUtils.lonLatToMercator(c.center || mapDefaultCenter),
1865
+ // 地图中心坐标
1866
+ constrainResolution: !0,
1867
+ // 需设为true禁用平滑缩放,zoom值为整数
1868
+ enableRotation: !1,
1869
+ // 禁用旋转
1870
+ multiWorld: !0
1871
+ };
1872
+ n.value = new Map$1({
1873
+ target: "map",
1874
+ // 对应页面里 id 为 map 的元素
1875
+ layers: [
1876
+ // 图层
1877
+ p.tiandituTile,
1878
+ p.tiandituTileMark,
1879
+ p.tiandituImgTile,
1880
+ p.tiandituImgTileMark,
1881
+ p.greenMark
1882
+ ],
1883
+ view: new View(v)
1884
+ }), h(), (S = l.value) == null || S.setScaleLine(c.vehicleMode === "ship" && "nautical"), (w = n.value) == null || w.on("moveend", b), g(v.zoom < mapZoom.shipGreenDotMax), T(c.vehicleMode === "ship" || c.viewMode === "findShip" ? BaseMapType.satellite : BaseMapType.vector), c.viewMode === "findShip" && c.mmsi && c.shipData && nextTick(() => {
1885
+ findShip(String(c.mmsi), c.shipData);
1886
+ });
1887
+ };
1888
+ onMounted(() => {
1889
+ y();
1890
+ });
1891
+ const h = () => {
1892
+ n.value && (renderCustomOverlaySetInstance(n.value), renderTruckSetInstance(n.value), drawPolygonSetInstance(n.value), renderShipStyleSetInstance(n.value), renderTrackStyleSetInstance(n.value), renderDashboardSetInstance(n.value), renderMarkerSetInstance(n.value), renderShipSetInstance(n.value), renderTrackSetInstance(n.value));
1893
+ }, g = (v) => {
1894
+ var S;
1895
+ c.vehicleMode !== "ship" && (v = !1), (S = n.value) == null || S.getLayers().forEach((w) => {
1896
+ w.ol_uid === p.greenMark.ol_uid && (w.setVisible(v), u.value = v);
1897
+ });
1898
+ }, L = ref(BaseMapType.satellite), T = (v) => {
1899
+ var S;
1900
+ L.value = v, (S = n.value) == null || S.getLayers().forEach((w) => {
1901
+ (w.ol_uid === p.tiandituTile.ol_uid || w.ol_uid === p.tiandituTileMark.ol_uid || w.ol_uid === p.tiandituImgTile.ol_uid || w.ol_uid === p.tiandituImgTileMark.ol_uid) && w.setVisible(!1), (v === BaseMapType.vector && (w.ol_uid === p.tiandituTile.ol_uid || w.ol_uid === p.tiandituTileMark.ol_uid) || v === BaseMapType.satellite && (w.ol_uid === p.tiandituImgTile.ol_uid || w.ol_uid === p.tiandituImgTileMark.ol_uid)) && w.setVisible(!0);
1902
+ });
1903
+ }, b = () => {
1904
+ const v = n.value.getView(), S = v.getZoom();
1905
+ S && C(S);
1906
+ const w = v.calculateExtent(n.value.getSize());
1907
+ w && S && F(w, S);
1908
+ }, C = (v) => {
1909
+ var V, k, M, E, x;
1910
+ d.value = v, g(v < mapZoom.shipGreenDotMax);
1911
+ const S = (V = n.value) == null ? void 0 : V.getLayers(), w = c.vehicleMode === "ship" ? S == null ? void 0 : S.getArray().find((P) => P.ol_uid === p.greenMark.ol_uid) : void 0;
1912
+ showTrackLayer.value ? (f.value = !1, w == null || w.setVisible(!1), (k = shipsLayer.value) == null || k.setVisible(!1), (M = largeAmountShipsLayer.value) == null || M.setVisible(!1)) : !m.value && u.value && v <= mapZoom.shipGreenDotMax ? (f.value = !0, w == null || w.setVisible(!0), (E = shipsLayer.value) == null || E.setVisible(!1), (x = largeAmountShipsLayer.value) == null || x.setVisible(!1)) : (f.value = !1, w == null || w.setVisible(!1)), s("zoomChanged", v);
1913
+ }, F = (v, S) => {
1914
+ const w = transform([v[0], v[1]], projection.mercator, projection.data), V = transform([v[2], v[3]], projection.mercator, projection.data);
1915
+ s("extentChanged", { extent: [w, V], zoom: S });
1916
+ };
1917
+ return t({
1918
+ mapInstance: n,
1919
+ initMap: y,
1920
+ renderTrucksMarker,
1921
+ renderShip: renderShips,
1922
+ renderTrack: (v, S, w) => {
1923
+ var V, k;
1924
+ currentTrackId.value = v, showTrackLayer.value = !0, m.value = !0, hiddenAllShips(), (k = (V = largeAmountShipsLayer.value) == null ? void 0 : V.getSource()) == null || k.clear(), renderTrack(v, S, w, LENGTH_UNIT.NM);
1925
+ },
1926
+ findTruck,
1927
+ removeTruckIcon,
1928
+ clearAllTruck,
1929
+ closeTrack: () => {
1930
+ var v, S;
1931
+ showTrackLayer.value = !1, (v = shipTrackVectorLayer.value) == null || v.setVisible(!1), (S = selectShipsLayer.value) == null || S.setVisible(!0), m.value = !1, g(d.value < mapZoom.shipGreenDotMax), allTracks.value = [], stopAnimation();
1932
+ },
1933
+ closeTruckTrack: () => {
1934
+ var v, S;
1935
+ showTrackLayer.value = !1, (v = shipTrackVectorLayer.value) == null || v.setVisible(!1), (S = selectShipsLayer.value) == null || S.setVisible(!0), stopAnimation();
1936
+ },
1937
+ resetTrackView,
1938
+ playTrack,
1939
+ clearSelectFeature,
1940
+ findShip,
1941
+ focusShip: (v, S, w = !0) => {
1942
+ var V, k;
1943
+ hiddenOrther.value = w, (V = shipsLayer.value) == null || V.setVisible(!w), (k = largeAmountShipsLayer.value) == null || k.setVisible(!1), findShip(v, S);
1944
+ },
1945
+ showTracks,
1946
+ removeAllTrackLayer,
1947
+ switchFilterItem,
1948
+ rerenderShip,
1949
+ switchGreenDot: () => g(!1),
1950
+ zoomTruckIcon,
1951
+ renderTruckTrack: (v, S, w) => {
1952
+ showTrackLayer.value = !0, renderTrack(v, S, w, LENGTH_UNIT.KM, "truck");
1953
+ },
1954
+ removerLayer: removeShipTrackLineFeatureByIndex,
1955
+ renderMarker,
1956
+ setMarkerPosition,
1957
+ getZoomAndCenter: () => {
1958
+ var k;
1959
+ const v = (k = n.value) == null ? void 0 : k.getView();
1960
+ if (!v) return null;
1961
+ const S = Math.round(Number(v.getZoom())), { lon: w, lat: V } = transformUtils.mercatorToLonLat(v.getCenter());
1962
+ return { zoom: S, center: [w, V] };
1963
+ },
1964
+ setCenter: (v) => {
1965
+ var V;
1966
+ const S = (V = n.value) == null ? void 0 : V.getView();
1967
+ if (!S) return null;
1968
+ const w = new Point(v);
1969
+ S.setCenter(transform(w.getCoordinates(), projection.data, projection.mercator));
1970
+ },
1971
+ drawPolygonTool,
1972
+ setMapInstance: h,
1973
+ config: {
1974
+ mapZoom,
1975
+ projection
1976
+ },
1977
+ utils: {
1978
+ transform: transformUtils,
1979
+ format: formatUtils
1980
+ }
1981
+ }), (v, S) => (openBlock(), createElementBlock("div", {
1982
+ class: "map-page map-container",
1983
+ ref_key: "pageRef",
1984
+ ref: r
1985
+ }, [
1986
+ S[0] || (S[0] = createElementVNode("div", {
1987
+ id: "map",
1988
+ class: "map"
1989
+ }, null, -1)),
1990
+ createVNode(ToolPanel, {
1991
+ "vehicle-mode": v.vehicleMode,
1992
+ "view-mode": v.viewMode,
1993
+ "disable-green-dot": m.value,
1994
+ "show-track-layer": unref(showTrackLayer),
1995
+ "map-tile-mode": L.value,
1996
+ onSwitchGreenDot: g,
1997
+ onSwitchMapTile: T
1998
+ }, {
1999
+ toolPanel: withCtx(() => [
2000
+ renderSlot(v.$slots, "toolPanel", {}, void 0, !0)
2001
+ ]),
2002
+ _: 3
2003
+ }, 8, ["vehicle-mode", "view-mode", "disable-green-dot", "show-track-layer", "map-tile-mode"]),
2004
+ v.viewMode !== "WxMiniprogram" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2005
+ createVNode(ScaleLine, {
2006
+ ref_key: "scaleLineControl",
2007
+ ref: l
2008
+ }, null, 512),
2009
+ createVNode(ZoomControl, {
2010
+ ref_key: "zoomControl",
2011
+ ref: i
2012
+ }, null, 512)
2013
+ ], 64)) : createCommentVNode("", !0),
2014
+ createVNode(Copyright)
2015
+ ], 512));
2016
+ }
2017
+ }), Map = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d4bd9364"]]), ZhMap = withInstall(Map);
2018
+ export {
2019
+ ZhMap as Z
2020
+ };