zhihao-ui 1.2.5 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/es/{BaseInfo-CboHDiqp.js → BaseInfo-Dv-eon6t.js} +1 -1
  2. package/dist/es/Button-DBbUF88w.js +51 -0
  3. package/dist/es/{DatePicker-AcRbvS-8.js → DatePicker-CWQoV03Q.js} +13 -13
  4. package/dist/es/{DetailHeader-CoaVXtN3.js → DetailHeader-C_mAB8-2.js} +3 -3
  5. package/dist/es/{DetailSubTitle-Csp4LjFx.js → DetailSubTitle-DD7Yllhf.js} +2 -2
  6. package/dist/es/Dialog-DyDSVm-6.js +109 -0
  7. package/dist/es/{DiyDataTable-DBonLs6p.js → DiyDataTable-cJVfvtax.js} +5 -4
  8. package/dist/es/{EditInfoPair-DBbRqppY.js → EditInfoPair-D0b5jY5Y.js} +3 -3
  9. package/dist/es/{FileWrapper-BwQhQopY.js → FileWrapper-CMSYWmEz.js} +4 -4
  10. package/dist/es/{Grid-B-FutGih.js → Grid-B5O9dZNI.js} +1 -1
  11. package/dist/es/{InfoPair-WmMCXoUh.js → InfoPair-Do3sSVw-.js} +3 -3
  12. package/dist/es/{Input-DFnH7_jo.js → Input-DVpd0Yte.js} +11 -11
  13. package/dist/es/{Loading-BW6Doqh_.js → Loading-DwtfOhMD.js} +2 -2
  14. package/dist/es/Map-CMiThYaG.js +1681 -0
  15. package/dist/es/MessageBox-BowhqMYW.js +48 -0
  16. package/dist/es/{MoneyInput-BwkFhS2B.js → MoneyInput-CaTrJLi1.js} +7 -7
  17. package/dist/es/{PageHeadPanel-BhR3Bq1A.js → PageHeadPanel-_mKu2rMQ.js} +2 -2
  18. package/dist/es/{ToolTips-BEYXkt4n.js → ToolTips-BTCP0N--.js} +3 -3
  19. package/dist/es/index.js +34 -30
  20. package/dist/es/{utils-B1dH8Kx6.js → utils-DZ8-2Fg2.js} +1 -1
  21. package/dist/es/{vendor-Cu-cEPs_.js → vendor-BY-fHNA3.js} +9646 -8896
  22. package/dist/index.css +1 -1
  23. package/dist/types/components/ButtonGroup/ButtonGroup.test.d.ts +1 -0
  24. package/dist/types/components/ButtonGroup/ButtonGroup.vue.d.ts +37 -0
  25. package/dist/types/components/ButtonGroup/index.d.ts +38 -0
  26. package/dist/types/components/Dialog/Dialog.test.d.ts +1 -0
  27. package/dist/types/components/Dialog/Dialog.vue.d.ts +187 -14
  28. package/dist/types/components/Dialog/index.d.ts +296 -25
  29. package/dist/types/components/Dialog/types.d.ts +15 -5
  30. package/dist/types/components/DiyDataTable/index.d.ts +1 -0
  31. package/dist/types/components/Map/Map.vue.d.ts +25 -3
  32. package/dist/types/components/Map/config.d.ts +2 -0
  33. package/dist/types/components/Map/enum/index.d.ts +1 -0
  34. package/dist/types/components/Map/enum/ship.d.ts +10 -0
  35. package/dist/types/components/Map/index.d.ts +69 -6
  36. package/dist/types/components/Map/interface/entity/queryLicenseResponse.d.ts +0 -111
  37. package/dist/types/components/Map/interface/entity/render.d.ts +32 -0
  38. package/dist/types/components/Map/interface/entity/shipInfoVo.d.ts +4 -0
  39. package/dist/types/components/Map/interface/entity/shipMapData.d.ts +5 -2
  40. package/dist/types/components/Map/interface/entity/shipMarker.d.ts +2 -2
  41. package/dist/types/components/Map/interface/entity/shipTrack.d.ts +0 -4
  42. package/dist/types/components/Map/interface/entity/vehicle.d.ts +171 -0
  43. package/dist/types/components/Map/interface/index.d.ts +5 -3
  44. package/dist/types/components/Map/interface/vo/vehicleVo.d.ts +20 -0
  45. package/dist/types/components/Map/render/canvasRender/canvasRender.d.ts +6 -3
  46. package/dist/types/components/Map/render/canvasRender/renderCustomOverlay.d.ts +3 -0
  47. package/dist/types/components/Map/render/canvasRender/renderShipStyle.d.ts +1 -1
  48. package/dist/types/components/Map/render/drawPolygon.d.ts +9 -0
  49. package/dist/types/components/Map/render/renderMarker.d.ts +6 -0
  50. package/dist/types/components/Map/render/renderShip.d.ts +6 -1
  51. package/dist/types/components/Map/render/renderTruck.d.ts +7 -2
  52. package/dist/types/components/Map/utils/format.d.ts +2 -0
  53. package/dist/types/components/Map/utils/store.d.ts +3 -0
  54. package/dist/types/components/MessageBox/MessageBox.test.d.ts +1 -0
  55. package/dist/types/components/MessageBox/MessageBox.vue.d.ts +11 -218
  56. package/dist/types/components/MessageBox/index.d.ts +4 -342
  57. package/dist/types/components/index.d.ts +1 -0
  58. package/dist/umd/index.css +1 -1
  59. package/dist/umd/index.umd.cjs +26 -16
  60. package/package.json +1 -1
  61. package/dist/es/Button-C1Q6WvkI.js +0 -32
  62. package/dist/es/Dialog-CtU-qGdR.js +0 -74
  63. package/dist/es/Map-BLQnapy4.js +0 -1183
  64. package/dist/es/MessageBox-CjuBt74R.js +0 -100
@@ -0,0 +1,1681 @@
1
+ var A = Object.defineProperty;
2
+ var R = (e, t, o) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var T = (e, t, o) => R(e, typeof t != "symbol" ? t + "" : t, o);
4
+ import { ref, defineComponent, useModel, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, withCtx, Fragment, renderList, unref, createBlock, toDisplayString, createCommentVNode, mergeModels, normalizeClass, nextTick, onMounted } 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 ElOption, s as ScaleLine$1, T as Text, t as Feature, P as Point, v as fromLonLat, e as cloneDeep, G as GeoJSON, W as WebGLPointsLayer, w as transform, h as hooks, L as LineString, I as Icon, x as Translate, y as toLonLat, M as MultiPoint, z as getCenter, A as TileLayer, X as XYZ, B as Map$1, H as View } from "./vendor-BY-fHNA3.js";
6
+ import { _ as _export_sfc } from "./Button-DBbUF88w.js";
7
+ import { w as withInstall } from "./utils-DZ8-2Fg2.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 || {});
9
+ const LENGTH_UNIT_LABEL = {
10
+ 1: "M",
11
+ // m
12
+ 2: "KM",
13
+ // km
14
+ 3: "NM"
15
+ // nm
16
+ };
17
+ var SWITCH_BTN = /* @__PURE__ */ ((e) => (e.Camera = "camera", e.Mobile = "mobile", e.WaterGauge = "waterGauge", e))(SWITCH_BTN || {});
18
+ class ShipMapData {
19
+ constructor(t, o, n, a, r, l, s, i, d, u, p, c, f, g, y, k, L, E, m, v, h, I) {
20
+ T(this, "id");
21
+ // mmsi
22
+ T(this, "mmsi");
23
+ // 船舶三角形填充色
24
+ T(this, "fill");
25
+ // 船类型 "7": "货船",
26
+ T(this, "shipType");
27
+ // 船名
28
+ T(this, "name");
29
+ // 长度
30
+ T(this, "length");
31
+ // 宽度
32
+ T(this, "breadth");
33
+ // 经度
34
+ T(this, "lon");
35
+ // 纬度
36
+ T(this, "lat");
37
+ // 时间
38
+ T(this, "createdAt");
39
+ // 速度
40
+ T(this, "speed");
41
+ // 来源
42
+ T(this, "from");
43
+ // 船状态 "stop":"静止","sail":"航行","work":"作业","danger":"危险","other":"其他"
44
+ T(this, "sailStatus");
45
+ // 船艏向
46
+ T(this, "hdg");
47
+ // 航迹向
48
+ T(this, "cog");
49
+ // 设备定位类型
50
+ T(this, "posType");
51
+ T(this, "type");
52
+ // 航向角度
53
+ T(this, "angle");
54
+ // 左侧是否显示色块
55
+ T(this, "leftIconColor");
56
+ T(this, "existDevice");
57
+ T(this, "existMobile");
58
+ T(this, "existWaterGauge");
59
+ this.id = t, this.mmsi = o, this.fill = n, this.shipType = a, this.name = r, this.length = l, this.breadth = s, this.lon = i, this.lat = d, this.createdAt = u, this.speed = p, this.from = c, this.sailStatus = f, this.hdg = g, this.cog = y, this.posType = k, this.type = L, this.angle = E, this.leftIconColor = m, this.existDevice = v, this.existMobile = h, this.existWaterGauge = I;
60
+ }
61
+ }
62
+ const formatLength = function(e, t) {
63
+ const n = getLength(e);
64
+ let a = "";
65
+ switch (t) {
66
+ case LENGTH_UNIT.M:
67
+ a = Math.round(n * 100) / 100 + " m";
68
+ break;
69
+ case LENGTH_UNIT.KM:
70
+ a = Math.round(n / 1e3 * 100) / 100 + " km";
71
+ break;
72
+ case LENGTH_UNIT.NM:
73
+ a = (Math.round(n / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
74
+ break;
75
+ }
76
+ return a;
77
+ }, convertSixHundredThousandToLatLng = function(e, t) {
78
+ const o = Number(t) / 6e5;
79
+ return [Number(e) / 6e5, o];
80
+ }, formatArea = (e, t) => {
81
+ const n = getArea(e);
82
+ let a;
83
+ switch (t) {
84
+ case LENGTH_UNIT.KM:
85
+ n > 1e4 ? a = Math.round(n / 1e6 * 100) / 100 + " km<sup>2</sup>" : a = Math.round(n * 100) / 100 + " m<sup>2</sup>";
86
+ break;
87
+ case LENGTH_UNIT.NM:
88
+ const r = Math.pow(1.852, 2);
89
+ n > 1e4 ? a = Math.round(n / 1e6 / r * 100) / 100 + " nm<sup>2</sup>" : a = Math.round(n * 100) / 100 + " m<sup>2</sup>";
90
+ break;
91
+ }
92
+ return a;
93
+ }, convertShipMapData = (e) => {
94
+ const t = (o) => new ShipMapData(
95
+ o.id,
96
+ o.id,
97
+ // 船舶三角形填充色
98
+ o.fill || "#04C900",
99
+ "70",
100
+ o.cnname || o.name,
101
+ o.len,
102
+ o.wid,
103
+ o.lon,
104
+ o.lat,
105
+ (/* @__PURE__ */ new Date()).getTime(),
106
+ o.spd,
107
+ o.from,
108
+ o.status,
109
+ Number(o.hdg),
110
+ o.cog,
111
+ Number(o.postype),
112
+ "other",
113
+ o.cog,
114
+ o.leftIconColor,
115
+ o.existDevice,
116
+ o.existMobile,
117
+ o.existWaterGauge
118
+ );
119
+ return Array.isArray(e) ? e.map((o) => t(o)) : t(e);
120
+ }, mapInstance = ref(), shipsLayer = ref(), selectShipsLayer = ref(), allShips = ref([]), largeAmountShipsLayer = ref();
121
+ ref();
122
+ const trucksLayer = ref(), shipTrackLineFeatures = ref([]), trackLineVectorSource = ref(), shipTrackVectorLayer = ref();
123
+ ref();
124
+ ref();
125
+ const labels = ref([]), _hoisted_1$4 = {
126
+ key: 0,
127
+ class: "measure-panel"
128
+ }, _hoisted_2$2 = { class: "d-flex justify-content-between align-content-start w-100" }, _hoisted_3$1 = { class: "measure-history-list" }, _hoisted_4 = { class: "left-panel" }, _hoisted_5 = { class: "text index" }, _hoisted_6 = { class: "text" }, _hoisted_7 = ["onClick"], _sfc_main$6 = /* @__PURE__ */ defineComponent({
129
+ __name: "measure",
130
+ props: {
131
+ visible: { type: Boolean },
132
+ visibleModifiers: {}
133
+ },
134
+ emits: /* @__PURE__ */ mergeModels(["close"], ["update:visible"]),
135
+ setup(e, { expose: t, emit: o }) {
136
+ const n = o, a = useModel(e, "visible"), r = ref(LENGTH_UNIT.NM), l = ref([]), s = ref(!1), i = new VectorSource();
137
+ let d, u, p, c, f;
138
+ const g = new VectorLayer({
139
+ source: i,
140
+ style: {
141
+ "fill-color": "rgba(255, 255, 255, 0.2)",
142
+ "stroke-color": "#ffcc33",
143
+ "stroke-width": 2,
144
+ "circle-radius": 7,
145
+ "circle-fill-color": "#ffcc33"
146
+ }
147
+ }), y = function(S) {
148
+ if (S.dragging)
149
+ return;
150
+ let w = "点击选择起点";
151
+ d && (w = "单击继续,双击结束"), u && (u.innerHTML = w, p.setPosition(S.coordinate), u.classList.remove("hidden"));
152
+ }, k = () => {
153
+ mapInstance.value && (mapInstance.value.on("pointermove", y), mapInstance.value.getViewport().addEventListener("mouseout", function() {
154
+ var S;
155
+ (S = u == null ? void 0 : u.classList) == null || S.add("hidden");
156
+ }), s.value = !0);
157
+ };
158
+ let L;
159
+ const E = new Style({
160
+ fill: new Fill({
161
+ color: "rgba(255, 255, 255, 0.2)"
162
+ }),
163
+ stroke: new Stroke({
164
+ color: "rgba(255,204,51)",
165
+ lineDash: [10, 10],
166
+ width: 2
167
+ }),
168
+ image: new CircleStyle({
169
+ radius: 5,
170
+ stroke: new Stroke({
171
+ color: "rgba(0, 0, 0, 0.7)"
172
+ }),
173
+ fill: new Fill({
174
+ color: "rgba(255, 255, 255, 0.2)"
175
+ })
176
+ })
177
+ });
178
+ function m() {
179
+ var S, w;
180
+ l.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((_) => {
181
+ var M;
182
+ (M = _ == null ? void 0 : _.parentNode) == null || M.removeChild(_);
183
+ }), i.clear(), (S = mapInstance.value) == null || S.removeInteraction(L), (w = mapInstance.value) == null || w.removeLayer(g), u != null && u.parentNode && u.parentNode.removeChild(u);
184
+ }
185
+ function v() {
186
+ var w, _;
187
+ m(), (w = mapInstance.value) == null || w.addLayer(g), L = new Draw({
188
+ source: i,
189
+ type: "LineString",
190
+ style: function() {
191
+ return E;
192
+ }
193
+ }), (_ = mapInstance.value) == null || _.addInteraction(L), I(), h();
194
+ let S;
195
+ L.on("drawstart", function(M) {
196
+ var F;
197
+ d = M.feature;
198
+ let b;
199
+ S = (F = d.getGeometry()) == null ? void 0 : F.on("change", function(P) {
200
+ const N = P.target;
201
+ let x = formatLength(N, r.value);
202
+ b = N.getLastCoordinate(), c && x && (c.innerHTML = x), f.setPosition(b);
203
+ });
204
+ }), L.on("drawend", function() {
205
+ c && (c.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), c != null && c.innerHTML && l.value.push(c == null ? void 0 : c.innerHTML), f.setOffset([0, -7]), d = null, c = null, I(), S && unByKey(S);
206
+ });
207
+ }
208
+ function h() {
209
+ var S;
210
+ u != null && u.parentNode && u.parentNode.removeChild(u), u = document.createElement("div"), u.className = "ol-tooltip hidden", p = new Overlay({
211
+ element: u,
212
+ offset: [15, 0],
213
+ positioning: "center-left"
214
+ }), (S = mapInstance.value) == null || S.addOverlay(p);
215
+ }
216
+ function I() {
217
+ var S;
218
+ c != null && c.parentNode && c.parentNode.removeChild(c), c = document.createElement("div"), c.className = "ol-tooltip ol-tooltip-measure", f = new Overlay({
219
+ element: c,
220
+ offset: [0, -15],
221
+ positioning: "bottom-center",
222
+ stopEvent: !1,
223
+ insertFirst: !1
224
+ }), (S = mapInstance.value) == null || S.addOverlay(f);
225
+ }
226
+ const C = (S) => {
227
+ var M, b;
228
+ l.value[S] && l.value.splice(S, 1);
229
+ const w = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
230
+ w[S] && ((b = (M = w[S]) == null ? void 0 : M.parentNode) == null || b.removeChild(w[S]));
231
+ const _ = i.getFeatures();
232
+ _[S] && i.removeFeature(_[S]);
233
+ }, V = () => {
234
+ n("close");
235
+ };
236
+ return watch(() => a, () => {
237
+ a && !s.value && (k(), v());
238
+ }, { deep: !0, immediate: !0 }), t({
239
+ addInteraction: v,
240
+ removeInteraction: m
241
+ }), (S, w) => {
242
+ const _ = resolveComponent("el-select");
243
+ return a.value ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
244
+ createElementVNode("div", { class: "header" }, [
245
+ w[1] || (w[1] = createElementVNode("div", { class: "title" }, "测量", -1)),
246
+ createElementVNode("i", {
247
+ onClick: V,
248
+ class: "map-iconfont icon-close"
249
+ })
250
+ ]),
251
+ createElementVNode("div", _hoisted_2$2, [
252
+ w[2] || (w[2] = createElementVNode("div", { class: "tips" }, "在地图上点击多个点测量距离,距离单位", -1)),
253
+ createVNode(_, {
254
+ class: "select-length-unit",
255
+ modelValue: r.value,
256
+ "onUpdate:modelValue": w[0] || (w[0] = (M) => r.value = M)
257
+ }, {
258
+ default: withCtx(() => [
259
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(LENGTH_UNIT_LABEL), (M) => (openBlock(), createBlock(unref(ElOption), {
260
+ key: unref(LENGTH_UNIT)[M],
261
+ label: M,
262
+ value: unref(LENGTH_UNIT)[M]
263
+ }, null, 8, ["label", "value"]))), 128))
264
+ ]),
265
+ _: 1
266
+ }, 8, ["modelValue"])
267
+ ]),
268
+ createElementVNode("div", _hoisted_3$1, [
269
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(l.value, (M, b) => (openBlock(), createElementBlock("div", {
270
+ class: "measure-history-item",
271
+ key: b
272
+ }, [
273
+ createElementVNode("div", _hoisted_4, [
274
+ w[3] || (w[3] = createElementVNode("i", { class: "map-iconfont icon-a-Frame-11" }, null, -1)),
275
+ createElementVNode("span", _hoisted_5, "线段" + toDisplayString(b + 1), 1),
276
+ createElementVNode("span", _hoisted_6, toDisplayString(M), 1)
277
+ ]),
278
+ createElementVNode("div", {
279
+ class: "delete-button",
280
+ onClick: (F) => C(b)
281
+ }, w[4] || (w[4] = [
282
+ createElementVNode("i", { class: "map-iconfont icon-a-delete1" }, null, -1)
283
+ ]), 8, _hoisted_7)
284
+ ]))), 128))
285
+ ])
286
+ ])) : createCommentVNode("", !0);
287
+ };
288
+ }
289
+ }), Measure = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-650abf6f"]]), _hoisted_1$3 = { class: "tool-panel" }, _hoisted_2$1 = { class: "tool-components" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
290
+ __name: "toolPanel",
291
+ props: {
292
+ vehicleMode: {}
293
+ },
294
+ emits: ["switchGreenDot", "switchMapTile"],
295
+ setup(e, { emit: t }) {
296
+ const o = t, n = ref(!1), a = ref(null), r = ref(!0), l = () => {
297
+ r.value = !r.value, o("switchGreenDot", r.value);
298
+ }, s = ref(BaseMapType.vector), i = () => {
299
+ s.value = s.value === BaseMapType.vector ? BaseMapType.satellite : BaseMapType.vector, o("switchMapTile", s.value);
300
+ }, d = () => {
301
+ var p, c;
302
+ n.value ? (p = a.value) == null || p.removeInteraction() : (c = a.value) == null || c.addInteraction(), n.value = !n.value;
303
+ }, u = () => {
304
+ var p;
305
+ (p = a.value) == null || p.removeInteraction(), n.value = !1;
306
+ };
307
+ return (p, c) => (openBlock(), createElementBlock(Fragment, null, [
308
+ createElementVNode("div", _hoisted_1$3, [
309
+ p.vehicleMode === "ship" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
310
+ createElementVNode("div", {
311
+ class: normalizeClass(["switch-btn", `${n.value && "active"}`]),
312
+ onClick: d
313
+ }, c[1] || (c[1] = [
314
+ createElementVNode("i", { class: "map-iconfont icon-measure" }, null, -1),
315
+ createElementVNode("div", { class: "button-text" }, "测距", -1)
316
+ ]), 2),
317
+ createElementVNode("div", {
318
+ class: normalizeClass(["switch-btn", { active: r.value }]),
319
+ onClick: l
320
+ }, c[2] || (c[2] = [
321
+ createElementVNode("i", { class: "map-iconfont icon-ship" }, null, -1),
322
+ createElementVNode("div", { class: "button-text" }, "绿点", -1)
323
+ ]), 2)
324
+ ], 64)) : createCommentVNode("", !0),
325
+ createElementVNode("div", {
326
+ class: normalizeClass(["switch-btn", { active: s.value === unref(BaseMapType).satellite }]),
327
+ onClick: i
328
+ }, c[3] || (c[3] = [
329
+ createElementVNode("i", { class: "map-iconfont icon-space" }, null, -1),
330
+ createElementVNode("div", { class: "button-text" }, "卫星", -1)
331
+ ]), 2)
332
+ ]),
333
+ createElementVNode("div", _hoisted_2$1, [
334
+ n.value ? (openBlock(), createBlock(Measure, {
335
+ key: 0,
336
+ ref_key: "measureRef",
337
+ ref: a,
338
+ visible: n.value,
339
+ "onUpdate:visible": c[0] || (c[0] = (f) => n.value = f),
340
+ onClose: u
341
+ }, null, 8, ["visible"])) : createCommentVNode("", !0)
342
+ ])
343
+ ], 64));
344
+ }
345
+ }), ToolPanel = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-9c83c550"]]), _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$4 = /* @__PURE__ */ defineComponent({
346
+ __name: "scaleLine",
347
+ setup(e, { expose: t }) {
348
+ const o = new ScaleLine$1({
349
+ units: "nautical"
350
+ });
351
+ return t({
352
+ setScaleLine: () => {
353
+ o.setTarget(document.getElementById("scale-line-container")), mapInstance.value.addControl(o);
354
+ }
355
+ }), (a, r) => (openBlock(), createElementBlock("div", _hoisted_1$2));
356
+ }
357
+ }), ScaleLine = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-e51b19b1"]]), _hoisted_1$1 = { class: "zoom" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
358
+ __name: "zoomControl",
359
+ props: {
360
+ map: {
361
+ type: Object
362
+ }
363
+ },
364
+ setup(e) {
365
+ const t = () => {
366
+ if (!mapInstance.value) return;
367
+ const n = mapInstance.value.getView(), a = n.getZoom();
368
+ a && n.setZoom(a + 1);
369
+ }, o = () => {
370
+ if (!mapInstance.value) return;
371
+ const n = mapInstance.value.getView(), a = n.getZoom();
372
+ a && n.setZoom(a - 1);
373
+ };
374
+ return (n, a) => (openBlock(), createElementBlock("div", _hoisted_1$1, [
375
+ createElementVNode("div", {
376
+ onClick: t,
377
+ class: "button big-button"
378
+ }, "+"),
379
+ createElementVNode("div", {
380
+ onClick: o,
381
+ class: "button small-button"
382
+ }, "-")
383
+ ]));
384
+ }
385
+ }), ZoomControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-f2b62b21"]]), CDN_URL = "https://static.zhihaoscm.cn/", tiandituKey = "a6e8f78974f2581f2ca00485b40c948f", baseMap = {
386
+ // 矢量底图
387
+ 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}`,
388
+ // 矢量注记
389
+ 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}`,
390
+ // 影像底图
391
+ 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}`,
392
+ // 影像注记
393
+ 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}`,
394
+ // 绿点图
395
+ greenTile: `${CDN_URL}/map/tile/{z}/{x}/{y}.png`
396
+ }, mapZoom = {
397
+ // 地图默认层级
398
+ default: 6,
399
+ // 地图缩放最小层级
400
+ min: 3,
401
+ // 地图缩放最大层级
402
+ max: 18,
403
+ // 查看船舶详情时地图缩放层级
404
+ findShip: 13,
405
+ // 船舶绿点图最大显示层级
406
+ shipGreenDotMax: 11,
407
+ // 查车图标显示层级
408
+ truckDefault: 14,
409
+ // 船形图标最小渲染层级
410
+ shipModelMin: 16,
411
+ // 船形图标最大渲染层级
412
+ shipModelMax: 18
413
+ }, mapDefaultCenter = [114.84, 30.52], projection = {
414
+ // 经纬度 源数据 地理坐标 WGS84
415
+ data: "EPSG:4326",
416
+ // 墨卡托投影坐标 渲染坐标
417
+ mercator: "EPSG:3857"
418
+ }, _hoisted_1 = { class: "copyright" }, _hoisted_2 = { class: "tdt-control-copyright tdt-control" }, _hoisted_3 = ["src"], _sfc_main$2 = /* @__PURE__ */ defineComponent({
419
+ __name: "copyright",
420
+ setup(e) {
421
+ return (t, o) => (openBlock(), createElementBlock("div", _hoisted_1, [
422
+ createElementVNode("div", _hoisted_2, [
423
+ createElementVNode("img", {
424
+ src: unref(CDN_URL) + "map/tdt-logo.png",
425
+ width: "53px",
426
+ height: "22px",
427
+ class: "logo",
428
+ alt: ""
429
+ }, null, 8, _hoisted_3),
430
+ o[0] || (o[0] = createElementVNode("div", { class: "copyright-text" }, "GS(2024)0568号 - 甲测资字1100471", -1))
431
+ ]),
432
+ o[1] || (o[1] = createElementVNode("div", {
433
+ id: "dataSource",
434
+ class: "tdt-control data-source"
435
+ }, "数据来源:自然资源部 & NavInfo", -1))
436
+ ]));
437
+ }
438
+ }), Copyright = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-9c5c2f7b"]]), _sfc_main$1 = /* @__PURE__ */ defineComponent({
439
+ __name: "fullscreen",
440
+ props: {
441
+ pageRef: {
442
+ type: Object,
443
+ default: () => ({})
444
+ }
445
+ },
446
+ setup(e) {
447
+ const t = e, o = ref(!1), n = () => {
448
+ var a;
449
+ o.value ? document.exitFullscreen() : (console.log(t.pageRef), (a = t.pageRef) == null || a.requestFullscreen()), o.value = !o.value;
450
+ };
451
+ return (a, r) => (openBlock(), createElementBlock("div", {
452
+ class: "fullscreen-btn",
453
+ onClick: n
454
+ }, [
455
+ createElementVNode("i", {
456
+ class: normalizeClass(`map-iconfont ${o.value ? "icon-quxiaoquanping" : "icon-quanping"} `)
457
+ }, null, 2)
458
+ ]));
459
+ }
460
+ }), Fullscreen = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-ed59d7cb"]]), equatorialCircumference = 2003750834e-2;
461
+ function lonLatToMercator(e) {
462
+ const t = e[0] * equatorialCircumference / 180;
463
+ let o = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
464
+ return o = o * equatorialCircumference / 180, [t, o];
465
+ }
466
+ function getIconFont(unicode = "") {
467
+ return unicode.indexOf("&amp;") !== -1 && (unicode = unicode.replace("&amp;", "&")), unicode.indexOf("&amp") !== -1 && (unicode = unicode.replace("&amp", "&")), eval('("' + unicode.replace("&#x", "\\u").replace(";", "") + '")');
468
+ }
469
+ const multiplyPixelRatio = (e) => {
470
+ const t = window.devicePixelRatio || 1;
471
+ return e.map((o) => o.map((n) => n * t));
472
+ }, 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({
473
+ text: new Text({
474
+ font: "Normal 14px map-iconfont",
475
+ text: getIconFont(e),
476
+ fill: new Fill({ color: "#fff" }),
477
+ offsetY: -14
478
+ }),
479
+ zIndex: 100
480
+ });
481
+ function convertToRadians(e) {
482
+ if (!e)
483
+ throw new Error("coord is required");
484
+ if (!Array.isArray(e)) {
485
+ if (e.type === "Feature" && e.geometry !== null && e.geometry.type === "Point")
486
+ return e.geometry.coordinates;
487
+ if (e.type === "Point")
488
+ return e.coordinates;
489
+ }
490
+ if (Array.isArray(e) && e.length >= 2 && !Array.isArray(e[0]) && !Array.isArray(e[1]))
491
+ return e;
492
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
493
+ }
494
+ function createFeature(e, t, o = {}) {
495
+ const n = {
496
+ type: "Feature"
497
+ };
498
+ return o.id !== void 0 && (n.id = o.id), o.bbox && (n.bbox = o.bbox), n.properties = {}, n.geometry = e, n;
499
+ }
500
+ function createPoint(e, t, o) {
501
+ return createFeature({
502
+ type: "Point",
503
+ coordinates: e
504
+ }, t, o);
505
+ }
506
+ function calculateAngle(e, t, o) {
507
+ const n = convertToRadians(e), a = convertToRadians(t), r = n[0] % 360 * (Math.PI / 180), l = a[0] % 360 * (Math.PI / 180), s = n[1] % 360 * (Math.PI / 180), i = a[1] % 360 * (Math.PI / 180), d = Math.sin(l - r) * Math.cos(i), u = Math.cos(s) * Math.sin(i) - Math.sin(s) * Math.cos(i) * Math.cos(l - r);
508
+ return 180 * Math.atan2(d, u) % (2 * Math.PI) / Math.PI;
509
+ }
510
+ const getAngle = (e, t) => {
511
+ let o = calculateAngle(createPoint(e), createPoint(t));
512
+ return o = o < 0 ? 360 + o : o, o % 360 * Math.PI / 180;
513
+ }, labelAlpha = 0.8, labelFont = "500 12px Arial", labelOutSize = 2, labelHeight = 10, fillRectRadius = (e, t, o, n, a, r, l = 4) => {
514
+ e.beginPath(), e.moveTo(t + l, o), e.arcTo(t + n, o, t + n, o + l, l), e.arcTo(t + n, o + a, t + n - l, o + a, l), e.arcTo(t, o + a, t, o + a - l, l), e.arcTo(t, o, t + l, o, l), e.closePath(), e.fillStyle = r, e.fill();
515
+ }, getPixelFromCoordinate = (e) => {
516
+ if (!e || e.length === 0)
517
+ throw new Error("Points array is empty or invalid.");
518
+ let t = 1 / 0, o = 1 / 0, n = -1 / 0, a = -1 / 0;
519
+ for (const [r, l] of e)
520
+ r < t && (t = r), l < o && (o = l), r > n && (n = r), l > a && (a = l);
521
+ return [t, o, n, a];
522
+ }, calculatePolygonCentroid = (e) => {
523
+ if (!Array.isArray(e) || e.length < 3)
524
+ throw new Error("A polygon must have at least 3 coordinates.");
525
+ let t = 0, o = 0, n = 0;
526
+ const a = e.length;
527
+ for (let s = 0; s < a - 1; s++) {
528
+ const [i, d] = e[s], [u, p] = e[s + 1], c = i * p - u * d;
529
+ n += c, t += (i + u) * c, o += (d + p) * c;
530
+ }
531
+ if (n *= 0.5, n === 0)
532
+ throw new Error("多边形面积为零");
533
+ const r = t / (6 * n), l = o / (6 * n);
534
+ return [r, l];
535
+ }, rotateShapeModel = (e, t) => {
536
+ const [o, n] = calculatePolygonCentroid(e), a = t * Math.PI / 180, r = Math.cos(a), l = Math.sin(a);
537
+ return e.map(([s, i]) => {
538
+ const d = s - o, u = i - n, p = d * r - u * l + o, c = d * l + u * r + n;
539
+ return [p, c];
540
+ });
541
+ }, getTopLeftPoint = (e) => [e[0], e[3]], getBottomLeftPoint = (e) => [e[2], e[3]], getBottomRightPoint = (e) => [e[2], e[1]], getTopRighttPoint = (e) => [e[0], e[1]];
542
+ function calculateBounds(e, t, o, n, a) {
543
+ let r, l, s, i, d = e[0], u = e[1];
544
+ switch (t) {
545
+ case 0:
546
+ r = d + a, l = r + o, i = u - a, s = i - n;
547
+ break;
548
+ case 1:
549
+ r = d + a, l = r + o, i = u + n / 2, s = i - n;
550
+ break;
551
+ case 2:
552
+ r = d + a, l = r + o, i = u + a + n, s = i - n;
553
+ break;
554
+ case 3:
555
+ r = d - o / 2, l = r + o, i = u + a + n, s = i - n;
556
+ break;
557
+ case 4:
558
+ l = d, r = l - o, i = u + a + n, s = i - n;
559
+ break;
560
+ case 5:
561
+ l = d - a, r = l - o, i = u + n / 2, s = i - n;
562
+ break;
563
+ case 6:
564
+ l = d, r = l - o, i = u - a, s = i - n;
565
+ break;
566
+ case 7:
567
+ r = d - o / 2, l = r + o, i = u - a, s = i - n;
568
+ }
569
+ if (!(!r || !s || !l || !i))
570
+ return [Math.min(r, l), Math.min(s, i), Math.max(r, l), Math.max(s, i) + 1];
571
+ }
572
+ function calculateAnchorPoint(e, t, o = 70, n = 20, a = 20) {
573
+ let r = [0, 0];
574
+ switch (t) {
575
+ case 0:
576
+ r[0] = e[0] + a, r[1] = e[1] - a - n / 2;
577
+ break;
578
+ case 1:
579
+ r[0] = e[0] + a, r[1] = e[1];
580
+ break;
581
+ case 2:
582
+ r[0] = e[0] + a, r[1] = e[1] + a + n / 2;
583
+ break;
584
+ case 3:
585
+ r[0] = e[0], r[1] = e[1] + a + n / 4;
586
+ break;
587
+ case 4:
588
+ r[0] = Math.max(e[0] - a, e[0] - o / 2), r[1] = e[1] + a + n / 4;
589
+ break;
590
+ case 5:
591
+ r[0] = e[0] - a, r[1] = e[1];
592
+ break;
593
+ case 6:
594
+ r[0] = Math.max(e[0] - a, e[0] - o / 2), r[1] = e[1] - a - n / 4;
595
+ break;
596
+ case 7:
597
+ r[0] = e[0], r[1] = e[1] - a - n / 4;
598
+ }
599
+ return r;
600
+ }
601
+ function drawLabelBody(e, t, o) {
602
+ if (!e) return;
603
+ const {
604
+ font: n,
605
+ labelOutSize: a = 2,
606
+ labelHeight: r,
607
+ center: l,
608
+ text: s,
609
+ leftIcon: i,
610
+ shipColor: d,
611
+ lineLength: u = 20
612
+ } = o;
613
+ e.save(), n && (e.font = n);
614
+ let p = e.measureText(s).width + 2 * a;
615
+ (i || d) && (p += r + 4 * a), e.restore();
616
+ let c, f = -1, g = r + 3 * a;
617
+ if (f = 0, c = calculateBounds(l, f, p, g, u), c && f > -1) {
618
+ let y = getBottomLeftPoint(c), k = getTopRighttPoint(c);
619
+ return {
620
+ center: l,
621
+ x: calculateAnchorPoint(l, f, p, g, u),
622
+ l: k,
623
+ r: y,
624
+ bounds: c,
625
+ position: f
626
+ };
627
+ }
628
+ return null;
629
+ }
630
+ const drawText = (e, t) => {
631
+ if (!e) return;
632
+ const { center: o, text: n, textColor: a, leftIcon: r, rightIcons: l, font: s } = t;
633
+ e.save();
634
+ let [i, d] = o;
635
+ if (r) {
636
+ e.font = "21px map-iconfont";
637
+ let u = getIconFont(r.icon);
638
+ e.fillStyle = r.color, e.fillText(u, i + labelOutSize - 4, d + 3), i += 22;
639
+ }
640
+ if (l != null && l.length) {
641
+ e.font = "12px map-iconfont", e.fillStyle = "#3370ff";
642
+ let u = e.measureText(n).width + 6;
643
+ l.forEach((p, c) => {
644
+ let f = getIconFont(p), g = 20 * c;
645
+ e.fillText(f, i + u + g, d);
646
+ });
647
+ }
648
+ e.font = s || labelFont, e.fillStyle = a, e.fillText(n, i, d), e.restore();
649
+ }, drawPolygon = (e, t) => {
650
+ let {
651
+ points: o,
652
+ strokeColor: n,
653
+ fillColor: a,
654
+ shouldClosePath: r,
655
+ translation: l,
656
+ rotation: s,
657
+ rotationCenter: i,
658
+ scale: d,
659
+ globalAlpha: u
660
+ } = t;
661
+ if (u || (u = 1), o && e) {
662
+ e.save(), e.beginPath(), s && s !== 0 && i == null && e.rotate(s), l && e.translate(l[0], l[1]), s && (i != null && i.length) && e.rotate(s), d && e.scale(d, d), e.moveTo(o[0][0], o[0][1]);
663
+ for (let p = 1; p < o.length; p++)
664
+ e.lineTo(o[p][0], o[p][1]);
665
+ r && e.closePath(), n && (e.strokeStyle = n, e.stroke()), a && r && (u && (e.globalAlpha = u), e.fillStyle = a, e.fill()), e.restore();
666
+ }
667
+ }, drawLabel = (e, t) => {
668
+ const { center: o, text: n, color: a, textColor: r, bgColor: l, leftIcon: s, rightIcons: i } = t;
669
+ if (o && n) {
670
+ let d = {
671
+ font: labelFont,
672
+ labelOutSize,
673
+ labelHeight,
674
+ center: o,
675
+ text: n,
676
+ leftIcon: s
677
+ }, u = drawLabelBody(e, labels.value, d);
678
+ if (u) {
679
+ const { x: p, bounds: c, l: f } = u;
680
+ let g = [getTopLeftPoint(c), getBottomLeftPoint(c), getBottomRightPoint(c), getTopRighttPoint(c)];
681
+ labels.value.push(u), drawPolygon(e, {
682
+ points: [o, p],
683
+ strokeColor: a,
684
+ fillColor: "#000",
685
+ shouldClosePath: !0,
686
+ translation: void 0,
687
+ rotation: void 0,
688
+ rotationCenter: void 0,
689
+ scale: void 0,
690
+ globalAlpha: labelAlpha
691
+ }), i != null && i.length && i.forEach(() => {
692
+ g[1][0] += 20, g[2][0] += 20;
693
+ }), drawPolygon(e, {
694
+ points: g,
695
+ strokeColor: a,
696
+ fillColor: l,
697
+ shouldClosePath: !0
698
+ });
699
+ const [L, E] = f, m = {
700
+ center: [L, E + labelOutSize + labelHeight + 1],
701
+ text: n,
702
+ textColor: r,
703
+ leftIcon: s,
704
+ rightIcons: i
705
+ };
706
+ drawText(e, m);
707
+ }
708
+ }
709
+ return null;
710
+ }, dotImage = new Image();
711
+ dotImage.src = `${CDN_URL}/map/truck-dot.svg`;
712
+ dotImage.crossOrigin = "anonymous";
713
+ const dotActiveImage = new Image();
714
+ dotActiveImage.src = `${CDN_URL}/map/truck-dot-active.svg`;
715
+ dotActiveImage.crossOrigin = "anonymous";
716
+ const cameraImage = new Image();
717
+ cameraImage.src = `${CDN_URL}/map/map-camera.svg`;
718
+ cameraImage.crossOrigin = "anonymous";
719
+ const loadImage = new Image();
720
+ loadImage.src = `${CDN_URL}/map/map-load.svg`;
721
+ loadImage.crossOrigin = "anonymous";
722
+ const setTruckStyle = (e, t, o, n) => new Style({
723
+ renderer: (a, r) => {
724
+ const l = r.context;
725
+ l.save();
726
+ let s = 1;
727
+ l.scale(s, s);
728
+ let [i, d] = a;
729
+ i = i / s - 20, d = d / s;
730
+ const u = i - 70, p = d - 68;
731
+ let c = 180;
732
+ const f = 56, g = "#FFFFFF";
733
+ let y = 176;
734
+ const k = 52;
735
+ let L = "#164AFF", E = "#FFFFFF";
736
+ o === CAR_COLOR.YELLOW ? (y = 176, L = "#FFC81E", E = "rgba(0,0,0,0.88)") : o === CAR_COLOR.Y_GREEN && (c = 200, y = 196, L = "#8FED7C", E = "rgba(0,0,0,0.88)"), n != null && n.length && (c += n.length * 56), fillRectRadius(l, u, p, c, f, g), fillRectRadius(l, u + 2, p + 2, y, k, L), o === CAR_COLOR.Y_GREEN && fillRectRadius(l, u + 2, p + 2, 68, k, "#FFC81E"), l.save(), l.restore(), l.fillStyle = E, l.font = "bold 28px Arial", l.textAlign = "left", l.textBaseline = "middle";
737
+ const m = `${t.slice(0, 2) + " · " + t.slice(2)}`;
738
+ if (l.fillText(m, u + 12, p + 32), l.save(), l.restore(), n != null && n.length) {
739
+ const h = l.measureText(m).width + 12;
740
+ let I = 0;
741
+ n.forEach((C) => {
742
+ C === DEVICE_TYPE.CAMERA && (l.drawImage(cameraImage, i - 54 + h + I * 56, d - 64, 50, 50), ++I), C === DEVICE_TYPE.LOAD && (l.drawImage(loadImage, i - 54 + h + I * 56, d - 64, 50, 50), ++I);
743
+ });
744
+ }
745
+ const v = dotImage;
746
+ l.drawImage(v, i + c / 2 - 90, d, 50 / s, 50 / s), l.restore();
747
+ }
748
+ });
749
+ ref([]);
750
+ let truckMarkerList = [], trucksVectorSource;
751
+ const renderTrucksMarker = (e) => {
752
+ if (deleteAllTruckMarkers(), !!mapInstance.value)
753
+ return e.forEach((t) => {
754
+ const o = convertSixHundredThousandToLatLng(t.lon, t.lat), n = new Feature({
755
+ geometry: new Point(fromLonLat(o))
756
+ });
757
+ n.set("data", t), n.setStyle(
758
+ setTruckStyle(!1, t.vno, t == null ? void 0 : t.vclColor, t == null ? void 0 : t.icons)
759
+ ), truckMarkerList.push({
760
+ name: t.vno,
761
+ lonlat: o,
762
+ feature: n
763
+ });
764
+ }), trucksVectorSource = new VectorSource({
765
+ features: truckMarkerList.map((t) => t.feature)
766
+ }), trucksLayer.value = new VectorLayer({
767
+ source: trucksVectorSource
768
+ }), mapInstance.value.addLayer(trucksLayer.value), trucksLayer.value;
769
+ }, deleteAllTruckMarkers = () => {
770
+ truckMarkerList.forEach((e) => {
771
+ e.feature && (trucksVectorSource == null || trucksVectorSource.removeFeature(e.feature));
772
+ }), truckMarkerList = [];
773
+ }, triangleModel = multiplyPixelRatio([
774
+ [0, -8],
775
+ [5, 8],
776
+ [-5, 8]
777
+ ]), shipShapeModel = multiplyPixelRatio([
778
+ [0, -4.545],
779
+ [-0.56, -3.909],
780
+ [-1, -2.727],
781
+ [-1, 3.636],
782
+ [-0.8, 4.545],
783
+ [0.8, 4.545],
784
+ [1, 3.636],
785
+ [1, -2.727],
786
+ [0.56, -3.909],
787
+ [0, -4.545]
788
+ ]), shipDirectPath = {
789
+ left: {
790
+ 0: [
791
+ [0, 0],
792
+ [0, -8],
793
+ [-4, -8]
794
+ ],
795
+ 1: [
796
+ [0, 0],
797
+ [0, -16],
798
+ [-6, -16]
799
+ ],
800
+ 2: [
801
+ [0, 0],
802
+ [0, -24],
803
+ [-8, -24]
804
+ ]
805
+ },
806
+ right: {
807
+ 0: [
808
+ [0, 0],
809
+ [0, -8],
810
+ [-4, -8]
811
+ ],
812
+ 1: [
813
+ [0, 0],
814
+ [0, -16],
815
+ [-6, -16]
816
+ ],
817
+ 2: [
818
+ [0, 0],
819
+ [0, -24],
820
+ [-8, -24]
821
+ ]
822
+ },
823
+ front: {
824
+ 0: [
825
+ [0, 0],
826
+ [0, -8]
827
+ ],
828
+ 1: [
829
+ [0, 0],
830
+ [0, -16]
831
+ ],
832
+ 2: [
833
+ [0, 0],
834
+ [0, -24]
835
+ ]
836
+ }
837
+ }, speedCondition = [[1, 10], [10, 20], [20, 1 / 0]], drawShipModelByZoom = { 16: [200, 30], 17: [50, 5], 18: [1, 1] }, setShipStyle = (e) => new Style({
838
+ renderer: (t, o) => {
839
+ const n = o.context, a = o.feature.get("data");
840
+ try {
841
+ const r = drawShipBody(n, a, t);
842
+ r && (drawHeading(n, a, r), e && drawSelectBounds(n, r)), drawShipLabel(n, a, t);
843
+ } catch {
844
+ return !1;
845
+ }
846
+ }
847
+ }), drawShipBody = (e, t, o) => {
848
+ if (!mapInstance.value) return;
849
+ const n = mapInstance.value.getView().getZoom();
850
+ if (!n) return;
851
+ let a = [];
852
+ const [r, l] = drawShipModelByZoom[n] || [0, 0], [s, i] = o;
853
+ if (n <= mapZoom.shipModelMax && n > mapZoom.shipModelMin && t.length >= r && t.breadth >= l)
854
+ a = rotateShapeModel(drawCurrentShipShapeModel(t, n), t.angle).map((u) => {
855
+ const [p, c] = u;
856
+ return [s + p, i + c];
857
+ });
858
+ else {
859
+ const d = rotateShapeModel(triangleModel, t.angle);
860
+ o.length === 2 && (a = d.map((u) => {
861
+ const [p, c] = u;
862
+ return [s + p, i + c];
863
+ }));
864
+ }
865
+ if (!(a.length > 2)) return !1;
866
+ e.save(), e.beginPath(), e.moveTo(a[0][0], a[0][1]);
867
+ for (let d = 1; d < a.length; d++)
868
+ e.lineTo(a[d][0], a[d][1]);
869
+ return e.closePath(), e.strokeStyle = "#000", e.lineWidth = 1, e.stroke(), e.fillStyle = t.fill, e.fill(), e.restore(), a;
870
+ }, drawHeading = (e, t, o) => {
871
+ const [n, a] = o[0], r = getShipDirectPath(t);
872
+ if (r) {
873
+ let l = r.map(function(s) {
874
+ let [i, d] = s;
875
+ return [i + n, d + a];
876
+ });
877
+ if (e.save(), e.beginPath(), t.angle > 0) {
878
+ e.translate(n, a);
879
+ const s = t.angle * Math.PI / 180;
880
+ e.rotate(s), e.translate(-n, -a);
881
+ }
882
+ e.moveTo(n, a);
883
+ for (let s = 1; s < l.length; s++) {
884
+ let [i, d] = l[s];
885
+ e.lineTo(i, d);
886
+ }
887
+ e.strokeStyle = "#000", e.lineWidth = 1, e.stroke(), e.restore();
888
+ }
889
+ }, drawSelectBounds = (e, t) => {
890
+ let [o, n, a, r] = getPixelFromCoordinate(t);
891
+ const l = 4;
892
+ o -= l, n -= l, a += l, r += l, e.save(), e.strokeStyle = "#ff0000", e.lineWidth = 4;
893
+ const s = 8;
894
+ e.beginPath(), e.moveTo(o + s, r), e.lineTo(o, r), e.lineTo(o, r - s), e.moveTo(o, n + s), e.lineTo(o, n), e.lineTo(o + s, n), e.moveTo(a - s, n), e.lineTo(a, n), e.lineTo(a, n + s), e.moveTo(a, r - s), e.lineTo(a, r), e.lineTo(a - s, r), e.stroke(), e.restore();
895
+ }, drawShipLabel = (e, t, o) => {
896
+ const [n, a] = o, r = n - 0, l = a - 0, s = t.name;
897
+ let i;
898
+ t.leftIconColor && (i = { color: t.leftIconColor, icon: "&#xe599;" });
899
+ let d = getShipCustomIcon(t);
900
+ drawLabel(e, {
901
+ center: [r, l],
902
+ text: s,
903
+ color: "#fff",
904
+ textColor: "#000",
905
+ bgColor: "#fff",
906
+ leftIcon: i,
907
+ rightIcons: d
908
+ });
909
+ }, drawCurrentShipShapeModel = (e, t) => {
910
+ let o = 0;
911
+ t === 17 ? o = 0.425 : t === 18 && (o = 0.857);
912
+ const n = e.length / 4 * o, a = e.breadth * o;
913
+ let r = cloneDeep(shipShapeModel);
914
+ return r = r.map(([l, s]) => [l * a, s * n]), r;
915
+ }, getShipDirectPath = (e) => {
916
+ let { speed: t, hdg: o, cog: n } = e, a = "", r = null;
917
+ if (t && t > 1 && (o !== null && o != 511 && n !== null ? n - o >= 3 ? a = "left" : n - o <= -3 ? a = "right" : a = "front" : a = "front", a && t))
918
+ for (let l in speedCondition) {
919
+ let s = speedCondition[l];
920
+ if (t >= s[0] && t < s[1]) {
921
+ r = shipDirectPath[a][l];
922
+ break;
923
+ }
924
+ }
925
+ return r;
926
+ }, getShipCustomIcon = (e) => {
927
+ let t = [];
928
+ return e.existDevice && t.push("&#xe687;"), e.existMobile && t.push("&#xe688;"), e.existWaterGauge && t.push("&#xe686;"), t || [];
929
+ };
930
+ let shipsMarkerList = [], shipsVectorSource, largeAmountShipsSource;
931
+ const selectedShipData = ref(null);
932
+ let selectShipsVectorSource;
933
+ const renderShips = (e) => {
934
+ if (!mapInstance.value) return;
935
+ const t = mapInstance.value.getView().getZoom();
936
+ if (selectedShipData.value && nextTick(() => {
937
+ selectSingleShipMarker(selectedShipData.value);
938
+ }).then((o) => {
939
+ }), !(!t || t < mapZoom.shipGreenDotMax))
940
+ return allShips.value = e, t > mapZoom.shipGreenDotMax && t < mapZoom.shipModelMin || e.length > 500 ? (deleteAllShipMarkers(), renderLargeAmountShips(e)) : (largeAmountShipsSource == null || largeAmountShipsSource.clear(), renderShipsMarker(e));
941
+ }, renderLargeAmountShips = (e) => {
942
+ if (!mapInstance.value) return;
943
+ const t = e.map((o) => ({
944
+ type: "Feature",
945
+ geometry: {
946
+ type: "Point",
947
+ coordinates: [o.lon, o.lat]
948
+ },
949
+ properties: o
950
+ }));
951
+ return largeAmountShipsSource == null || largeAmountShipsSource.clear(), largeAmountShipsSource = new VectorSource({
952
+ features: new GeoJSON().readFeatures({
953
+ type: "FeatureCollection",
954
+ features: t
955
+ }, {
956
+ featureProjection: projection.mercator
957
+ })
958
+ }), largeAmountShipsLayer.value = new WebGLPointsLayer({
959
+ source: largeAmountShipsSource,
960
+ style: {
961
+ "shape-points": 3,
962
+ "shape-radius": 9,
963
+ "shape-fill-color": "#04C900",
964
+ "shape-rotate-with-view": !1,
965
+ "shape-rotation": [
966
+ "get",
967
+ "cog",
968
+ // 获取 'cog' 属性值
969
+ 0
970
+ // 如果 'cog' 属性不存在,使用默认值 0
971
+ ],
972
+ "shape-scale": [0.8, 1.2]
973
+ }
974
+ }), mapInstance.value.addLayer(largeAmountShipsLayer.value), largeAmountShipsLayer.value;
975
+ }, renderShipsMarker = (e) => {
976
+ if (!mapInstance.value) return;
977
+ deleteAllShipMarkers();
978
+ let t = convertShipMapData(e);
979
+ if (t = customFilterShips(t), !!(t != null && t.length))
980
+ return t.forEach((o) => {
981
+ const n = [o.lon, o.lat], a = new Feature({
982
+ geometry: new Point(fromLonLat(n))
983
+ });
984
+ a.set("data", o), a.setStyle(
985
+ setShipStyle(!1, o.id)
986
+ ), shipsMarkerList.push({
987
+ ship: o,
988
+ lonlat: n,
989
+ feature: a
990
+ });
991
+ }), shipsVectorSource = new VectorSource({
992
+ features: shipsMarkerList.map((o) => o.feature)
993
+ }), shipsLayer.value = new VectorLayer({
994
+ source: shipsVectorSource
995
+ }), mapInstance.value.addLayer(shipsLayer.value), shipsLayer.value;
996
+ }, customFilterShips = (e) => {
997
+ let t = cloneDeep(e);
998
+ return t = t.filter((o) => {
999
+ var a, r, l;
1000
+ let n = getFilterItem(o).every(({ btnShow: s, value: i }) => s ? !!i : !0);
1001
+ return switchBtnShow.value.camera || switchBtnShow.value.mobile || switchBtnShow.value.waterGauge ? ((a = selectedShipData.value) == null ? void 0 : a.id) === o.id && clearSelectFeature() : (r = selectedShipData.value) != null && r.id && findShip((l = selectedShipData.value) == null ? void 0 : l.id, selectedShipData.value, !1), n;
1002
+ }), t;
1003
+ }, getFilterItem = (e) => [
1004
+ { btnShow: switchBtnShow.value.camera, value: e == null ? void 0 : e.existDevice },
1005
+ { btnShow: switchBtnShow.value.mobile, value: e == null ? void 0 : e.existMobile },
1006
+ { btnShow: switchBtnShow.value.waterGauge, value: e == null ? void 0 : e.existWaterGauge }
1007
+ ], deleteAllShipMarkers = () => {
1008
+ shipsMarkerList.forEach((e) => {
1009
+ e.feature && (shipsVectorSource == null || shipsVectorSource.removeFeature(e.feature));
1010
+ }), shipsMarkerList = [];
1011
+ }, selectSingleShipMarker = (e) => {
1012
+ if (!mapInstance.value) return;
1013
+ const t = convertShipMapData(e), o = [t.lon, t.lat], n = new Feature({
1014
+ geometry: new Point(fromLonLat(o))
1015
+ });
1016
+ return n.set("data", t), n.setStyle(
1017
+ setShipStyle(!0, t.id)
1018
+ ), shipsMarkerList.push({
1019
+ ship: t,
1020
+ lonlat: o,
1021
+ feature: n
1022
+ }), selectShipsVectorSource == null || selectShipsVectorSource.clear(), selectShipsVectorSource = new VectorSource({
1023
+ features: [n]
1024
+ }), selectShipsLayer.value = new VectorLayer({
1025
+ source: selectShipsVectorSource
1026
+ }), mapInstance.value.addLayer(selectShipsLayer.value), selectShipsLayer.value.setVisible(!0), selectShipsLayer.value;
1027
+ }, findShip = (e, t, o = !0) => {
1028
+ var a, r, l, s, i;
1029
+ if (!e || !mapInstance.value) return;
1030
+ const n = (l = (r = (a = shipsLayer.value) == null ? void 0 : a.getSource()) == null ? void 0 : r.getFeatures()) == null ? void 0 : l.find((d) => {
1031
+ var u;
1032
+ return ((u = d.get("data")) == null ? void 0 : u.id) === e;
1033
+ });
1034
+ if (n)
1035
+ selectedShipData.value = n;
1036
+ else if (t)
1037
+ selectedShipData.value = t;
1038
+ else {
1039
+ console.error("找不到船舶");
1040
+ return;
1041
+ }
1042
+ if (selectSingleShipMarker(t), o && ((s = selectedShipData.value) != null && s.lon) && ((i = selectedShipData.value) != null && i.lat)) {
1043
+ const d = mapInstance.value.getView(), u = new Point([selectedShipData.value.lon, selectedShipData.value.lat]);
1044
+ d.setCenter(transform(u.getCoordinates(), projection.data, projection.mercator));
1045
+ const p = d.getZoom(), c = p < mapZoom.findShip ? mapZoom.findShip : p;
1046
+ d.setZoom(c);
1047
+ }
1048
+ return n;
1049
+ }, clearSelectFeature = () => {
1050
+ selectedShipData.value = null, mapInstance.value && (selectShipsVectorSource == null || selectShipsVectorSource.clear(), selectShipsLayer.value = new VectorLayer({
1051
+ source: selectShipsVectorSource
1052
+ }), mapInstance.value.addLayer(selectShipsLayer.value), selectShipsLayer.value.setVisible(!1));
1053
+ }, hiddenAllShips = () => {
1054
+ var e, t;
1055
+ (e = shipsLayer.value) == null || e.setVisible(!1), (t = largeAmountShipsLayer.value) == null || t.setVisible(!1);
1056
+ }, switchBtnShow = ref({
1057
+ // 船舶摄像头过滤开关
1058
+ [SWITCH_BTN.Camera]: !1,
1059
+ // 船舶联系方式过滤开关
1060
+ [SWITCH_BTN.Mobile]: !1,
1061
+ // 船舶水尺过滤开关
1062
+ [SWITCH_BTN.WaterGauge]: !1
1063
+ }), switchFilterItem = (e, t) => {
1064
+ switchBtnShow.value[e] = t, renderShips(allShips.value);
1065
+ }, rerenderShip = () => {
1066
+ renderShips(allShips.value);
1067
+ }, stopIcon = "&#xe6e2;", stopColor = "#E31818", slowIcon = "&#xe703;", slowColor = "#1890FF", dropletsIcon = "&#xe6d2", trackList$1 = ref([]), renderTrackLine = (e, t, o) => {
1068
+ var r, l;
1069
+ const n = e[t];
1070
+ if (!n) return;
1071
+ (r = trackLineVectorSource.value) == null || r.clear(), trackList$1.value = [], trackList$1.value = n.reverse().map((s, i) => (s.center = [s.lon, s.lat], s.centerPoint = lonLatToMercator(s.center), s.id = t, s.index = i, s.time = hooks(s.createdAt).format("YYYY-MM-DD HH:mm:ss"), s));
1072
+ let a = trackList$1.value.map((s) => s.centerPoint);
1073
+ if (a.length >= 2) {
1074
+ let s = new LineString(a);
1075
+ const i = new Feature({ geometry: s });
1076
+ i.setStyle(
1077
+ new Style({
1078
+ stroke: new Stroke({
1079
+ color: o,
1080
+ width: 2
1081
+ })
1082
+ })
1083
+ ), i.setId(t), i.set("type", "line");
1084
+ const d = shipTrackLineFeatures.value.findIndex((u) => u.getId() === t);
1085
+ d >= 0 ? shipTrackLineFeatures.value[d] = i : shipTrackLineFeatures.value.push(i), trackLineVectorSource.value = new VectorSource({
1086
+ features: shipTrackLineFeatures.value
1087
+ }), shipTrackVectorLayer.value = new VectorLayer({
1088
+ source: trackLineVectorSource.value
1089
+ }), setTimeout(() => {
1090
+ renderPoint(o);
1091
+ }, 500), (l = mapInstance.value) == null || l.addLayer(shipTrackVectorLayer.value);
1092
+ }
1093
+ }, renderPoint = (e) => {
1094
+ if (!mapInstance.value) return;
1095
+ let t = trackList$1.value || [];
1096
+ if (!(t && t.length > 2)) return [];
1097
+ let o = { 16: 24, 17: 15, default: 4 }, n = [], a = t.length;
1098
+ for (let s = 0; s < a; s++) {
1099
+ t[s].index = s;
1100
+ let i = mapInstance.value.getPixelFromCoordinate(t[s].centerPoint);
1101
+ if (i) {
1102
+ let d = i.concat(i);
1103
+ d = adjustBounds(d, [20, 20]);
1104
+ let u = mapInstance.value.getView().getZoom();
1105
+ if (!u) return;
1106
+ if (u > 15) {
1107
+ let c = o[u] || o.default;
1108
+ d = adjustBounds(d, [c, c]);
1109
+ }
1110
+ let p = !0;
1111
+ if (t[s].state !== "0") {
1112
+ for (let c = 0; c < n.length; c++)
1113
+ if (isOverlapping(d, n[c].bounds)) {
1114
+ p = !1;
1115
+ break;
1116
+ }
1117
+ }
1118
+ p && (t[s].bounds = d, n.push(t[s]));
1119
+ }
1120
+ }
1121
+ const r = getIconStyle(stopIcon), l = getIconStyle(slowIcon);
1122
+ n.forEach((s) => {
1123
+ var u, p;
1124
+ let i = new Feature({
1125
+ geometry: new Point(s.centerPoint)
1126
+ });
1127
+ i.set("type", "track_point"), i.set("data", s), i.setStyle(
1128
+ new Style({
1129
+ image: new CircleStyle({
1130
+ fill: new Fill({ color: e }),
1131
+ stroke: new Stroke({ color: "#fff", width: 2 }),
1132
+ radius: 3
1133
+ })
1134
+ })
1135
+ ), trackLineVectorSource.value.addFeature(i);
1136
+ const d = new Feature({
1137
+ geometry: new Point(fromLonLat(s.center))
1138
+ });
1139
+ if (d.set("type", "track_label"), d.setStyle(
1140
+ setTrackLabelStyle(s, e)
1141
+ ), console.log("trackLabelFeature"), trackLineVectorSource.value.addFeature(d), typeof s == "object" && s.hasOwnProperty("state")) {
1142
+ let c = new Feature({
1143
+ geometry: new Point(s.centerPoint)
1144
+ });
1145
+ c.set("type", "track_icon");
1146
+ let f = new Style({
1147
+ text: new Text({
1148
+ font: "Normal 22px map-iconfont",
1149
+ text: getIconFont(dropletsIcon),
1150
+ offsetY: -10
1151
+ }),
1152
+ zIndex: 99
1153
+ }), g = [];
1154
+ s.state === "0" ? ((u = f.getText()) == null || u.setFill(new Fill({ color: stopColor })), g.push(r)) : ((p = f.getText()) == null || p.setFill(new Fill({ color: slowColor })), g.push(l)), g.push(f), c.setStyle(g), trackLineVectorSource.value.addFeature(c);
1155
+ }
1156
+ }), renderArrow(n, e), renderIconPoint();
1157
+ }, renderArrow = (e, t) => {
1158
+ const o = e.length;
1159
+ o || (e.push(trackList$1.value[0]), e.push(trackList$1.value[trackList$1.value.length - 1]));
1160
+ for (let n = 0; n < o - 1; n++) {
1161
+ let a, r = e[n], l = (e[n + 1].index + r.index) / 2;
1162
+ if (l % 2 === 0)
1163
+ a = trackList$1.value[l].centerPoint;
1164
+ else {
1165
+ let s = trackList$1.value[Math.floor(l)], i = trackList$1.value[Math.ceil(l)];
1166
+ if (s && i) {
1167
+ let [d, u] = s.centerPoint, [p, c] = i.centerPoint;
1168
+ a = [(d + p) / 2, (u + c) / 2];
1169
+ }
1170
+ }
1171
+ if (a) {
1172
+ let s = new Feature({
1173
+ geometry: new Point(a)
1174
+ });
1175
+ s.set("type", "track_arrow"), s.setStyle(
1176
+ new Style({
1177
+ text: new Text({
1178
+ font: "700 14px map-iconfont",
1179
+ text: getIconFont("&#xe6bc;"),
1180
+ fill: new Fill({ color: t }),
1181
+ rotation: getAngle(
1182
+ e[n].center,
1183
+ e[n + 1].center
1184
+ )
1185
+ })
1186
+ })
1187
+ ), trackLineVectorSource.value.addFeature(s);
1188
+ }
1189
+ }
1190
+ }, renderIconPoint = () => {
1191
+ const e = "&#xe69b;", t = "#fcdc3f", o = "#ff0000";
1192
+ (trackList$1.value.length < 2 ? [trackList$1.value[0]] : [trackList$1.value[0], trackList$1.value[trackList$1.value.length - 1]]).forEach((a) => {
1193
+ let r = new Feature({
1194
+ geometry: new Point(a.centerPoint)
1195
+ });
1196
+ r.set("type", "track_begin"), r.set("data", a);
1197
+ const l = a.index === 0 && trackList$1.value.length >= 2 ? t : o;
1198
+ r.setStyle(
1199
+ new Style({
1200
+ text: new Text({
1201
+ font: "Normal 14px map-iconfont",
1202
+ text: getIconFont(e),
1203
+ fill: new Fill({ color: l })
1204
+ }),
1205
+ zIndex: 101
1206
+ })
1207
+ ), trackLineVectorSource.value.addFeature(r);
1208
+ });
1209
+ }, setTrackLabelStyle = (e, t) => new Style({
1210
+ renderer: (o, n) => {
1211
+ const a = n.context, s = {
1212
+ center: o,
1213
+ text: e.time,
1214
+ color: t,
1215
+ textColor: "#000",
1216
+ bgColor: "rgba(255,255,255,.8)"
1217
+ };
1218
+ drawLabel(a, s);
1219
+ }
1220
+ }), showTracks = ref([]), trackList = ref([]);
1221
+ ref(null);
1222
+ const trackId = ref(""), cursor = ref(0), renderTrack = (e, t, o, n, a = "ship") => {
1223
+ var u;
1224
+ if (nextTick(() => {
1225
+ hiddenAllShips();
1226
+ }).then((p) => {
1227
+ }), (t == null ? void 0 : t.length) < 2) {
1228
+ ((u = showTracks.value) == null ? void 0 : u.findIndex((p) => p.id === e)) < 0 && showTracks.value.push({ id: e, length: "" });
1229
+ return;
1230
+ }
1231
+ let r = {};
1232
+ t.forEach((p) => {
1233
+ p.state ? p.state = Number(p.state) : delete p.state;
1234
+ }), trackId.value = e, r[e] = t, trackList.value = t;
1235
+ const l = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], s = r[e].map(
1236
+ (p) => transform([p.lon, p.lat], projection.data, projection.mercator)
1237
+ ), i = new LineString(s), d = formatLength(i, n) || "--";
1238
+ nextTick(() => {
1239
+ var c;
1240
+ const p = (c = showTracks.value) == null ? void 0 : c.findIndex((f) => f.id === e);
1241
+ p < 0 ? showTracks.value.push({ id: e, length: d }) : showTracks.value[p].length = d, renderTrackLine(r, e, o), ++cursor.value, cursor.value > l.length && (cursor.value = 0), resetTrackView(e);
1242
+ }).then(() => {
1243
+ });
1244
+ }, removeAllTrackLayer = () => {
1245
+ var e;
1246
+ showTracks.value = [], (e = trackLineVectorSource.value) == null || e.clear();
1247
+ }, resetTrackView = (e) => {
1248
+ var n, a;
1249
+ const t = mapInstance.value.getView(), o = (a = (n = shipTrackLineFeatures.value.find((r) => r.getId() === e)) == null ? void 0 : n.getGeometry()) == null ? void 0 : a.getExtent();
1250
+ if (o != null && o.length)
1251
+ try {
1252
+ t.fit(o);
1253
+ } catch (r) {
1254
+ console.log(r);
1255
+ }
1256
+ }, drawCustomContent = (e, t, o, n = "top-left", a = !1) => {
1257
+ var u, p;
1258
+ if (!t || !mapInstance.value) return;
1259
+ document.querySelectorAll(".truck-custom-content").forEach((c) => c.parentNode.removeChild(c));
1260
+ const r = document.createElement("div");
1261
+ r.innerHTML = o;
1262
+ const l = new Overlay({
1263
+ element: r,
1264
+ position: t,
1265
+ // 初始位置
1266
+ positioning: n,
1267
+ stopEvent: a
1268
+ // 设置不阻拦事件
1269
+ });
1270
+ if (a) {
1271
+ let c = !1, f = [0, 0], g = [0, 0];
1272
+ r.addEventListener("mousedown", function(y) {
1273
+ var k;
1274
+ c = !0, y.clientX, y.clientY, f = (k = mapInstance.value) == null ? void 0 : k.getCoordinateFromPixel([y.clientX - 200, y.clientY - 200]), g = [
1275
+ y.clientX - r.getBoundingClientRect().left + 160,
1276
+ y.clientY - r.getBoundingClientRect().top + 84
1277
+ ], y.preventDefault();
1278
+ }), document.addEventListener("mousemove", function(y) {
1279
+ var k;
1280
+ if (c) {
1281
+ let L = (k = mapInstance.value) == null ? void 0 : k.getCoordinateFromPixel([y.clientX - g[0], y.clientY - g[1]]), E = L[0] - f[0], m = L[1] - f[1];
1282
+ l.setPosition([f[0] + E, f[1] + m]);
1283
+ }
1284
+ }), document.addEventListener("mouseup", function() {
1285
+ c = !1;
1286
+ });
1287
+ }
1288
+ (u = mapInstance.value) == null || u.addOverlay(l);
1289
+ const s = r.querySelector(".close-button");
1290
+ s && s.addEventListener("click", () => {
1291
+ var c, f;
1292
+ (c = mapInstance.value) == null || c.removeOverlay(l), (f = r.parentNode) == null || f.removeChild(r);
1293
+ });
1294
+ let i = JSON.parse(JSON.stringify(t));
1295
+ const d = (p = mapInstance.value) == null ? void 0 : p.getCoordinateFromPixel(i);
1296
+ return l.setPosition(d), l;
1297
+ }, vehicle = ref(null), focusShipData = ref(), currentTruckOverlay = ref(null), findTruck = async (e) => {
1298
+ if (!mapInstance.value) return;
1299
+ focusShipData.value = e;
1300
+ const t = convertSixHundredThousandToLatLng(e.lon, e.lat), o = mapInstance.value.getPixelFromCoordinate(transform(t, projection.data, projection.mercator));
1301
+ currentTruckOverlay.value = drawTruckIcon(e.vno, o, e == null ? void 0 : e.drc);
1302
+ const n = mapInstance.value.getView(), a = new Point(t);
1303
+ n.setCenter(transform(a.getCoordinates(), projection.data, projection.mercator));
1304
+ }, clearAllTruck = () => {
1305
+ vehicle.value.clearAllShip();
1306
+ }, drawTruckIcon = (e, t, o) => {
1307
+ const n = `<div id="${e}" class="ol-custom-content truck-custom-content" style="width: 80px; height: 80px; transform: rotate(${o}deg);">
1308
+ <img src="${CDN_URL}map/car-icon.gif" width="100%" height="100%" />
1309
+ </div>`;
1310
+ return drawCustomContent(e, t, n, "center-center");
1311
+ }, removeTruckIcon = () => {
1312
+ var t;
1313
+ const e = (t = currentTruckOverlay.value) == null ? void 0 : t.getElement();
1314
+ e && (e.innerHTML = "");
1315
+ }, zoomTruckIcon = () => {
1316
+ var r;
1317
+ if (!mapInstance.value) return;
1318
+ const e = mapInstance.value.getView().getZoom(), t = 120, o = 60;
1319
+ function n(l) {
1320
+ return l < 14 ? o : l >= 14 && l <= 18 ? Math.round((l - 14) * (t - o) / 4 + o) : t;
1321
+ }
1322
+ const a = n(e);
1323
+ (r = document.querySelectorAll(".truck-custom-content")) == null || r.forEach((l) => {
1324
+ l.style.width = `${a}px`, l.style.height = `${a}px`;
1325
+ });
1326
+ }, markerPosition = ref(""), marker = ref(), createIconStyle = (e) => new Style({
1327
+ image: new Icon({
1328
+ src: CDN_URL + "map/poi-marker-default.png",
1329
+ anchor: [0.5, 1]
1330
+ }),
1331
+ text: new Text({
1332
+ text: e,
1333
+ offsetY: -90,
1334
+ // 调整文本位置,使其位于标记上方
1335
+ font: "12px",
1336
+ fill: new Fill({
1337
+ color: "#000"
1338
+ }),
1339
+ stroke: new Stroke({
1340
+ color: "#fff",
1341
+ width: 2
1342
+ }),
1343
+ backgroundFill: new Fill({
1344
+ color: "#fff"
1345
+ // 设置文本背景填充颜色
1346
+ }),
1347
+ backgroundStroke: new Stroke({
1348
+ color: "#000",
1349
+ // 设置文本背景描边颜色
1350
+ width: 1
1351
+ }),
1352
+ padding: [2, 2, 2, 2]
1353
+ // 设置文本背景的内边距
1354
+ })
1355
+ }), renderMarker = (e, t = !0, o = !0) => {
1356
+ var u;
1357
+ if (!mapInstance.value || !e || e.split(",").length !== 2) return;
1358
+ const [n, a] = e.split(",").map(Number);
1359
+ marker.value = new Feature({
1360
+ geometry: new Point(fromLonLat([n, a]))
1361
+ });
1362
+ const r = o ? `${n}, ${a}` : "";
1363
+ (u = marker.value) == null || u.setStyle(createIconStyle(r));
1364
+ const l = new VectorSource({
1365
+ features: [marker.value]
1366
+ }), s = new VectorLayer({
1367
+ source: l
1368
+ }), i = mapInstance.value.getView();
1369
+ if (mapInstance.value.addLayer(s), t) {
1370
+ const p = new Translate({
1371
+ layers: [s]
1372
+ });
1373
+ p.on("translating", function(c) {
1374
+ var y;
1375
+ const f = c.features.item(0).getGeometry().getCoordinates(), g = toLonLat(f);
1376
+ markerPosition.value = `${g[0].toFixed(6)}, ${g[1].toFixed(6)}`, (y = marker.value) == null || y.setStyle(createIconStyle(markerPosition.value));
1377
+ }), mapInstance.value.addInteraction(p);
1378
+ }
1379
+ const d = new Point([n, a]);
1380
+ i.setCenter(transform(d.getCoordinates(), projection.data, projection.mercator)), i.setZoom(mapZoom.findShip);
1381
+ }, setMarkerPosition = (e) => {
1382
+ var a, r;
1383
+ if (!mapInstance.value) return;
1384
+ const t = mapInstance.value.getView(), o = e.split(",").map(Number);
1385
+ (r = (a = marker.value) == null ? void 0 : a.getGeometry()) == null || r.setCoordinates(fromLonLat([o[0], o[1]]));
1386
+ const n = new Point([o[0], o[1]]);
1387
+ t.setCenter(transform(n.getCoordinates(), projection.data, projection.mercator));
1388
+ };
1389
+ let layerState = "drawn", drawnState = "undrawn";
1390
+ const source = new VectorSource();
1391
+ let sketch, helpTooltipElement, helpTooltip, measureTooltipElement, measureTooltip;
1392
+ const circleStyle = {
1393
+ image: new CircleStyle({
1394
+ radius: 5,
1395
+ fill: new Fill({
1396
+ color: "rgb(51,112,255, 1)"
1397
+ })
1398
+ }),
1399
+ geometry: function(e) {
1400
+ const t = e.getGeometry().getCoordinates();
1401
+ return new MultiPoint(t);
1402
+ }
1403
+ }, drawVector = new VectorLayer({
1404
+ source,
1405
+ style: [
1406
+ {
1407
+ "stroke-color": "rgba(255, 255, 255, 1)",
1408
+ "stroke-width": 2,
1409
+ "fill-color": "rgba(255, 255, 255, 0.3)"
1410
+ },
1411
+ new Style(circleStyle)
1412
+ ]
1413
+ });
1414
+ let draw;
1415
+ function createMeasureTooltip() {
1416
+ var e;
1417
+ measureTooltipElement != null && measureTooltipElement.parentNode && measureTooltipElement.parentNode.removeChild(measureTooltipElement), measureTooltipElement = document.createElement("div"), measureTooltipElement.className = "ol-tooltip ol-tooltip-draw-polygon", measureTooltip = new Overlay({
1418
+ element: measureTooltipElement,
1419
+ offset: [0, -15],
1420
+ positioning: "bottom-center",
1421
+ stopEvent: !1,
1422
+ insertFirst: !1
1423
+ }), (e = mapInstance.value) == null || e.addOverlay(measureTooltip);
1424
+ }
1425
+ function createHelpTooltip() {
1426
+ var e;
1427
+ helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), helpTooltipElement = document.createElement("div"), helpTooltipElement.className = "ol-tooltip ol-help-tooltip hidden", helpTooltip = new Overlay({
1428
+ element: helpTooltipElement,
1429
+ offset: [15, 0],
1430
+ positioning: "center-left"
1431
+ }), (e = mapInstance.value) == null || e.addOverlay(helpTooltip);
1432
+ }
1433
+ let squareLimitError = !1, lineLimitError = !1;
1434
+ const validateSquareLimit = (e) => {
1435
+ let o = 1 / 0, n = -1 / 0, a = 1 / 0, r = -1 / 0;
1436
+ e == null || e.forEach((i) => {
1437
+ const d = transform(i, projection.mercator, projection.data), u = d[0], p = d[1];
1438
+ o = Math.min(o, p), n = Math.max(n, p), a = Math.min(a, u), r = Math.max(r, u);
1439
+ });
1440
+ const l = (n - o) * 111, s = (r - a) * 111;
1441
+ squareLimitError = l > 150 || s > 150;
1442
+ };
1443
+ let storeFeature;
1444
+ function addInteraction(e) {
1445
+ var o, n;
1446
+ mapInstance.value || init(), drawnState = "undrawn", layerState = "drawn", (o = mapInstance.value) == null || o.addLayer(drawVector), draw = new Draw({
1447
+ type: "Polygon",
1448
+ // source: drawVector.getSource(),
1449
+ source,
1450
+ trace: !0,
1451
+ style: [
1452
+ {
1453
+ "stroke-color": "rgba(255, 255, 255, 1)",
1454
+ "stroke-width": 1.5,
1455
+ "stroke-line-dash": [10, 10],
1456
+ "fill-color": "rgba(255, 255, 255, 0.25)"
1457
+ // "circle-radius": 6,
1458
+ // "circle-fill-color": "rgb(51,112,255, 1)"
1459
+ },
1460
+ new Style(circleStyle)
1461
+ ]
1462
+ }), (n = mapInstance.value) == null || n.addInteraction(draw), createMeasureTooltip(), createHelpTooltip();
1463
+ let t;
1464
+ draw.on("drawstart", function(a) {
1465
+ var r;
1466
+ layerState = "drawn", sketch = a.feature, t = (r = sketch.getGeometry()) == null ? void 0 : r.on("change", function(l) {
1467
+ const s = l.target;
1468
+ let i = formatArea(s, LENGTH_UNIT.NM);
1469
+ const u = s.getCoordinates()[0], p = new LineString([u[u.length - 2], u[u.length - 1]]);
1470
+ let c = formatLength(p, LENGTH_UNIT.NM);
1471
+ if (lineLimitError = Number(getLength(p) / 1e3) > 150, validateSquareLimit(u), measureTooltipElement && i && (measureTooltipElement.innerHTML = `
1472
+ <span class="text">面积:${i}${lineLimitError || squareLimitError ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1473
+ `), helpTooltipElement && i) {
1474
+ let f = "";
1475
+ parseFloat(i) > 0 && (f = `
1476
+ <div class="text ${squareLimitError ? "error" : ""}">面积:${i}${squareLimitError ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</div>`), helpTooltipElement.innerHTML = `${f}
1477
+ <span class="text ${lineLimitError ? "error" : ""}">线段${u.length - 2}:${c}${lineLimitError ? '<span class="error pl-4">超出可以绘画的距离</span>' : ""}</span>
1478
+ <div><span class="text">单击继续,双击结束</span></div>
1479
+ `;
1480
+ }
1481
+ }), drawnState = "drawing";
1482
+ }), draw.on("drawend", function(a) {
1483
+ if (a.feature.getGeometry()) {
1484
+ storeFeature = a.feature;
1485
+ const r = endFn(a.feature);
1486
+ r != null && r.length && e && e(r);
1487
+ }
1488
+ sketch = null, measureTooltipElement = null, createMeasureTooltip(), t && unByKey(t), drawnState = "drawend";
1489
+ });
1490
+ }
1491
+ function removeInteraction() {
1492
+ var e, t, o;
1493
+ mapInstance.value && (document.querySelectorAll(".ol-tooltip.ol-tooltip-draw-polygon").forEach((n) => {
1494
+ var a;
1495
+ (a = n == null ? void 0 : n.parentNode) == null || a.removeChild(n);
1496
+ }), source.clear(), (e = mapInstance.value) == null || e.removeInteraction(draw), (t = mapInstance.value) == null || t.removeLayer(drawVector), helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), ((o = mapInstance.value) == null ? void 0 : o.getTargetElement()).style.cursor = "", document.querySelector("#map").style.cursor = "", drawnState = "undrawn", layerState = "destroyed");
1497
+ }
1498
+ const endFn = (e) => {
1499
+ var t, o, n;
1500
+ if (e.getGeometry()) {
1501
+ const a = [], l = e.getGeometry().getCoordinates();
1502
+ (t = l[0]) == null || t.forEach((i) => {
1503
+ a.push(transform(i, projection.mercator, projection.data));
1504
+ });
1505
+ const s = l[0][l[0].length - 2];
1506
+ if (s && measureTooltip.setPosition(s), measureTooltip.setOffset([10, 0]), measureTooltipElement && (measureTooltipElement.innerHTML += '<span class="delete-icon"><i class="iconfont icon-delete" /></div>'), (o = document.querySelector(".delete-icon")) == null || o.addEventListener("click", () => {
1507
+ reset();
1508
+ }), !lineLimitError && !squareLimitError)
1509
+ return a;
1510
+ draw && ((n = mapInstance.value) == null || n.removeInteraction(draw)), helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement);
1511
+ }
1512
+ }, initFeature = (e) => {
1513
+ var t, o;
1514
+ if (layerState = "drawn", storeFeature) {
1515
+ const n = storeFeature.getGeometry();
1516
+ if (!n) return;
1517
+ const a = formatArea(n, LENGTH_UNIT.NM);
1518
+ measureTooltipElement && (measureTooltipElement.innerHTML = `
1519
+ <span class="text">面积:${a}${lineLimitError || squareLimitError ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1520
+ `), (t = drawVector.getSource()) == null || t.addFeature(storeFeature);
1521
+ const r = endFn(storeFeature);
1522
+ r != null && r.length && e && e(r);
1523
+ const l = getCenter(storeFeature.getGeometry().getExtent());
1524
+ (o = mapInstance.value) == null || o.getView().setCenter(l);
1525
+ }
1526
+ }, pointerMoveHandler = function(e) {
1527
+ var o;
1528
+ if (e.dragging)
1529
+ return;
1530
+ let t = "点击选择起点";
1531
+ 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");
1532
+ }, init = () => {
1533
+ mapInstance.value && (mapInstance.value.on("pointermove", pointerMoveHandler), mapInstance.value.getViewport().addEventListener("mouseout", function() {
1534
+ var e;
1535
+ (e = helpTooltipElement == null ? void 0 : helpTooltipElement.classList) == null || e.add("hidden");
1536
+ }), mapInstance.value.on("dblclick", function(e) {
1537
+ drawnState !== "undrawn" && (e.stopPropagation(), e.preventDefault());
1538
+ }));
1539
+ }, reset = () => {
1540
+ removeInteraction(), addInteraction(), storeFeature = null;
1541
+ }, drawPolygonTool = {
1542
+ addInteraction,
1543
+ removeInteraction,
1544
+ initFeature,
1545
+ reset
1546
+ }, _sfc_main = /* @__PURE__ */ defineComponent({
1547
+ __name: "Map",
1548
+ props: {
1549
+ zoom: {},
1550
+ center: {},
1551
+ vehicleMode: {}
1552
+ },
1553
+ emits: ["zoomChanged", "extentChanged"],
1554
+ setup(e, { expose: t, emit: o }) {
1555
+ const n = ref(null), a = ref(null), r = ref(null), l = o, s = e, i = ref(s.zoom || mapZoom.default), d = ref(!1), u = ref(!0), p = ref(!0);
1556
+ let c;
1557
+ ((m) => {
1558
+ m[m.tiandituTile = new TileLayer({ source: new XYZ({ url: baseMap.tiandituTile }) })] = "tiandituTile", m[m.tiandituTileMark = new TileLayer({ source: new XYZ({ url: baseMap.tiandituTileMark }) })] = "tiandituTileMark", m[m.tiandituImgTile = new TileLayer({ source: new XYZ({ url: baseMap.tiandituImgTile }), visible: !1 })] = "tiandituImgTile", m[m.tiandituImgTileMark = new TileLayer({ source: new XYZ({ url: baseMap.tiandituImgTileMark }), visible: !1 })] = "tiandituImgTileMark", m[m.greenMark = new TileLayer({ source: new XYZ({ url: baseMap.greenTile }) })] = "greenMark";
1559
+ })(c || (c = {}));
1560
+ const f = () => {
1561
+ var v, h;
1562
+ const m = {
1563
+ projection: projection.mercator,
1564
+ // 地图投影坐标系
1565
+ zoom: s.zoom || (s.vehicleMode === "ship" ? mapZoom.default : mapZoom.truckDefault),
1566
+ // 地图缩放级别(打开页面时默认级别)
1567
+ minZoom: mapZoom.min,
1568
+ // 地图缩放最小级别
1569
+ maxZoom: mapZoom.max,
1570
+ // 地图缩放最大级别
1571
+ center: lonLatToMercator(s.center || mapDefaultCenter),
1572
+ // 深圳坐标
1573
+ constrainResolution: !0,
1574
+ multiWorld: !0
1575
+ };
1576
+ mapInstance.value = new Map$1({
1577
+ target: "map",
1578
+ // 对应页面里 id 为 map 的元素
1579
+ layers: [
1580
+ // 图层
1581
+ c.tiandituTile,
1582
+ c.tiandituTileMark,
1583
+ c.tiandituImgTile,
1584
+ c.tiandituImgTileMark,
1585
+ c.greenMark
1586
+ ],
1587
+ view: new View(m)
1588
+ }), (v = a.value) == null || v.setScaleLine(), (h = mapInstance.value) == null || h.on("moveend", k), g(s.vehicleMode === "ship"), y(s.vehicleMode === "ship" ? BaseMapType.satellite : BaseMapType.vector);
1589
+ };
1590
+ onMounted(() => {
1591
+ f();
1592
+ });
1593
+ const g = (m) => {
1594
+ var v;
1595
+ (v = mapInstance.value) == null || v.getLayers().forEach((h) => {
1596
+ h.ol_uid === c.greenMark.ol_uid && (h.setVisible(m), u.value = m);
1597
+ });
1598
+ }, y = (m) => {
1599
+ var v;
1600
+ console.log("mode", m), (v = mapInstance.value) == null || v.getLayers().forEach((h) => {
1601
+ (h.ol_uid === c.tiandituTile.ol_uid || h.ol_uid === c.tiandituTileMark.ol_uid || h.ol_uid === c.tiandituImgTile.ol_uid || h.ol_uid === c.tiandituImgTileMark.ol_uid) && h.setVisible(!1), (m === BaseMapType.vector && h.ol_uid === c.tiandituTile.ol_uid || h.ol_uid === c.tiandituTileMark.ol_uid || m === BaseMapType.satellite && h.ol_uid === c.tiandituImgTile.ol_uid || h.ol_uid === c.tiandituImgTileMark.ol_uid) && (console.log(m, h.ol_uid), h.setVisible(!0));
1602
+ });
1603
+ }, k = () => {
1604
+ const m = mapInstance.value.getView(), v = m.getZoom();
1605
+ v && L(v);
1606
+ const h = m.calculateExtent(mapInstance.value.getSize());
1607
+ h && v && E(h, v);
1608
+ }, L = (m) => {
1609
+ var I, C, V, S;
1610
+ i.value = m;
1611
+ const v = (I = mapInstance.value) == null ? void 0 : I.getLayers(), h = s.vehicleMode === "ship" ? v == null ? void 0 : v.getArray().find((w) => w.ol_uid === c.greenMark.ol_uid) : void 0;
1612
+ !d.value && u.value && m < mapZoom.shipGreenDotMax ? (p.value = !0, h == null || h.setVisible(!0), (C = shipsLayer.value) == null || C.setVisible(!1), (V = largeAmountShipsLayer.value) == null || V.setVisible(!1)) : (p.value = !1, h == null || h.setVisible(!1), (S = largeAmountShipsLayer.value) == null || S.setVisible(!0)), l("zoomChanged", m);
1613
+ }, E = (m, v) => {
1614
+ const h = transform([m[0], m[1]], projection.mercator, projection.data), I = transform([m[2], m[3]], projection.mercator, projection.data);
1615
+ l("extentChanged", { extent: [h, I], zoom: v });
1616
+ };
1617
+ return t({
1618
+ mapInstance,
1619
+ initMap: f,
1620
+ renderTrucksMarker,
1621
+ renderShip: renderShips,
1622
+ renderTrack,
1623
+ findTruck,
1624
+ removeTruckIcon,
1625
+ clearAllTruck,
1626
+ closeTrack: () => {
1627
+ var m;
1628
+ (m = shipTrackVectorLayer.value) == null || m.setVisible(!1);
1629
+ },
1630
+ closeTruckTrack: () => {
1631
+ var m;
1632
+ (m = shipTrackVectorLayer.value) == null || m.setVisible(!1);
1633
+ },
1634
+ clearSelectFeature,
1635
+ findShip,
1636
+ focusShip: (m, v) => {
1637
+ var h, I;
1638
+ (h = shipsLayer.value) == null || h.setVisible(!1), (I = largeAmountShipsLayer.value) == null || I.setVisible(!1), findShip(m, v);
1639
+ },
1640
+ showTracks,
1641
+ removeAllTrackLayer,
1642
+ switchFilterItem,
1643
+ rerenderShip,
1644
+ switchGreenDot: () => g(!1),
1645
+ zoomTruckIcon,
1646
+ renderTruckTrack: (m, v, h) => {
1647
+ renderTrack(m, v, h, LENGTH_UNIT.KM, "truck");
1648
+ },
1649
+ renderMarker,
1650
+ setMarkerPosition,
1651
+ drawPolygonTool
1652
+ }), (m, v) => (openBlock(), createElementBlock("div", {
1653
+ class: "map-page map-container",
1654
+ ref_key: "pageRef",
1655
+ ref: n
1656
+ }, [
1657
+ v[0] || (v[0] = createElementVNode("div", {
1658
+ id: "map",
1659
+ class: "map"
1660
+ }, null, -1)),
1661
+ createVNode(ToolPanel, {
1662
+ "vehicle-mode": m.vehicleMode,
1663
+ onSwitchGreenDot: g,
1664
+ onSwitchMapTile: y
1665
+ }, null, 8, ["vehicle-mode"]),
1666
+ createVNode(ScaleLine, {
1667
+ ref_key: "scaleLineControl",
1668
+ ref: a
1669
+ }, null, 512),
1670
+ createVNode(ZoomControl, {
1671
+ ref_key: "zoomControl",
1672
+ ref: r
1673
+ }, null, 512),
1674
+ createVNode(Copyright),
1675
+ createVNode(Fullscreen, { page: n.value }, null, 8, ["page"])
1676
+ ], 512));
1677
+ }
1678
+ }), Map = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-08679314"]]), ZhMap = withInstall(Map);
1679
+ export {
1680
+ ZhMap as Z
1681
+ };