zhihao-ui 1.3.20 → 1.3.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.
@@ -4,16 +4,16 @@ import { _ as _export_sfc } from "./Button-CGndQwez.js";
4
4
  import { w as withInstall } from "./utils-D2wHR1YB.js";
5
5
  const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
6
6
  __name: "scaleLine",
7
- setup(e, { expose: s }) {
8
- return s({
9
- setScaleLine: (n, i) => {
10
- i || (i = "metric");
7
+ setup(e, { expose: l }) {
8
+ return l({
9
+ setScaleLine: (s, c) => {
10
+ c || (c = "metric");
11
11
  const t = new ScaleLine$1({
12
- units: i
13
- }), m = document.getElementById("scale-line-container");
14
- m && (t.setTarget(m), n.addControl(t));
12
+ units: c
13
+ }), L = document.getElementById("scale-line-container");
14
+ L && (t.setTarget(L), s.addControl(t));
15
15
  }
16
- }), (n, i) => (openBlock(), createElementBlock("div", _hoisted_1$2));
16
+ }), (s, c) => (openBlock(), createElementBlock("div", _hoisted_1$2));
17
17
  }
18
18
  }), ScaleLine = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2bc5dee8"]]), _hoisted_1$1 = { class: "zoom" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
19
19
  __name: "zoomControl",
@@ -24,28 +24,28 @@ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__
24
24
  }
25
25
  },
26
26
  setup(e) {
27
- const s = e;
28
- console.log("props", s);
29
- const l = () => {
27
+ const l = e;
28
+ console.log("props", l);
29
+ const n = () => {
30
30
  console.log("props");
31
- const { setZoom: i, getZoom: t, getInstall: m } = s.mapInstance.methods;
32
- if (!m()) return;
31
+ const { setZoom: c, getZoom: t, getInstall: L } = l.mapInstance.methods;
32
+ if (!L()) return;
33
33
  const o = t();
34
- o && i(o + 1);
35
- }, n = () => {
36
- const { setZoom: i, getZoom: t, getInstall: m } = s.mapInstance.methods;
37
- if (!m()) return;
34
+ o && c(o + 1);
35
+ }, s = () => {
36
+ const { setZoom: c, getZoom: t, getInstall: L } = l.mapInstance.methods;
37
+ if (!L()) return;
38
38
  const o = t();
39
- o && i(o - 1);
39
+ o && c(o - 1);
40
40
  };
41
- return (i, t) => (openBlock(), createElementBlock("div", _hoisted_1$1, [
41
+ return (c, t) => (openBlock(), createElementBlock("div", _hoisted_1$1, [
42
42
  createElementVNode("div", {
43
43
  class: "button big-button",
44
- onClick: l
44
+ onClick: n
45
45
  }, " + "),
46
46
  createElementVNode("div", {
47
47
  class: "button small-button",
48
- onClick: n
48
+ onClick: s
49
49
  }, " - ")
50
50
  ]));
51
51
  }
@@ -72,27 +72,27 @@ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__
72
72
  }, MAP_DEFAULT_CENTER = [114.84, 30.52], CDN_URL = "https://static.zhihaoscm.cn/", equatorialCircumference = 2003750834e-2;
73
73
  var BASE_MAP_LINK = ((e) => (e.vectorTile = `https://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.vectorTileMark = `https://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.satelliteImgTile = `https://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.satelliteImgTileMark = `https://t0.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.greenTile = `${CDN_URL}/map/tile/{z}/{x}/{y}.png`, e))(BASE_MAP_LINK || {}), LENGTH_UNIT = /* @__PURE__ */ ((e) => (e[e.M = 1] = "M", e[e.KM = 2] = "KM", e[e.NM = 3] = "NM", e))(LENGTH_UNIT || {});
74
74
  function useMapInitializer() {
75
- const e = ref(), s = () => e.value, l = () => s().getView(), n = () => {
75
+ const e = ref(), l = () => e.value, n = () => l().getView(), s = () => {
76
76
  var y;
77
- return (y = l()) == null ? void 0 : y.getZoom();
78
- }, i = (y) => {
79
- var P;
80
- (P = l()) == null || P.setZoom(y);
81
- }, t = (y, P) => {
82
- var V;
83
- (V = l()) == null || V.setCenter(fromLonLat([y, P]));
84
- }, m = () => {
85
- var P;
86
- const y = (P = l()) == null ? void 0 : P.getCenter();
77
+ return (y = n()) == null ? void 0 : y.getZoom();
78
+ }, c = (y) => {
79
+ var N;
80
+ (N = n()) == null || N.setZoom(y);
81
+ }, t = (y, N) => {
82
+ var $;
83
+ ($ = n()) == null || $.setCenter(fromLonLat([y, N]));
84
+ }, L = () => {
85
+ var N;
86
+ const y = (N = n()) == null ? void 0 : N.getCenter();
87
87
  return toLonLat(y);
88
- }, v = () => {
88
+ }, m = () => {
89
89
  var y;
90
- return (y = s()) == null ? void 0 : y.getSize();
91
- }, o = new Map$2(), r = (y, P) => {
92
- p(P);
93
- const V = {
94
- zoom: P.zoom,
95
- center: fromLonLat(P.center),
90
+ return (y = l()) == null ? void 0 : y.getSize();
91
+ }, o = new Map$2(), r = (y, N) => {
92
+ p(N);
93
+ const $ = {
94
+ zoom: N.zoom,
95
+ center: fromLonLat(N.center),
96
96
  minZoom: MAP_ZOOM.min,
97
97
  maxZoom: MAP_ZOOM.max,
98
98
  constrainResolution: !0,
@@ -109,7 +109,7 @@ function useMapInitializer() {
109
109
  o.get("satelliteImgTile"),
110
110
  o.get("satelliteImgTileMark")
111
111
  ],
112
- view: new View(V)
112
+ view: new View($)
113
113
  });
114
114
  e.value = f;
115
115
  }, p = (y) => {
@@ -145,279 +145,279 @@ function useMapInitializer() {
145
145
  }));
146
146
  };
147
147
  return {
148
- getInstall: s,
149
- getView: l,
150
- getZoom: n,
151
- setZoom: i,
148
+ getInstall: l,
149
+ getView: n,
150
+ getZoom: s,
151
+ setZoom: c,
152
152
  setCenter: t,
153
- getCenter: m,
154
- getSize: v,
153
+ getCenter: L,
154
+ getSize: m,
155
155
  initMap: r,
156
156
  setBaseLayerMap: p
157
157
  };
158
158
  }
159
- const convertSixHundredThousandToLatLng = function(e, s) {
160
- const l = Number(s) / 6e5;
161
- return [Number(e) / 6e5, l];
162
- }, calculateCirclePoints = (e, s) => {
163
- const l = fromLonLat(e), n = s * 1e3, i = [
164
- l[0] - n,
165
- l[1] - n,
166
- l[0] + n,
167
- l[1] + n
168
- ], t = transformExtent(i, projection.mercator, projection.data);
159
+ const convertSixHundredThousandToLatLng = function(e, l) {
160
+ const n = Number(l) / 6e5;
161
+ return [Number(e) / 6e5, n];
162
+ }, calculateCirclePoints = (e, l) => {
163
+ const n = fromLonLat(e), s = l * 1e3, c = [
164
+ n[0] - s,
165
+ n[1] - s,
166
+ n[0] + s,
167
+ n[1] + s
168
+ ], t = transformExtent(c, projection.mercator, projection.data);
169
169
  return {
170
170
  leftTopPoint: { lng: t[0], lat: t[3] },
171
171
  rightTopPoint: { lng: t[2], lat: t[3] },
172
172
  rightBottomPoint: { lng: t[2], lat: t[1] },
173
173
  leftBottomPoint: { lng: t[0], lat: t[1] }
174
174
  };
175
- }, formatLength = function(e, s) {
176
- const n = getLength(e);
177
- let i = "";
178
- switch (console.log(s, LENGTH_UNIT), s) {
175
+ }, formatLength = function(e, l) {
176
+ const s = getLength(e);
177
+ let c = "";
178
+ switch (console.log(l, LENGTH_UNIT), l) {
179
179
  case LENGTH_UNIT.M:
180
- i = Math.round(n * 100) / 100 + " m";
180
+ c = Math.round(s * 100) / 100 + " m";
181
181
  break;
182
182
  case LENGTH_UNIT.KM:
183
- i = Math.round(n / 1e3 * 100) / 100 + " km";
183
+ c = Math.round(s / 1e3 * 100) / 100 + " km";
184
184
  break;
185
185
  case LENGTH_UNIT.NM:
186
- i = (Math.round(n / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
186
+ c = (Math.round(s / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
187
187
  break;
188
188
  }
189
- return i;
189
+ return c;
190
190
  };
191
191
  function lonLatToMercator(e) {
192
- const s = e[0] * equatorialCircumference / 180;
193
- let l = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
194
- return l = l * equatorialCircumference / 180, [s, l];
192
+ const l = e[0] * equatorialCircumference / 180;
193
+ let n = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
194
+ return n = n * equatorialCircumference / 180, [l, n];
195
195
  }
196
196
  function getIconFont(unicode = "") {
197
197
  return unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), unicode.indexOf("&amp") !== -1 && (unicode = unicode.replace("&amp", "&")), eval('("' + unicode.replace("&#x", "\\u").replace(";", "") + '")');
198
198
  }
199
199
  const getIconStyle = (e) => {
200
- const s = new Text({
200
+ const l = new Text({
201
201
  font: "Normal 14px map-iconfont",
202
202
  text: getIconFont(e),
203
203
  fill: new Fill({ color: "#fff" }),
204
204
  offsetY: -14
205
205
  });
206
206
  return new Style({
207
- text: s,
207
+ text: l,
208
208
  zIndex: 100
209
209
  });
210
- }, mercatorToLonLat = (e, s = "lonlat") => {
211
- const l = { lon: 0, lat: 0 }, n = e[0] / equatorialCircumference * 180;
212
- let i = e[1] / equatorialCircumference * 180;
213
- return i = 180 / Math.PI * (2 * Math.atan(Math.exp(i * Math.PI / 180)) - Math.PI / 2), l.lon = n, l.lat = i, s === "lonlat" ? l : [n, i];
210
+ }, mercatorToLonLat = (e, l = "lonlat") => {
211
+ const n = { lon: 0, lat: 0 }, s = e[0] / equatorialCircumference * 180;
212
+ let c = e[1] / equatorialCircumference * 180;
213
+ return c = 180 / Math.PI * (2 * Math.atan(Math.exp(c * Math.PI / 180)) - Math.PI / 2), n.lon = s, n.lat = c, l === "lonlat" ? n : [s, c];
214
214
  }, formatMinutesToDDHHMM = (e) => {
215
- const s = hooks.duration(e, "minutes"), l = Math.floor(s.asDays()), n = s.hours(), i = s.minutes();
216
- let t = `${String(i).padStart(2, "0")}分`;
217
- return n !== 0 && (t = `${String(n).padStart(2, "0")}时${t}`), l !== 0 && (t = `${String(l).padStart(2, "0")}天${t}`), t;
218
- }, useCarTrackManager = (e, s) => {
219
- let l = null;
220
- const n = async (p) => {
215
+ const l = hooks.duration(e, "minutes"), n = Math.floor(l.asDays()), s = l.hours(), c = l.minutes();
216
+ let t = `${String(c).padStart(2, "0")}分`;
217
+ return s !== 0 && (t = `${String(s).padStart(2, "0")}时${t}`), n !== 0 && (t = `${String(n).padStart(2, "0")}天${t}`), t;
218
+ }, useCarTrackManager = (e, l) => {
219
+ let n = null;
220
+ const s = async (p) => {
221
221
  if (!e || (console.log("vehicleInfo", p), !(p != null && p.lon && (p != null && p.lat)))) return;
222
222
  const y = Math.abs(Number(p.lon)) > 180 ? convertSixHundredThousandToLatLng(p.lon, p.lat) : [p.lon, p.lat];
223
- i(p, fromLonLat(y));
224
- const P = e == null ? void 0 : e.getView(), V = new Point(y);
225
- P.setCenter(transform(V.getCoordinates(), projection.data, projection.mercator));
226
- }, i = (p, y) => {
227
- const P = `${CDN_URL}map/car-icon.gif`;
228
- l || (l = new Overlay({
223
+ c(p, fromLonLat(y));
224
+ const N = e == null ? void 0 : e.getView(), $ = new Point(y);
225
+ N.setCenter(transform($.getCoordinates(), projection.data, projection.mercator));
226
+ }, c = (p, y) => {
227
+ const N = `${CDN_URL}map/car-icon.gif`;
228
+ n || (n = new Overlay({
229
229
  element: document.createElement("div"),
230
230
  positioning: "center-center",
231
231
  stopEvent: !1
232
232
  // 允许交互事件穿透
233
- }), e.addOverlay(l));
234
- const V = l.getElement();
235
- V.style.backgroundImage = `url(${P})`, V.style.width = "80px", V.style.height = "80px";
233
+ }), e.addOverlay(n));
234
+ const $ = n.getElement();
235
+ $.style.backgroundImage = `url(${N})`, $.style.width = "80px", $.style.height = "80px";
236
236
  const f = (p == null ? void 0 : p.drc) || "";
237
- V.style.transform = `rotate(${f}deg)`, V.style.backgroundSize = "cover", l == null || l.setPosition(y);
237
+ $.style.transform = `rotate(${f}deg)`, $.style.backgroundSize = "cover", n == null || n.setPosition(y);
238
238
  };
239
239
  return {
240
- location: n,
240
+ location: s,
241
241
  remove: () => {
242
- const p = l == null ? void 0 : l.getElement();
242
+ const p = n == null ? void 0 : n.getElement();
243
243
  p && (p.innerHTML = "");
244
244
  },
245
- renderTrack: (p, y, P) => {
246
- s.render(p, y, P, "truck", 1e3);
245
+ renderTrack: (p, y, N) => {
246
+ l.render(p, y, N, "truck", 1e3);
247
247
  },
248
248
  setCenter: (p) => {
249
- s.setCenter(p);
249
+ l.setCenter(p);
250
250
  },
251
251
  closeTrack: () => {
252
- s.close();
252
+ l.close();
253
253
  },
254
254
  playTrack: (p, y) => {
255
- s.play(p, y);
255
+ l.play(p, y);
256
256
  }
257
257
  };
258
258
  };
259
259
  var SHIP_SAIL_STATUS = /* @__PURE__ */ ((e) => (e[e.发动机使用中 = 0] = "发动机使用中", e[e.锚泊 = 1] = "锚泊", e[e.未操作 = 2] = "未操作", e[e.操纵能力受限 = 3] = "操纵能力受限", e[e.吃水受限 = 4] = "吃水受限", e[e.系泊 = 5] = "系泊", e[e.搁浅 = 6] = "搁浅", e[e.从事捕捞 = 7] = "从事捕捞", e[e.航行中 = 8] = "航行中", e[e.留作将来修正导航状态 = 9] = "留作将来修正导航状态", e[e.高速船留用 = 10] = "高速船留用", e[e.机动船尾推作业 = 11] = "机动船尾推作业", e[e.机动船顶推或侧推作业 = 12] = "机动船顶推或侧推作业", e[e.飞翼船留用 = 13] = "飞翼船留用", e[e.现行的 = 14] = "现行的", e[e.未定义 = 15] = "未定义", e))(SHIP_SAIL_STATUS || {}), SHIP_DIRECT = /* @__PURE__ */ ((e) => (e.left = "left", e.right = "right", e.front = "front", e.up = "up", e.down = "down", e.back = "back", e))(SHIP_DIRECT || {});
260
260
  const useTrackManager = (e) => {
261
- const s = /* @__PURE__ */ new Map(), l = {};
262
- let n = null;
263
- const i = "--";
261
+ const l = /* @__PURE__ */ new Map(), n = {};
262
+ let s = null;
263
+ const c = "--";
264
264
  let t = null;
265
- const m = document.createElement("div"), v = new Overlay({
266
- element: m,
265
+ const L = document.createElement("div"), m = new Overlay({
266
+ element: L,
267
267
  positioning: "top-left",
268
268
  stopEvent: !1,
269
269
  className: "track-label-popup"
270
270
  });
271
- let o, r, p, y, P, V = !1, f = Date.now(), w, k = 0, L = null, S = 20, _ = !1;
272
- const H = 5, B = [], W = (a) => {
273
- var d;
274
- for (B.unshift(a); B.length > H; ) {
275
- const g = B.pop(), b = s.get(g);
276
- b && ((d = b.getSource()) == null || d.clear(), e == null || e.removeLayer(b), s.delete(g), delete l[g]);
271
+ let o, r, p, y, N, $ = !1, f = Date.now(), v, k = 0, x = null, C = 20, A = !1;
272
+ const H = 5, B = [], W = (i) => {
273
+ var u;
274
+ for (B.unshift(i); B.length > H; ) {
275
+ const g = B.pop(), b = l.get(g);
276
+ b && ((u = b.getSource()) == null || u.clear(), e == null || e.removeLayer(b), l.delete(g), delete n[g]);
277
277
  }
278
278
  };
279
- let c = "";
280
- const x = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], u = debounce(() => {
281
- if (n && l[n] && s.get(n).getVisible() && _) {
279
+ let d = "";
280
+ const w = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], a = debounce(() => {
281
+ if (s && n[s] && l.get(s).getVisible() && A) {
282
282
  console.log("reRenderTrackLine------------");
283
- const a = cloneDeep(M(n, l[n]));
284
- ce(n, a);
283
+ const i = cloneDeep(M(s, n[s]));
284
+ ae(s, i);
285
285
  }
286
- }, 300), M = (a, d) => {
286
+ }, 300), M = (i, u) => {
287
287
  let g = [];
288
- const b = Math.max(1, Math.floor(d.length / S));
289
- return g = d.filter((T, R) => R % b === 0).map((T, R) => {
288
+ const b = Math.max(1, Math.floor(u.length / C));
289
+ return g = u.filter((T, _) => _ % b === 0).map((T, _) => {
290
290
  if (Number(T.lon) > 180 || Number(T.lat) > 180) {
291
- const [$, A] = convertSixHundredThousandToLatLng(T.lon, T.lat);
292
- T.lon = $, T.lat = A;
291
+ const [D, z] = convertSixHundredThousandToLatLng(T.lon, T.lat);
292
+ T.lon = D, T.lat = z;
293
293
  }
294
- return T.center = [T.lon, T.lat], T.centerPoint = lonLatToMercator(T.center), T.time = hooks(T.createdAt).format("YYYY-MM-DD HH:mm:ss"), T.id = a, T.index = R, T;
294
+ return T.center = [T.lon, T.lat], T.centerPoint = lonLatToMercator(T.center), T.time = hooks(T.createdAt).format("YYYY-MM-DD HH:mm:ss"), T.id = i, T.index = _, T;
295
295
  }), g;
296
- }, D = async (a, d, g, b = "ship", C = 200) => {
297
- if (!e || (d = d == null ? void 0 : d.reverse(), v && b === "ship" && (e != null && e.getOverlays().getArray().includes(v) || e.addOverlay(v)), (d == null ? void 0 : d.length) < 2))
296
+ }, F = async (i, u, g, b = "ship", E = 200) => {
297
+ if (!e || (u = u == null ? void 0 : u.reverse(), m && b === "ship" && (e != null && e.getOverlays().getArray().includes(m) || e.addOverlay(m)), (u == null ? void 0 : u.length) < 2))
298
298
  return;
299
- W(a), n = a, l[a] = d, S = C;
300
- const T = Object.keys(l).findIndex((R) => R === a) || 0;
301
- c = g || x[T > 10 ? 10 : T], _ = !0, await z(), await ne(n);
302
- }, N = (a) => {
303
- const d = new VectorSource();
299
+ W(i), s = i, n[i] = u, C = E;
300
+ const T = Object.keys(n).findIndex((_) => _ === i) || 0;
301
+ d = g || w[T > 10 ? 10 : T], A = !0, await R(), await se(s);
302
+ }, V = (i) => {
303
+ const u = new VectorSource();
304
304
  return new VectorLayer({
305
- source: d,
305
+ source: u,
306
306
  visible: !1,
307
307
  // 默认隐藏
308
- className: `track-layer-${a}`,
308
+ className: `track-layer-${i}`,
309
309
  renderBuffer: 1024
310
310
  // 增大渲染缓冲区
311
311
  });
312
- }, O = (a) => {
313
- s.forEach((d, g) => {
314
- var C;
315
- const b = g === a;
316
- d.getVisible() !== b && (d.setVisible(b), e.getLayers().getArray().includes(d) || e.addLayer(d), b || (C = d.getSource()) == null || C.clear());
317
- }), n = a;
318
- }, z = async () => {
319
- const a = n;
320
- if (!s.has(a)) {
321
- const T = N(a);
322
- s.set(a, T);
312
+ }, O = (i) => {
313
+ l.forEach((u, g) => {
314
+ var E;
315
+ const b = g === i;
316
+ u.getVisible() !== b && (u.setVisible(b), e.getLayers().getArray().includes(u) || e.addLayer(u), b || (E = u.getSource()) == null || E.clear());
317
+ }), s = i;
318
+ }, R = async () => {
319
+ const i = s;
320
+ if (!l.has(i)) {
321
+ const T = V(i);
322
+ l.set(i, T);
323
323
  }
324
- await O(a);
325
- const d = c || "", g = l[a] || [];
324
+ await O(i);
325
+ const u = d || "", g = n[i] || [];
326
326
  if (!(g && g.length > 1)) return [];
327
327
  let b = [];
328
- b = M(a, g);
329
- const C = b.map((T) => T.centerPoint);
330
- b.length >= 2 && await F(a, C, d);
331
- }, F = (a, d, g) => {
332
- const b = new LineString(d), C = s.get(a).getSource(), T = C.getFeatureById(a);
328
+ b = M(i, g);
329
+ const E = b.map((T) => T.centerPoint);
330
+ b.length >= 2 && await P(i, E, u);
331
+ }, P = (i, u, g) => {
332
+ const b = new LineString(u), E = l.get(i).getSource(), T = E.getFeatureById(i);
333
333
  if (T)
334
- T.setGeometry(b), T.setId(a), T.setStyle(Z(g)), L = T;
334
+ T.setGeometry(b), T.setId(i), T.setStyle(Z(g)), x = T;
335
335
  else {
336
- const R = new Feature({ geometry: b });
337
- R.setId(a), R.set("type", "line"), R.setStyle(Z(g)), C.addFeature(R), L = R;
336
+ const _ = new Feature({ geometry: b });
337
+ _.setId(i), _.set("type", "line"), _.setStyle(Z(g)), E.addFeature(_), x = _;
338
338
  }
339
- return L;
340
- }, Z = (a) => new Style({
339
+ return x;
340
+ }, Z = (i) => new Style({
341
341
  stroke: new Stroke({
342
- color: a,
342
+ color: i,
343
343
  width: 2
344
344
  })
345
- }), K = (a, d, g) => {
346
- const b = a == null ? void 0 : a.get("trackId");
347
- if (a && b && d === "hover") {
345
+ }), K = (i, u, g) => {
346
+ const b = i == null ? void 0 : i.get("trackId");
347
+ if (i && b && u === "hover") {
348
348
  e.getTargetElement().style.cursor = b ? "pointer" : "";
349
- const C = a.get("data"), T = Q(C), R = g == null ? void 0 : g.coordinate;
350
- R && (m.querySelector(".popup-content"), m.innerHTML = T, v == null || v.setPosition(R));
349
+ const E = i.get("data"), T = Q(E), _ = g == null ? void 0 : g.coordinate;
350
+ _ && (L.querySelector(".popup-content"), L.innerHTML = T, m == null || m.setPosition(_));
351
351
  } else
352
- v && v.setPosition(void 0);
353
- }, Q = (a) => {
354
- if (!(a != null && a.time)) return;
355
- let d = "";
356
- return a != null && a.stayTime && (d = `
352
+ m && m.setPosition(void 0);
353
+ }, Q = (i) => {
354
+ if (!(i != null && i.time)) return;
355
+ let u = "";
356
+ return i != null && i.stayTime && (u = `
357
357
  <div class="item w-100">
358
358
  <div class="item-label">停泊时间约</div>
359
- <div class="item-item">${formatMinutesToDDHHMM(Number(a.stayTime))}</div>
359
+ <div class="item-item">${formatMinutesToDDHHMM(Number(i.stayTime))}</div>
360
360
  </div>
361
361
  `), `
362
362
  <div class="track-point-popup">
363
363
  <div class="item">
364
364
  <div class="item-label">状态</div>
365
- <div class="item-item">${a != null && a.sailStatus ? SHIP_SAIL_STATUS[a.sailStatus] : i}</div>
365
+ <div class="item-item">${i != null && i.sailStatus ? SHIP_SAIL_STATUS[i.sailStatus] : c}</div>
366
366
  </div>
367
367
  <div class="item">
368
368
  <div class="item-label">航速</div>
369
- <div class="item-item">${a.speed || i}</div>
369
+ <div class="item-item">${i.speed || c}</div>
370
370
  </div>
371
371
  <div class="item">
372
372
  <div class="item-label">艏向</div>
373
- <div class="item-item">${a.hdg || i}</div>
373
+ <div class="item-item">${i.hdg || c}</div>
374
374
  </div>
375
375
  <div class="item">
376
376
  <div class="item-label">航向</div>
377
- <div class="item-item">${a.cog || i}</div>
377
+ <div class="item-item">${i.cog || c}</div>
378
378
  </div>
379
379
  <div class="item">
380
380
  <div class="item-label">经度</div>
381
- <div class="item-item">${a.lon || i}</div>
381
+ <div class="item-item">${i.lon || c}</div>
382
382
  </div>
383
383
  <div class="item">
384
384
  <div class="item-label">纬度</div>
385
- <div class="item-item">${a.lat || i}</div>
385
+ <div class="item-item">${i.lat || c}</div>
386
386
  </div>
387
387
  <div class="item w-100">
388
388
  <div class="item-label">时间</div>
389
- <div class="item-item">${a.time}</div>
389
+ <div class="item-item">${i.time}</div>
390
390
  </div>
391
- ${d ?? d}
391
+ ${u ?? u}
392
392
  </div>`;
393
- }, ie = (a) => {
394
- const g = a.map(($) => {
395
- const A = e.getPixelFromCoordinate(fromLonLat($.center));
393
+ }, U = (i) => {
394
+ const g = i.map((D) => {
395
+ const z = e.getPixelFromCoordinate(fromLonLat(D.center));
396
396
  return {
397
- ...$,
398
- original: $,
399
- pixel: A,
397
+ ...D,
398
+ original: D,
399
+ pixel: z,
400
400
  distance: 0
401
401
  // 先初始化,后续计算
402
402
  };
403
403
  });
404
404
  let b = 0;
405
405
  g[0].distance = 0;
406
- for (let $ = 1; $ < g.length; $++) {
407
- const A = g[$ - 1].pixel, Y = g[$].pixel, X = Y[0] - A[0], E = Y[1] - A[1];
408
- b += Math.sqrt(X * X + E * E), g[$].distance = b;
406
+ for (let D = 1; D < g.length; D++) {
407
+ const z = g[D - 1].pixel, Y = g[D].pixel, X = Y[0] - z[0], S = Y[1] - z[1];
408
+ b += Math.sqrt(X * X + S * S), g[D].distance = b;
409
409
  }
410
- const C = g.filter(
411
- ($, A) => A === 0 || A === g.length - 1
410
+ const E = g.filter(
411
+ (D, z) => z === 0 || z === g.length - 1
412
412
  ), T = [];
413
- for (let $ = 0; $ < C.length; $++) {
414
- const A = C[$];
415
- if (T.push(A), $ < C.length - 1) {
416
- const Y = C[$ + 1], X = Y.distance - A.distance, E = Math.floor(X / 100);
417
- for (let G = 1; G <= E; G++) {
418
- const j = A.distance + G * 100;
413
+ for (let D = 0; D < E.length; D++) {
414
+ const z = E[D];
415
+ if (T.push(z), D < E.length - 1) {
416
+ const Y = E[D + 1], X = Y.distance - z.distance, S = Math.floor(X / 100);
417
+ for (let G = 1; G <= S; G++) {
418
+ const j = z.distance + G * 100;
419
419
  if (j >= Y.distance) break;
420
- const q = ae(
420
+ const q = J(
421
421
  g,
422
422
  j
423
423
  );
@@ -426,29 +426,29 @@ const useTrackManager = (e) => {
426
426
  }
427
427
  }
428
428
  return Array.from(
429
- new Map(T.map(($) => [$.distance.toFixed(2), $])).values()
430
- ).map(($) => ({
431
- ...$.original,
429
+ new Map(T.map((D) => [D.distance.toFixed(2), D])).values()
430
+ ).map((D) => ({
431
+ ...D.original,
432
432
  // 优先保留原始数据
433
- ...$,
433
+ ...D,
434
434
  // 覆盖坐标等计算属性
435
- coord: $.coord,
435
+ coord: D.coord,
436
436
  // 确保使用插值后的坐标
437
- pixel: $.pixel,
438
- distance: $.distance
437
+ pixel: D.pixel,
438
+ distance: D.distance
439
439
  }));
440
440
  };
441
- function ae(a, d) {
442
- for (let g = 1; g < a.length; g++) {
443
- const b = a[g - 1], C = a[g];
444
- if (d >= b.distance && d <= C.distance) {
445
- const T = (d - b.distance) / (C.distance - b.distance), R = b.pixel[0] + T * (C.pixel[0] - b.pixel[0]), $ = b.pixel[1] + T * (C.pixel[1] - b.pixel[1]), A = e == null ? void 0 : e.getCoordinateFromPixel([R, $]);
441
+ function J(i, u) {
442
+ for (let g = 1; g < i.length; g++) {
443
+ const b = i[g - 1], E = i[g];
444
+ if (u >= b.distance && u <= E.distance) {
445
+ const T = (u - b.distance) / (E.distance - b.distance), _ = b.pixel[0] + T * (E.pixel[0] - b.pixel[0]), D = b.pixel[1] + T * (E.pixel[1] - b.pixel[1]), z = e == null ? void 0 : e.getCoordinateFromPixel([_, D]);
446
446
  return {
447
447
  ...b,
448
448
  // 继承前一个点的属性(可调整)
449
- coord: A,
450
- pixel: [R, $],
451
- distance: d,
449
+ coord: z,
450
+ pixel: [_, D],
451
+ distance: u,
452
452
  original: void 0
453
453
  // 明确标记为插值生成点
454
454
  };
@@ -456,26 +456,26 @@ const useTrackManager = (e) => {
456
456
  }
457
457
  return null;
458
458
  }
459
- const ce = async (a, d) => {
460
- await re(), await ge(a);
461
- const g = ie(d), b = g.map((T) => de(T));
462
- s.get(a).getSource().addFeatures(b), he(a, g, d, c), g.forEach((T) => {
463
- const R = ue(a, c, T);
464
- e.addOverlay(R);
459
+ const ae = async (i, u) => {
460
+ await le(), await ge(i);
461
+ const g = U(u), b = g.map((T) => de(T));
462
+ l.get(i).getSource().addFeatures(b), me(i, g, u, d), g.forEach((T) => {
463
+ const _ = ue(i, d, T);
464
+ e.addOverlay(_);
465
465
  });
466
- }, de = (a) => {
467
- const d = new Feature({
468
- geometry: new Point(a.centerPoint),
469
- data: a
466
+ }, de = (i) => {
467
+ const u = new Feature({
468
+ geometry: new Point(i.centerPoint),
469
+ data: i
470
470
  });
471
- d.set("type", "track_point"), d.set("trackId", a.id), d.set("data", a);
471
+ u.set("type", "track_point"), u.set("trackId", i.id), u.set("data", i);
472
472
  let g = [
473
- ...fe(a, c)
473
+ ...fe(i, d)
474
474
  ];
475
- return (a.index === 0 || a.index === l[a.id].length - 1) && (g = [...me(a)], d.set("type", "track_begin")), a.state !== void 0 && a.state !== null && (g = [...ye(a)], d.set("type", "track_icon")), d.setStyle(g), d;
476
- }, ue = (a, d, g) => {
475
+ return (i.index === 0 || i.index === n[i.id].length - 1) && (g = [...ve(i)], u.set("type", "track_begin")), i.state !== void 0 && i.state !== null && (g = [...ye(i)], u.set("type", "track_icon")), u.setStyle(g), u;
476
+ }, ue = (i, u, g) => {
477
477
  const b = document.createElement("div");
478
- b.className = "track-overlay-label", b.style.position = "relative", b.style.backgroundColor = "rgba(255,255,255,0.8)", b.style.border = `1px solid ${d}`, b.style.fontSize = "12px", b.innerHTML = `
478
+ b.className = "track-overlay-label", b.style.position = "relative", b.style.backgroundColor = "rgba(255,255,255,0.8)", b.style.border = `1px solid ${u}`, b.style.fontSize = "12px", b.innerHTML = `
479
479
  <span>${g.time}</span>
480
480
  <svg
481
481
  style="position: absolute;left: -20px;top: 0;"
@@ -485,10 +485,10 @@ const useTrackManager = (e) => {
485
485
  height="20">
486
486
  <line x1="0" y1="20"
487
487
  x2="20" y2="0"
488
- stroke="${d}"
488
+ stroke="${u}"
489
489
  stroke-width="1" />
490
490
  `;
491
- const C = new Overlay({
491
+ const E = new Overlay({
492
492
  element: b,
493
493
  position: fromLonLat(g.center),
494
494
  positioning: "top-left",
@@ -496,18 +496,18 @@ const useTrackManager = (e) => {
496
496
  stopEvent: !1,
497
497
  className: "track-label-time-overlay"
498
498
  });
499
- return C.set("class", "track-label-overlay"), C.set("trackId", a), C;
500
- }, re = () => {
501
- const a = e == null ? void 0 : e.getOverlays().getArray(), d = a == null ? void 0 : a.filter((g) => g.get("class") === "track-label-overlay");
502
- d && d.length > 0 && d.forEach((g) => {
499
+ return E.set("class", "track-label-overlay"), E.set("trackId", i), E;
500
+ }, le = () => {
501
+ const i = e == null ? void 0 : e.getOverlays().getArray(), u = i == null ? void 0 : i.filter((g) => g.get("class") === "track-label-overlay");
502
+ u && u.length > 0 && u.forEach((g) => {
503
503
  g.setPosition(void 0), g.dispose();
504
504
  });
505
- }, ge = (a) => {
506
- const d = s.get(a).getSource();
507
- d.forEachFeature((g) => {
508
- g.get("type") !== "line" && d.removeFeature(g);
505
+ }, ge = (i) => {
506
+ const u = l.get(i).getSource();
507
+ u.forEachFeature((g) => {
508
+ g.get("type") !== "line" && u.removeFeature(g);
509
509
  });
510
- }, fe = (a, d) => (`${a.time}`, [
510
+ }, fe = (i, u) => (`${i.time}`, [
511
511
  new Style({
512
512
  // 扩大交互热区
513
513
  image: new CircleStyle({
@@ -518,39 +518,39 @@ const useTrackManager = (e) => {
518
518
  // 轨迹点样式
519
519
  new Style({
520
520
  image: new CircleStyle({
521
- fill: new Fill({ color: d }),
521
+ fill: new Fill({ color: u }),
522
522
  stroke: new Stroke({ color: "#fff", width: 2 }),
523
523
  radius: 3
524
524
  })
525
525
  })
526
526
  // textStyle,
527
- ]), ye = (a) => {
528
- const d = "#E31818", g = "#1890FF", b = "&#xe6d2", C = new Style({
527
+ ]), ye = (i) => {
528
+ const u = "#E31818", g = "#1890FF", b = "&#xe6d2", E = new Style({
529
529
  text: new Text({
530
530
  font: "Normal 22px map-iconfont",
531
531
  text: getIconFont(b),
532
532
  offsetY: -10,
533
533
  fill: new Fill({
534
- color: Number(a.state) === 0 ? d : Number(a.state) === 1 ? g : ""
534
+ color: Number(i.state) === 0 ? u : Number(i.state) === 1 ? g : ""
535
535
  })
536
536
  }),
537
537
  zIndex: 99
538
- }), R = getIconStyle("&#xe6e2;"), A = getIconStyle("&#xe703;"), Y = [];
539
- return Number(a.state) === 0 ? Y.push(R) : Number(a.state) === 1 && Y.push(A), Y.push(C), Y;
540
- }, he = (a, d, g, b) => {
541
- const C = d || [], T = d.length;
542
- T || (C.push(g[0]), C.push(g[g.length - 1]));
543
- const R = [];
544
- for (let A = 0; A < T - 1; A++) {
538
+ }), _ = getIconStyle("&#xe6e2;"), z = getIconStyle("&#xe703;"), Y = [];
539
+ return Number(i.state) === 0 ? Y.push(_) : Number(i.state) === 1 && Y.push(z), Y.push(E), Y;
540
+ }, me = (i, u, g, b) => {
541
+ const E = u || [], T = u.length;
542
+ T || (E.push(g[0]), E.push(g[g.length - 1]));
543
+ const _ = [];
544
+ for (let z = 0; z < T - 1; z++) {
545
545
  let Y;
546
- const X = d[A], E = (d[A + 1].index + X.index) / 2;
547
- if (E % 2 === 0)
548
- Y = g[E].centerPoint;
546
+ const X = u[z], S = (u[z + 1].index + X.index) / 2;
547
+ if (S % 2 === 0)
548
+ Y = g[S].centerPoint;
549
549
  else {
550
- const G = g[Math.floor(E)], j = g[Math.ceil(E)];
550
+ const G = g[Math.floor(S)], j = g[Math.ceil(S)];
551
551
  if (G && j) {
552
- const [q, J] = G.centerPoint, [I, ee] = j.centerPoint;
553
- Y = [(q + I) / 2, (J + ee) / 2];
552
+ const [q, ee] = G.centerPoint, [te, oe] = j.centerPoint;
553
+ Y = [(q + te) / 2, (ee + oe) / 2];
554
554
  }
555
555
  }
556
556
  if (Y) {
@@ -564,69 +564,69 @@ const useTrackManager = (e) => {
564
564
  text: getIconFont("&#xe6bc;"),
565
565
  fill: new Fill({ color: b }),
566
566
  // 设置箭头旋转 角度转为弧度
567
- rotation: le(
568
- d[A].center,
569
- d[A + 1].center
567
+ rotation: ie(
568
+ u[z].center,
569
+ u[z + 1].center
570
570
  ) * (Math.PI / 180)
571
571
  })
572
572
  })
573
- ), R.push(G);
573
+ ), _.push(G);
574
574
  }
575
575
  }
576
- const $ = s.get(a).getSource();
577
- $ == null || $.addFeatures(R);
578
- }, ne = (a) => {
579
- var T, R;
580
- const d = e.getView(), g = (T = s == null ? void 0 : s.get(a)) == null ? void 0 : T.getSource(), b = L || (a ? g == null ? void 0 : g.getFeatureById(a) : null);
576
+ const D = l.get(i).getSource();
577
+ D == null || D.addFeatures(_);
578
+ }, se = (i) => {
579
+ var T, _;
580
+ const u = e.getView(), g = (T = l == null ? void 0 : l.get(i)) == null ? void 0 : T.getSource(), b = x || (i ? g == null ? void 0 : g.getFeatureById(i) : null);
581
581
  if (!b) return;
582
- const C = (R = b == null ? void 0 : b.getGeometry()) == null ? void 0 : R.getExtent();
583
- if (C != null && C.length)
582
+ const E = (_ = b == null ? void 0 : b.getGeometry()) == null ? void 0 : _.getExtent();
583
+ if (E != null && E.length)
584
584
  try {
585
- const $ = buffer(C, Math.max(C[2] - C[0], C[3] - C[1]) * 0.02);
586
- d.fit($);
587
- } catch ($) {
588
- console.log($);
585
+ const D = buffer(E, Math.max(E[2] - E[0], E[3] - E[1]) * 0.02);
586
+ u.fit(D);
587
+ } catch (D) {
588
+ console.log(D);
589
589
  }
590
- }, me = (a) => {
591
- const d = "&#xe69b;", C = a.index === 0 ? "#fcdc3f" : "#ff0000";
590
+ }, ve = (i) => {
591
+ const u = "&#xe69b;", E = i.index === 0 ? "#fcdc3f" : "#ff0000";
592
592
  return [new Style({
593
593
  text: new Text({
594
594
  font: "Normal 14px map-iconfont",
595
- text: getIconFont(d),
596
- fill: new Fill({ color: C })
595
+ text: getIconFont(u),
596
+ fill: new Fill({ color: E })
597
597
  }),
598
598
  zIndex: 101
599
599
  })];
600
- }, ve = () => {
601
- console.log("清除所有的轨迹-----"), U(), s.forEach((d) => {
600
+ }, he = () => {
601
+ console.log("清除所有的轨迹-----"), I(), l.forEach((u) => {
602
602
  var g;
603
- (g = d.getSource()) == null || g.clear(), e == null || e.removeLayer(d);
604
- }), Object.keys(l).forEach((d) => {
605
- s.delete(d), delete l[d];
606
- }), _ = !1, re();
607
- }, we = (a) => {
608
- const d = s.get(a || n);
609
- d == null || d.setVisible(!1);
603
+ (g = u.getSource()) == null || g.clear(), e == null || e.removeLayer(u);
604
+ }), Object.keys(n).forEach((u) => {
605
+ l.delete(u), delete n[u];
606
+ }), A = !1, le();
607
+ }, we = (i) => {
608
+ const u = l.get(i || s);
609
+ u == null || u.setVisible(!1);
610
610
  const g = e.getOverlays().getArray();
611
611
  for (let b = 0; b < g.length; ) {
612
- const C = g[b];
613
- C.get("class") === "track-label-overlay" ? (C.setPosition(void 0), e.removeOverlay(C)) : b++;
612
+ const E = g[b];
613
+ E.get("class") === "track-label-overlay" ? (E.setPosition(void 0), e.removeOverlay(E)) : b++;
614
614
  }
615
- U();
616
- }, pe = (a, d = LENGTH_UNIT.NM) => {
615
+ I();
616
+ }, Le = (i, u = LENGTH_UNIT.NM) => {
617
617
  const g = {
618
- id: a,
618
+ id: i,
619
619
  length: "--"
620
- }, C = (l[a] || []).map(
621
- (R) => transform([R.lon, R.lat], projection.data, projection.mercator)
622
- ), T = new LineString(C);
623
- return g.length = formatLength(T, d) || "--", g;
624
- }, Le = (a, d) => {
625
- xe(String(a), d);
626
- }, xe = (a, d) => {
627
- const g = l[String(a)], b = g == null ? void 0 : g.map((C) => [C.lon, C.lat]);
628
- b && ke(b, d);
629
- }, te = new Style({
620
+ }, E = (n[i] || []).map(
621
+ (_) => transform([_.lon, _.lat], projection.data, projection.mercator)
622
+ ), T = new LineString(E);
623
+ return g.length = formatLength(T, u) || "--", g;
624
+ }, pe = (i, u) => {
625
+ xe(String(i), u);
626
+ }, xe = (i, u) => {
627
+ const g = n[String(i)], b = g == null ? void 0 : g.map((E) => [E.lon, E.lat]);
628
+ b && ke(b, u);
629
+ }, re = new Style({
630
630
  text: new Text({
631
631
  font: "700 20px map-iconfont",
632
632
  text: getIconFont("&#xe657;"),
@@ -634,35 +634,35 @@ const useTrackManager = (e) => {
634
634
  rotation: 0
635
635
  // 初始旋转角度
636
636
  })
637
- }), be = (a, d) => {
638
- var E, G;
639
- const g = Number(50 * d), b = ((E = a.frameState) == null ? void 0 : E.time) ?? Date.now(), C = b - f;
640
- if (k = (k + g * C / 1e6) % 2, f = b, k >= 1) {
641
- U();
637
+ }), be = (i, u) => {
638
+ var S, G;
639
+ const g = Number(50 * u), b = ((S = i.frameState) == null ? void 0 : S.time) ?? Date.now(), E = b - f;
640
+ if (k = (k + g * E / 1e6) % 2, f = b, k >= 1) {
641
+ I();
642
642
  return;
643
643
  }
644
644
  const T = r.getCoordinateAt(
645
645
  k > 1 ? 2 - k : k
646
- ), R = r.getCoordinateAt(
646
+ ), _ = r.getCoordinateAt(
647
647
  k > 1 ? k - 0.01 : k
648
- ), $ = r.getCoordinateAt(
648
+ ), D = r.getCoordinateAt(
649
649
  k > 1 ? 2 - k : k + 0.01
650
- ), Y = le(
651
- mercatorToLonLat(R, "array"),
652
- mercatorToLonLat($, "array")
650
+ ), Y = ie(
651
+ mercatorToLonLat(_, "array"),
652
+ mercatorToLonLat(D, "array")
653
653
  ) * Math.PI / 180;
654
- (G = te.getText()) == null || G.setRotation(Y), y.setCoordinates(T);
655
- const X = getVectorContext(a);
656
- X.setStyle(te), X.drawGeometry(y), e == null || e.render();
654
+ (G = re.getText()) == null || G.setRotation(Y), y.setCoordinates(T);
655
+ const X = getVectorContext(i);
656
+ X.setStyle(re), X.drawGeometry(y), e == null || e.render();
657
657
  }, Me = () => {
658
- var a;
659
- V = !0, f = Date.now(), k = 0, y = ((a = p.getGeometry()) == null ? void 0 : a.clone()) || new Point([0, 0]), t && (w == null || w.on("postrender", t)), P == null || P.setGeometry(void 0);
660
- }, U = () => {
661
- V && (V = !1, P == null || P.setGeometry(void 0), t && w && w.un("postrender", t), w && (e == null || e.removeLayer(w)), w = null, P = null);
662
- }, ke = (a, d) => {
663
- V && U(), o = new Polyline({
658
+ var i;
659
+ $ = !0, f = Date.now(), k = 0, y = ((i = p.getGeometry()) == null ? void 0 : i.clone()) || new Point([0, 0]), t && (v == null || v.on("postrender", t)), N == null || N.setGeometry(void 0);
660
+ }, I = () => {
661
+ $ && ($ = !1, N == null || N.setGeometry(void 0), t && v && v.un("postrender", t), v && (e == null || e.removeLayer(v)), v = null, N = null);
662
+ }, ke = (i, u) => {
663
+ $ && I(), o = new Polyline({
664
664
  factor: 1e6
665
- }).writeGeometry(new LineString(a)), r = new Polyline({
665
+ }).writeGeometry(new LineString(i)), r = new Polyline({
666
666
  factor: 1e6
667
667
  }).readGeometry(o, {
668
668
  dataProjection: projection.data,
@@ -672,51 +672,51 @@ const useTrackManager = (e) => {
672
672
  geometry: new Point(r.getFirstCoordinate())
673
673
  });
674
674
  const g = p.getGeometry();
675
- y = g ? g.clone() : new Point([0, 0]), P = new Feature({
675
+ y = g ? g.clone() : new Point([0, 0]), N = new Feature({
676
676
  type: "geoMarker",
677
- style: te,
677
+ style: re,
678
678
  geometry: y
679
- }), w = new VectorLayer({
679
+ }), v = new VectorLayer({
680
680
  source: new VectorSource({
681
- features: [P]
681
+ features: [N]
682
682
  })
683
- }), e == null || e.addLayer(w), t = (b) => be(b, d), Me();
684
- }, le = (a, d, g) => {
685
- function b(E) {
686
- return 180 * (E % (2 * Math.PI)) / Math.PI;
683
+ }), e == null || e.addLayer(v), t = (b) => be(b, u), Me();
684
+ }, ie = (i, u, g) => {
685
+ function b(S) {
686
+ return 180 * (S % (2 * Math.PI)) / Math.PI;
687
687
  }
688
- function C(E) {
689
- return E % 360 * Math.PI / 180;
688
+ function E(S) {
689
+ return S % 360 * Math.PI / 180;
690
690
  }
691
- function T(E) {
691
+ function T(S) {
692
692
  var G;
693
- if (!E) throw new Error("Coordinate is required");
694
- if (!Array.isArray(E)) {
695
- if ((E == null ? void 0 : E.type) === "Feature" && (E == null ? void 0 : E.geometry) !== null && ((G = E == null ? void 0 : E.geometry) == null ? void 0 : G.type) === "Point")
696
- return E == null ? void 0 : E.geometry.coordinates;
697
- if (E.type === "Point") return (E == null ? void 0 : E.coordinates) || [];
693
+ if (!S) throw new Error("Coordinate is required");
694
+ if (!Array.isArray(S)) {
695
+ if ((S == null ? void 0 : S.type) === "Feature" && (S == null ? void 0 : S.geometry) !== null && ((G = S == null ? void 0 : S.geometry) == null ? void 0 : G.type) === "Point")
696
+ return S == null ? void 0 : S.geometry.coordinates;
697
+ if (S.type === "Point") return (S == null ? void 0 : S.coordinates) || [];
698
698
  }
699
- if (Array.isArray(E) && E.length >= 2 && !Array.isArray(E[0]) && !Array.isArray(E[1]))
700
- return E;
699
+ if (Array.isArray(S) && S.length >= 2 && !Array.isArray(S[0]) && !Array.isArray(S[1]))
700
+ return S;
701
701
  throw new Error(
702
702
  "Coordinate must be GeoJSON Point or an Array of numbers"
703
703
  );
704
704
  }
705
- function R(E, G, j = {}) {
705
+ function _(S, G, j = {}) {
706
706
  if (j.final)
707
- return function(Ee, Se) {
708
- return (R(Se, Ee) + 180) % 360;
709
- }(E, G);
710
- const q = T(E), J = T(G), I = C(q[0]), ee = C(J[0]), se = C(q[1]), oe = C(J[1]), Ce = Math.sin(ee - I) * Math.cos(oe), Te = Math.cos(se) * Math.sin(oe) - Math.sin(se) * Math.cos(oe) * Math.cos(ee - I);
711
- return b(Math.atan2(Ce, Te));
707
+ return function(Te, Se) {
708
+ return (_(Se, Te) + 180) % 360;
709
+ }(S, G);
710
+ const q = T(S), ee = T(G), te = E(q[0]), oe = E(ee[0]), ce = E(q[1]), ne = E(ee[1]), Ce = Math.sin(oe - te) * Math.cos(ne), Ee = Math.cos(ce) * Math.sin(ne) - Math.sin(ce) * Math.cos(ne) * Math.cos(oe - te);
711
+ return b(Math.atan2(Ce, Ee));
712
712
  }
713
- function $(E) {
714
- return !isNaN(E) && E !== null && !Array.isArray(E);
713
+ function D(S) {
714
+ return !isNaN(S) && S !== null && !Array.isArray(S);
715
715
  }
716
- function A(E, G = {}, j = {}) {
717
- return E || console.log("Coordinates are required"), Array.isArray(E) || console.log("Coordinates must be an Array"), E.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!$(E[0]) || !$(E[1])) && console.log("Coordinates must contain numbers"), Y({ type: "Point", coordinates: E }, G, j);
716
+ function z(S, G = {}, j = {}) {
717
+ return S || console.log("Coordinates are required"), Array.isArray(S) || console.log("Coordinates must be an Array"), S.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!D(S[0]) || !D(S[1])) && console.log("Coordinates must contain numbers"), Y({ type: "Point", coordinates: S }, G, j);
718
718
  }
719
- function Y(E, G = {}, j = {}) {
719
+ function Y(S, G = {}, j = {}) {
720
720
  const q = {
721
721
  type: "Feature",
722
722
  id: "",
@@ -724,34 +724,36 @@ const useTrackManager = (e) => {
724
724
  bbox: {},
725
725
  geometry: {}
726
726
  };
727
- return j.id !== void 0 && (q.id = j.id), j.bbox && (q.bbox = j.bbox), q.properties = G, q.geometry = E, q;
727
+ return j.id !== void 0 && (q.id = j.id), j.bbox && (q.bbox = j.bbox), q.properties = G, q.geometry = S, q;
728
728
  }
729
- const X = R(A(a), A(d), g);
729
+ const X = _(z(i), z(u), g);
730
730
  return X < 0 ? 360 + X : X;
731
731
  };
732
732
  return {
733
- render: D,
734
- remove: ve,
735
- play: Le,
736
- setCenter: ne,
733
+ render: F,
734
+ remove: he,
735
+ play: pe,
736
+ setCenter: se,
737
737
  close: we,
738
- getLength: pe,
738
+ getLength: Le,
739
739
  handleTrackMapEvent: K,
740
- reRenderTrackLine: u
740
+ reRenderTrackLine: a
741
741
  };
742
742
  };
743
743
  function useShipOverlay(e) {
744
- const s = ref(null);
745
- ref(null);
746
- const l = computed(() => ({
747
- "--overlay-color": e.color || "#FFF",
748
- "--bg-color": e.selected ? e.color : "#ffffff",
744
+ console.log("useShipOverlay", e);
745
+ const l = ref(null), n = computed(() => ({
746
+ "--overlay-color": "#FFF",
747
+ "--bg-color1": e.colors && e.colors[0] ? e.colors[0] : "#ffffff",
748
+ // 默认第一个颜色
749
+ "--bg-color2": e.colors && e.colors[1] ? e.colors[1] : "#ffffff",
750
+ "--bg-color": "#ffffff",
749
751
  position: "relative",
750
752
  "pointer-events": "none"
751
- })), n = computed(() => ({
753
+ })), s = computed(() => ({
752
754
  position: "relative",
753
755
  "border-radius": "1px",
754
- "background-color": "var(--bg-color)",
756
+ "background-color": "var(--content-bg)",
755
757
  color: "#000",
756
758
  padding: "2px 5px 2px 0px",
757
759
  font: "500 Normal 12px",
@@ -760,17 +762,17 @@ function useShipOverlay(e) {
760
762
  "white-space": "nowrap",
761
763
  border: "1px solid #FFF",
762
764
  "pointer-events": "auto",
763
- transition: "background-color 0.5s ease, border 0.5s ease",
765
+ // 'transition': 'background-color 0.5s ease, border 0.5s ease',
764
766
  "z-index": "1",
765
767
  display: "flex",
766
768
  "align-items": "center",
767
- animation: e.selected ? "blink 1.5s ease-in-out infinite" : "none"
768
- // 动画开关
769
- })), i = computed(() => ({
769
+ animation: e.selected ? e.colors && e.colors.length >= 2 ? "blink-dual 2s ease-in-out infinite" : "blink-single 1.5s ease-in-out infinite" : "none"
770
+ // "animation": props.selected ? 'blink 1.5s ease-in-out infinite' : 'none', // 动画开关
771
+ })), c = computed(() => ({
770
772
  width: "14px",
771
773
  height: "14px",
772
774
  margin: "1px 5px 1px 1px",
773
- "background-color": "var(--bg-color)"
775
+ "background-color": "var(--attention-bg)"
774
776
  })), t = computed(() => ({
775
777
  position: "absolute",
776
778
  top: "0px",
@@ -784,19 +786,19 @@ function useShipOverlay(e) {
784
786
  left: "-20px"
785
787
  }));
786
788
  return () => h("div", {
787
- ref: s,
789
+ ref: l,
788
790
  class: "ship-overlay-container",
789
- style: l.value
791
+ style: n.value
790
792
  }, [
791
793
  h(
792
794
  "div",
793
795
  {
794
796
  class: "ship-overlay-content",
795
- style: n.value
797
+ style: s.value
796
798
  },
797
799
  [
798
800
  h("div", {
799
- style: e.selected ? i.value : {}
801
+ style: e.selected ? c.value : {}
800
802
  }, ""),
801
803
  h("div", {
802
804
  class: "text",
@@ -851,43 +853,43 @@ function useShipOverlay(e) {
851
853
  ]);
852
854
  }
853
855
  ref([]);
854
- function addOverlay(e, s, l, n) {
855
- if (s) {
856
- const i = new Overlay({
857
- element: l,
856
+ function addOverlay(e, l, n, s) {
857
+ if (l) {
858
+ const c = new Overlay({
859
+ element: n,
858
860
  positioning: "top-left",
859
- id: "label-" + (n == null ? void 0 : n.id),
861
+ id: "label-" + (s == null ? void 0 : s.id),
860
862
  offset: [20, -20],
861
863
  autoPan: !1,
862
- position: s,
863
- className: n.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
864
+ position: l,
865
+ className: s.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
864
866
  });
865
- i.set("class", "zh-map-ship-overlay"), e.addOverlay(i);
867
+ c.set("class", "zh-map-ship-overlay"), e.addOverlay(c);
866
868
  }
867
869
  }
868
870
  const getShipDirectPath = (e) => {
869
- const { spd: s, hdg: l, cog: n } = e;
870
- return s ? l !== null && +l != 511 && n !== null ? n - +l >= 3 ? SHIP_DIRECT.right : n - +l <= -3 ? SHIP_DIRECT.left : SHIP_DIRECT.front : SHIP_DIRECT.front : "";
871
- }, createShipStyle = (e, s) => {
872
- const { shipData: l } = s.getProperties(), n = getShipType(e), i = getShipScale(e, l, n);
873
- return initShipStyle(s, i, n);
871
+ const { spd: l, hdg: n, cog: s } = e;
872
+ return l ? n !== null && +n != 511 && s !== null ? s - +n >= 3 ? SHIP_DIRECT.right : s - +n <= -3 ? SHIP_DIRECT.left : SHIP_DIRECT.front : SHIP_DIRECT.front : "";
873
+ }, createShipStyle = (e, l) => {
874
+ const { shipData: n } = l.getProperties(), s = getShipType(e), c = getShipScale(e, n, s);
875
+ return initShipStyle(l, c, s);
874
876
  }, getShipType = (e) => {
875
- const s = e == null ? void 0 : e.getView().getZoom();
876
- return s <= MAP_ZOOM.shipModelMax && s >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
877
- }, getShipScale = (e, s, l) => {
878
- if (l === "ship") {
879
- const { len: n, wid: i } = s, t = 97, m = 20, o = 1 / (e == null ? void 0 : e.getView().getResolution()), r = n * o / t, p = i * o / m, y = Math.min(r, p);
877
+ const l = e == null ? void 0 : e.getView().getZoom();
878
+ return l <= MAP_ZOOM.shipModelMax && l >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
879
+ }, getShipScale = (e, l, n) => {
880
+ if (n === "ship") {
881
+ const { len: s, wid: c } = l, t = 97, L = 20, o = 1 / (e == null ? void 0 : e.getView().getResolution()), r = s * o / t, p = c * o / L, y = Math.min(r, p);
880
882
  return y < 0.2 ? 0.2 : y > 2 ? 2 : y;
881
883
  }
882
884
  return MAP_ZOOM.scaleNum;
883
- }, initShipStyle = (e, s, l) => {
884
- const { color: n, direct: i, isHighlight: t, shipData: m } = e.getProperties(), v = ((m == null ? void 0 : m.cog) - 90 + 360) % 360;
885
+ }, initShipStyle = (e, l, n) => {
886
+ const { color: s, direct: c, isHighlight: t, shipData: L } = e.getProperties(), m = ((L == null ? void 0 : L.cog) - 90 + 360) % 360;
885
887
  return new Style({
886
888
  image: new Icon({
887
889
  src: o(),
888
- scale: s || MAP_ZOOM.scaleNum,
890
+ scale: l || MAP_ZOOM.scaleNum,
889
891
  anchor: [0.5, 0.5],
890
- rotation: v * Math.PI / 180,
892
+ rotation: m * Math.PI / 180,
891
893
  rotateWithView: !1
892
894
  })
893
895
  });
@@ -895,72 +897,73 @@ const getShipDirectPath = (e) => {
895
897
  return `data:image/svg+xml;utf8,${encodeURIComponent(r())}`;
896
898
  }
897
899
  function r() {
898
- switch (l) {
900
+ switch (n) {
899
901
  case "triangle":
900
902
  return `<svg width="41" height="24" viewBox="0 0 41 24" fill="none" xmlns="http://www.w3.org/2000/svg">
901
903
  <path d="M30.8843 12.6777L2.21343 21.7067C1.75559 21.8509 1.28947 21.509 1.28947 21.029L1.28947 2.97103C1.28947 2.49102 1.75558 2.14913 2.21342 2.29331L30.8843 11.3223C31.5471 11.531 31.5471 12.469 30.8843 12.6777Z"
902
- fill="${n}" stroke="${t ? "#FF2424" : "black"}" stroke-width="${t ? "2" : "0.578947"}" />
904
+ fill="${s}" stroke="${t ? "#FF2424" : "black"}" stroke-width="${t ? "2" : "0.578947"}" />
903
905
  <!--path船航向左边或者向前-->
904
- ${i === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${t ? "#FF2424" : "black"}" stroke-width="2"/>`}
906
+ ${c === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${t ? "#FF2424" : "black"}" stroke-width="2"/>`}
905
907
  <!--path船航向右边-->
906
- ${i === SHIP_DIRECT.right && `<path d="M30 12L40 12L40 16" stroke="${t ? "#FF2424" : "black"}" stroke-width="2"/>`}
908
+ ${c === SHIP_DIRECT.right && `<path d="M30 12L40 12L40 16" stroke="${t ? "#FF2424" : "black"}" stroke-width="2"/>`}
907
909
  <!--path黑线无左右-->
908
- ${i === SHIP_DIRECT.front && `<path d="M30 12L40 12" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
910
+ ${c === SHIP_DIRECT.front && `<path d="M30 12L40 12" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
909
911
  </svg>
910
912
  `;
911
913
  case "ship":
912
914
  return `<svg width="97" height="20" viewBox="0 0 97 20" fill="none" xmlns="http://www.w3.org/2000/svg">
913
915
  <path d="M0.289474 17.3433L0.289474 2.65655C0.289474 2.28572 0.574654 1.97725 0.944343 1.9482L22.0544 0.289473L67.5204 0.289473C67.6295 0.289473 67.7372 0.314613 67.835 0.362943L86.0565 9.3629C86.5844 9.6236 86.5844 10.3763 86.0565 10.637L67.835 19.6371C67.7372 19.6854 67.6295 19.7105 67.5203 19.7105L22.0544 19.7105L0.944343 18.0517C0.574653 18.0226 0.289474 17.7142 0.289474 17.3433Z"
914
- fill="${n}" stroke="${t ? "#FF2424" : "black"}" stroke-width="${t ? "4" : "0.578947"}"/>
915
- ${i === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
916
- ${i === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
917
- ${i === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
916
+ fill="${s}" stroke="${t ? "#FF2424" : "black"}" stroke-width="${t ? "4" : "0.578947"}"/>
917
+ ${c === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
918
+ ${c === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
919
+ ${c === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${t ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
918
920
  </svg>
919
921
  `;
920
922
  default:
921
923
  return "";
922
924
  }
923
925
  }
924
- }, selectedShipStyle = (e, s) => {
925
- const l = selectedShipElement(e, s), n = s.id, { lon: i, lat: t } = s, m = new Overlay({
926
- element: l,
927
- position: fromLonLat([i, t]),
928
- id: "selected-" + n,
926
+ }, selectedShipStyle = (e, l) => {
927
+ const n = selectedShipElement(e, l), s = l.id, { lon: c, lat: t } = l, L = new Overlay({
928
+ element: n,
929
+ position: fromLonLat([c, t]),
930
+ id: "selected-" + s,
929
931
  positioning: "center-center",
930
932
  offset: [0, 5],
931
933
  className: "ship-selected-overlay"
932
934
  });
933
- return m.set("class", "ship-overlay-selected"), m;
934
- }, selectedShipElement = (e, s) => {
935
- const l = getShipType(e), n = getShipScale(e, s, l), i = l === "ship" ? 109 : 49, t = `
936
- <svg style="transform:scale(${n});" xmlns="http://www.w3.org/2000/svg" width="${i}" height="${i}" viewBox="0 0 49 49" fill="none">
935
+ return L.set("class", "ship-overlay-selected"), L;
936
+ }, selectedShipElement = (e, l) => {
937
+ const n = getShipType(e), s = getShipScale(e, l, n), c = n === "ship" ? 109 : 49, t = `
938
+ <svg style="transform:scale(${s});" xmlns="http://www.w3.org/2000/svg" width="${c}" height="${c}" viewBox="0 0 49 49" fill="none">
937
939
  <path d="M1.99982 46.9998L1.99982 1.99982L46.9998 1.99982L46.9998 46.9998L1.99982 46.9998Z" fill="#FF2424" fill-opacity="0.2"/>
938
940
  <path fill-rule="evenodd" clip-rule="evenodd" d="M19.9998 0.5V3.5L3.49976 3.5V20H0.499756V0.500002L19.9998 0.5ZM45.4998 3.5H28.9998V0.5H48.4998V20H45.4998V3.5ZM48.4998 29L48.4998 48.5H28.9998V45.5H45.4998L45.4998 29H48.4998ZM3.49976 45.5L3.49976 29H0.499756L0.499758 48.5L19.9998 48.5V45.5L3.49976 45.5Z" fill="#FF2424"/>
939
941
  </svg>
940
- `, m = document.createElement("div");
941
- return m.className = "ship-overlay-selected", m.innerHTML = t, m;
942
- }, createLabelStyle = (e, s) => {
943
- const { shipData: l, blinking: n } = s.getProperties(), { lon: i, lat: t } = l, m = createLabelElement(s);
944
- i && t && addOverlay(e, fromLonLat([i, t]), m, { ...l, blinking: n });
942
+ `, L = document.createElement("div");
943
+ return L.className = "ship-overlay-selected", L.innerHTML = t, L;
944
+ }, createLabelStyle = (e, l) => {
945
+ const { lon: n, lat: s, blinking: c } = l, t = createLabelElement(l);
946
+ n && s && addOverlay(e, fromLonLat([n, s]), t, { ...l, blinking: c });
945
947
  }, createLabelElement = (e) => {
946
- const s = document.createElement("div");
947
- s.className = "ship-overlay-box", s.style.position = "relative";
948
- const l = e.getProperties(), { shipData: n, blinking: i, blinkingColor: t, name: m } = l, { lon: v, lat: o } = n, r = createVNode({
948
+ const l = document.createElement("div");
949
+ l.className = "ship-overlay-box", l.style.position = "relative";
950
+ const { lon: n, lat: s, blinking: c, blinkingColors: t, name: L } = e, m = createVNode({
949
951
  setup() {
950
952
  return useShipOverlay({
951
- selected: i,
952
- name: m,
953
- color: t,
954
- existDevice: n == null ? void 0 : n.existDevice,
955
- existMobile: n == null ? void 0 : n.existMobile,
956
- existWaterGauge: n == null ? void 0 : n.existWaterGauge
953
+ position: [n + 2e-3, s + 2e-3],
954
+ selected: c,
955
+ name: L,
956
+ colors: t || [],
957
+ existDevice: e == null ? void 0 : e.existDevice,
958
+ existMobile: e == null ? void 0 : e.existMobile,
959
+ existWaterGauge: e == null ? void 0 : e.existWaterGauge
957
960
  });
958
961
  }
959
962
  });
960
- return render(r, s), s;
963
+ return render(m, l), l;
961
964
  }, getRightIcons = (e) => {
962
- const s = [];
963
- return e.existDevice && s.push("&#xe687;"), e.existMobile && s.push("&#xe688;"), e.existWaterGauge && s.push("&#xe686;"), s;
965
+ const l = [];
966
+ return e.existDevice && l.push("&#xe687;"), e.existMobile && l.push("&#xe688;"), e.existWaterGauge && l.push("&#xe686;"), l;
964
967
  };
965
968
  function getRandomLineDirection() {
966
969
  const e = [
@@ -974,48 +977,48 @@ function getRandomLineDirection() {
974
977
  return e[Math.floor(Math.random() * e.length)];
975
978
  }
976
979
  const devicePixelRatio = window.devicePixelRatio || 1;
977
- function generateBase64Icon(e, s, l = "left-bottom", n = 2) {
978
- const i = document.createElement("canvas"), t = i.getContext("2d");
980
+ function generateBase64Icon(e, l, n = "left-bottom", s = 2) {
981
+ const c = document.createElement("canvas"), t = c.getContext("2d");
979
982
  if (!t) return "";
980
- const m = 2, v = 16, o = window.devicePixelRatio || 1, r = "500 12px Arial", p = "14px map-iconfont";
983
+ const L = 2, m = 16, o = window.devicePixelRatio || 1, r = "500 12px Arial", p = "14px map-iconfont";
981
984
  t.font = r;
982
- const P = t.measureText(e).width;
985
+ const N = t.measureText(e).width;
983
986
  t.font = p;
984
- const V = s.map((N) => ({ width: t.measureText(getIconFont(N)).width, height: 14 })), f = V.reduce((N, O) => N + O.width, 0), w = (s.length - 1) * n, k = m + P + f + w + m * 2, L = m + 16 + m;
985
- let S, _, H = 0, B = 0, W = 0, c = 0, x = 0, u = 0;
986
- switch (S = v + k, l) {
987
+ const $ = l.map((V) => ({ width: t.measureText(getIconFont(V)).width, height: 14 })), f = $.reduce((V, O) => V + O.width, 0), v = (l.length - 1) * s, k = L + N + f + v + L * 2, x = L + 16 + L;
988
+ let C, A, H = 0, B = 0, W = 0, d = 0, w = 0, a = 0;
989
+ switch (C = m + k, n) {
987
990
  case "right-top":
988
- _ = v + L, H = 0, B = v + L, W = v, c = 0, x = v, u = 0;
991
+ A = m + x, H = 0, B = m + x, W = m, d = 0, w = m, a = 0;
989
992
  break;
990
993
  case "right-middle":
991
- _ = L, H = 0, B = L / 2, W = v, c = L / 2, x = v, u = 0;
994
+ A = x, H = 0, B = x / 2, W = m, d = x / 2, w = m, a = 0;
992
995
  break;
993
996
  case "right-bottom":
994
- _ = v + L, H = 0, B = 0, W = v, c = v, x = v, u = v;
997
+ A = m + x, H = 0, B = 0, W = m, d = m, w = m, a = m;
995
998
  break;
996
999
  case "left-top":
997
- _ = v + L, H = k, B = v, W = k + v, c = L + v, x = 0, u = 0;
1000
+ A = m + x, H = k, B = m, W = k + m, d = x + m, w = 0, a = 0;
998
1001
  break;
999
1002
  case "left-middle":
1000
- _ = L, H = k, B = L / 2, W = k + v, c = L / 2, x = 0, u = 0;
1003
+ A = x, H = k, B = x / 2, W = k + m, d = x / 2, w = 0, a = 0;
1001
1004
  break;
1002
1005
  case "left-bottom":
1003
- _ = v + L, H = k, B = L, W = k + v, c = 0, x = 0, u = v;
1006
+ A = m + x, H = k, B = x, W = k + m, d = 0, w = 0, a = m;
1004
1007
  break;
1005
1008
  }
1006
- i.width = Math.round(S * o), i.height = Math.round(_ * o), i.style.width = `${S}px`, i.style.height = `${_}px`, t.scale(o, o), t.clearRect(0, 0, S, _), t.beginPath(), t.moveTo(H, B), t.lineTo(W, c), t.strokeStyle = "#FFF", t.lineWidth = 1, t.stroke(), t.fillStyle = "#FFF", t.fillRect(x, u, k, L), t.font = r, t.textBaseline = "middle";
1007
- const M = u + m + L / 2;
1008
- t.strokeStyle = "#ffffff", t.lineWidth = 1, t.strokeText(e, x + m, M), t.fillStyle = "#000000", t.fillText(e, x + m, M), t.font = p, t.fillStyle = "#3370ff";
1009
- let D = x + m + P + n;
1010
- return s.forEach((N, O) => {
1011
- const z = u + m + L / 2;
1012
- t.fillText(getIconFont(N), D, z), D += V[O].width + n;
1013
- }), i.toDataURL("image/png");
1009
+ c.width = Math.round(C * o), c.height = Math.round(A * o), c.style.width = `${C}px`, c.style.height = `${A}px`, t.scale(o, o), t.clearRect(0, 0, C, A), t.beginPath(), t.moveTo(H, B), t.lineTo(W, d), t.strokeStyle = "#FFF", t.lineWidth = 1, t.stroke(), t.fillStyle = "#FFF", t.fillRect(w, a, k, x), t.font = r, t.textBaseline = "middle";
1010
+ const M = a + L + x / 2;
1011
+ t.strokeStyle = "#ffffff", t.lineWidth = 1, t.strokeText(e, w + L, M), t.fillStyle = "#000000", t.fillText(e, w + L, M), t.font = p, t.fillStyle = "#3370ff";
1012
+ let F = w + L + N + s;
1013
+ return l.forEach((V, O) => {
1014
+ const R = a + L + x / 2;
1015
+ t.fillText(getIconFont(V), F, R), F += $[O].width + s;
1016
+ }), c.toDataURL("image/png");
1014
1017
  }
1015
1018
  const createLabelFeatureStyle = (e) => {
1016
- const { name: s, rightIcons: l } = e.getProperties(), n = getRandomLineDirection(), i = generateBase64Icon(s, l, n);
1019
+ const { name: l, rightIcons: n } = e.getProperties(), s = getRandomLineDirection(), c = generateBase64Icon(l, n, s);
1017
1020
  let t = [0, 0];
1018
- switch (n) {
1021
+ switch (s) {
1019
1022
  case "right-top":
1020
1023
  t = [0, 1];
1021
1024
  break;
@@ -1037,7 +1040,7 @@ const createLabelFeatureStyle = (e) => {
1037
1040
  }
1038
1041
  return new Style({
1039
1042
  image: new Icon({
1040
- src: i,
1043
+ src: c,
1041
1044
  anchor: t,
1042
1045
  displacement: [0, 0],
1043
1046
  scale: 1 / devicePixelRatio,
@@ -1046,191 +1049,206 @@ const createLabelFeatureStyle = (e) => {
1046
1049
  })
1047
1050
  });
1048
1051
  }, useShipManager = (e) => {
1049
- let s = null, l = null;
1050
- const n = new VectorSource(), i = new VectorImageLayer({
1051
- source: n,
1052
+ let l = null, n = null;
1053
+ const s = new VectorSource(), c = new VectorImageLayer({
1054
+ source: s,
1052
1055
  className: "zh-map--ship-layer",
1053
1056
  renderBuffer: 300,
1054
1057
  zIndex: 101
1055
- }), t = new VectorSource(), m = new VectorLayer({
1058
+ }), t = new VectorSource(), L = new VectorLayer({
1056
1059
  source: t,
1057
1060
  className: "zh-map--ship-label-layer",
1058
1061
  zIndex: 102,
1059
1062
  updateWhileInteracting: !1,
1060
1063
  updateWhileAnimating: !1,
1061
- declutter: function(c, x) {
1062
- return !x.get("selected");
1064
+ declutter: function(d, w) {
1065
+ return !(w && (w != null && w.get("selected")));
1063
1066
  }
1064
1067
  });
1065
- e == null || e.addLayer(i), e == null || e.addLayer(m);
1066
- let v = "", o = {}, r = {};
1067
- const p = (c) => {
1068
- if (!c || !e) return;
1069
- const x = (l == null ? void 0 : l.id) || (s == null ? void 0 : s.get("id"));
1070
- if (l) {
1071
- const u = c.filter((M) => M.id === x);
1072
- u.length === 0 ? c.push(l) : l = u[0];
1068
+ e == null || e.addLayer(c), e == null || e.addLayer(L);
1069
+ let m = "", o = {}, r = {};
1070
+ const p = (d) => {
1071
+ if (!d || !e) return;
1072
+ const w = (n == null ? void 0 : n.id) || (l == null ? void 0 : l.get("id"));
1073
+ if (n) {
1074
+ const a = d.filter((M) => M.id === w);
1075
+ a.length === 0 ? d.push(n) : n = a[0];
1073
1076
  }
1074
- V(), f(!0), W(c), P();
1075
- }, y = (c) => {
1076
- const x = (l == null ? void 0 : l.id) || (s == null ? void 0 : s.get("id")), u = fromLonLat([c == null ? void 0 : c.lon, c == null ? void 0 : c.lat]), M = c.fill || "#04C900", D = getShipDirectPath(c), N = new Feature({
1077
- geometry: new Point(u),
1077
+ $(), f(!0), W(d), N();
1078
+ }, y = (d) => {
1079
+ var P;
1080
+ const w = (n == null ? void 0 : n.id) || (l == null ? void 0 : l.get("id")), a = fromLonLat([d == null ? void 0 : d.lon, d == null ? void 0 : d.lat]), M = ((P = r[d.id]) == null ? void 0 : P.blinkColors) || [], V = M[M.length - 1] || d.fill || "#04C900", O = getShipDirectPath(d), R = new Feature({
1081
+ geometry: new Point(a),
1078
1082
  // 船舶数据
1079
- shipData: c,
1080
- id: c.id,
1081
- name: c.cnname || "未命名船舶",
1082
- selected: c.id === x,
1083
+ shipData: d,
1084
+ id: d.id,
1085
+ name: d.cnname || d.enname || d.id || "未命名船舶",
1086
+ selected: d.id === w,
1083
1087
  // 图标
1084
- rightIcons: getRightIcons(c),
1088
+ rightIcons: getRightIcons(d),
1085
1089
  // 是否闪烁
1086
- blinking: o[c.id] || !1,
1087
- // 闪烁颜色
1088
- blinkingColor: r[c.id] || "",
1090
+ // blinking: attentionShips[ship.id] || false,
1091
+ // // 闪烁颜色
1092
+ // blinkingColor: attentionShipsColor[ship.id].blinkColors || '',
1089
1093
  // 船舶颜色
1090
- color: M,
1094
+ color: V,
1091
1095
  // 船艏向的方向
1092
- direct: D,
1093
- // shipType,
1094
- // scale:scaleNum,
1095
- // rotation,
1096
+ direct: O,
1096
1097
  // 高亮
1097
1098
  isHighlight: !1
1098
1099
  });
1099
- return N.set("clickGeometry", new Circle(u)), N;
1100
- }, P = async () => {
1101
- if (!l || !e) return;
1102
- let x = e.getOverlays().getArray().find((u) => u.get("class") == "ship-overlay-selected");
1103
- if (console.log("selectedOverlay----------", x), x) {
1104
- const u = selectedShipElement(e, l);
1105
- await x.setElement(u), await x.setPosition(fromLonLat([l.lon, l.lat]));
1100
+ return R.set("clickGeometry", new Circle(a)), R;
1101
+ }, N = async () => {
1102
+ if (!n || !e) return;
1103
+ let w = e.getOverlays().getArray().find((a) => a.get("class") == "ship-overlay-selected");
1104
+ if (console.log("selectedOverlay----------", w), w) {
1105
+ const a = selectedShipElement(e, n);
1106
+ await w.setElement(a), await w.setPosition(fromLonLat([n.lon, n.lat]));
1106
1107
  } else
1107
- x = selectedShipStyle(e, l), x && e.addOverlay(x);
1108
+ w = selectedShipStyle(e, n), w && e.addOverlay(w);
1108
1109
  setTimeout(() => {
1109
- var u;
1110
- x && ((u = x.get("element")) != null && u.parentElement) && (x.get("element").parentElement.style.display = "block");
1110
+ var a;
1111
+ w && ((a = w.get("element")) != null && a.parentElement) && (w.get("element").parentElement.style.display = "block");
1111
1112
  }, 20);
1112
- }, V = () => {
1113
- e && n && (n.clear(), t.clear(), f());
1114
- }, f = (c) => {
1115
- const x = e.getOverlays().getArray().filter((u) => u.get("class") == "zh-map-ship-overlay");
1116
- if (x && x.length > 0) {
1117
- for (let u = 0; u < x.length; u++)
1118
- if (!c && x[u].get("class") !== "ship-overlay-selected") {
1119
- const M = x[u];
1113
+ }, $ = () => {
1114
+ e && s && (s.clear(), t.clear(), f());
1115
+ }, f = (d) => {
1116
+ const w = e.getOverlays().getArray().filter((a) => a.get("class") == "zh-map-ship-overlay");
1117
+ if (w && w.length > 0) {
1118
+ for (let a = 0; a < w.length; a++)
1119
+ if (!d && w[a].get("class") !== "ship-overlay-selected") {
1120
+ const M = w[a];
1120
1121
  M.setPosition(void 0), e.removeOverlay(M), M.dispose();
1121
1122
  }
1122
1123
  }
1123
- }, w = (c, x) => {
1124
- o = c, r = x;
1125
- const u = e.getOverlays().getArray(), M = n.getFeatures();
1126
- for (const D in o) {
1127
- const N = o[D], O = u.find((F) => F.getId() === "label-" + D), z = M.find((F) => D === F.get("id"));
1128
- if (O && z) {
1129
- z.set("blinking", N), z.set("blinkingColor", r[D] || "");
1130
- const F = O.getElement(), Z = createLabelElement(z), K = Z.querySelector(".ship-overlay-line"), Q = F == null ? void 0 : F.querySelector(".ship-overlay-line");
1131
- F && F !== Z && (Q && K && K.replaceWith(Q), O.setElement(Z));
1124
+ }, v = (d, w) => {
1125
+ o = d, r = w;
1126
+ const a = e.getOverlays().getArray(), M = s.getFeatures();
1127
+ for (const F in o) {
1128
+ const V = o[F], O = a.find((P) => P.getId() === "label-" + F), R = M.find((P) => F === P.get("id"));
1129
+ if (O && R) {
1130
+ const P = w[F].blinkColors, { shipData: Z, name: K } = R == null ? void 0 : R.getProperties();
1131
+ R.set("color", P[P.length - 1] || ""), R.set("blinking", V);
1132
+ const Q = {
1133
+ ...Z,
1134
+ blinking: V,
1135
+ blinkingColors: P || [],
1136
+ name: K + "(" + w[F].shipState + ")"
1137
+ }, U = O.getElement(), J = createLabelElement(Q);
1138
+ U && U !== J && O.setElement(J);
1132
1139
  }
1133
1140
  }
1134
- }, k = (c) => {
1141
+ }, k = (d) => {
1135
1142
  if (!e) return;
1136
- const x = n.getFeatures(), u = t.getFeatures(), M = s ? s.get("id") : "", D = x.filter((F) => F.get("id") !== M), N = u == null ? void 0 : u.filter((F) => F.get("id") !== M), O = /* @__PURE__ */ new Map();
1137
- c.forEach((F) => {
1138
- O.set(F.id, !0);
1143
+ const w = s.getFeatures(), a = t.getFeatures(), M = l ? l.get("id") : "", F = w.filter((P) => P.get("id") !== M), V = a == null ? void 0 : a.filter((P) => P.get("id") !== M), O = /* @__PURE__ */ new Map();
1144
+ d.forEach((P) => {
1145
+ O.set(P.id, !0);
1139
1146
  });
1140
- const z = e.getOverlays().getArray();
1141
- D.forEach((F) => {
1142
- const Z = F.get("id");
1147
+ const R = e.getOverlays().getArray();
1148
+ F.forEach((P) => {
1149
+ const Z = P.get("id");
1143
1150
  if (!O.has(Z))
1144
- F.setStyle([]);
1151
+ P.setStyle([]);
1145
1152
  else {
1146
- const Q = F.getStyle();
1147
- (Q == null ? void 0 : Q.length) == 0 && F.setStyle(createShipStyle(e, F));
1153
+ const Q = P.getStyle();
1154
+ (Q == null ? void 0 : Q.length) == 0 && P.setStyle(createShipStyle(e, P));
1148
1155
  }
1149
- const K = z.find((Q) => Q.getId() === "label-" + Z);
1156
+ const K = R.find((Q) => Q.getId() === "label-" + Z);
1150
1157
  K && K.setPosition(void 0);
1151
- }), N.forEach((F) => {
1152
- const Z = F.get("id");
1158
+ }), V.forEach((P) => {
1159
+ const Z = P.get("id");
1153
1160
  if (!O.has(Z))
1154
- F.setStyle([]);
1161
+ P.setStyle([]);
1155
1162
  else {
1156
- const K = F.getStyle();
1157
- (K == null ? void 0 : K.length) == 0 && F.setStyle(createLabelFeatureStyle(F));
1163
+ const K = P.getStyle();
1164
+ (K == null ? void 0 : K.length) == 0 && P.setStyle(createLabelFeatureStyle(P));
1158
1165
  }
1159
1166
  });
1160
- }, L = (c) => {
1161
- if (c) {
1162
- console.log("选中", c);
1163
- const x = n.getFeatures().find((M) => M.get("id") === c.id), u = t.getFeatures().find((M) => M.get("id") === c.id);
1164
- x && (s = x), u && u.set("selected", !0), l = c, P();
1167
+ }, x = (d) => {
1168
+ if (d) {
1169
+ console.log("选中", d);
1170
+ const w = s.getFeatures().find((M) => M.get("id") === d.id), a = t.getFeatures().find((M) => M.get("id") === d.id);
1171
+ w && (l = w), a && a.set("selected", !0), n = d, N();
1165
1172
  } else
1166
- console.log("取消选中"), l = null, s = null, H();
1167
- }, S = debounce((c, x, u) => {
1168
- if (c) {
1169
- const M = c.get("shipData"), D = c.get("id");
1170
- if (e.getTargetElement().style.cursor = D ? "pointer" : "", x === "click" && (L(M), u && u(D)), x === "hover") {
1171
- v && v !== D && _(), v = D;
1172
- const N = n.getFeatures().find((O) => O.get("id") === v);
1173
- N == null || N.set("isHighlight", !0), N == null || N.setStyle(createShipStyle(e, N));
1173
+ console.log("取消选中"), n = null, l = null, H();
1174
+ }, C = debounce((d, w, a) => {
1175
+ if (d) {
1176
+ const M = d.get("shipData"), F = d.get("id");
1177
+ if (e.getTargetElement().style.cursor = F ? "pointer" : "", w === "click" && (x(M), a && a(F)), w === "hover") {
1178
+ m && m !== F && A(), m = F;
1179
+ const V = s.getFeatures().find((O) => O.get("id") === m);
1180
+ V == null || V.set("isHighlight", !0), V == null || V.setStyle(createShipStyle(e, V));
1174
1181
  }
1175
1182
  } else
1176
- e.getTargetElement().style.cursor = "", _();
1177
- }, 10), _ = () => {
1178
- const c = v ? n.getFeatures().find((x) => x.get("id") === v) : null;
1179
- v = null, c == null || c.set("isHighlight", !1), c == null || c.setStyle(createShipStyle(e, c));
1183
+ e.getTargetElement().style.cursor = "", A();
1184
+ }, 10), A = () => {
1185
+ const d = m ? s.getFeatures().find((w) => w.get("id") === m) : null;
1186
+ m = null, d == null || d.set("isHighlight", !1), d == null || d.setStyle(createShipStyle(e, d));
1180
1187
  }, H = () => {
1181
1188
  try {
1182
- const x = e.getOverlays().getArray().find((u) => u.get("class") == "ship-overlay-selected");
1183
- x && x.setPosition(void 0);
1184
- } catch (c) {
1185
- console.log(c);
1189
+ const w = e.getOverlays().getArray().find((a) => a.get("class") == "ship-overlay-selected");
1190
+ w && w.setPosition(void 0);
1191
+ } catch (d) {
1192
+ console.log(d);
1186
1193
  }
1187
- }, B = (c) => {
1188
- const x = fromLonLat([c == null ? void 0 : c.lon, c == null ? void 0 : c.lat]), u = new Feature({
1189
- geometry: new Point(x),
1190
- name: c.cnname || c.enname || c.id || "未命名船舶",
1194
+ }, B = (d) => {
1195
+ const w = fromLonLat([d == null ? void 0 : d.lon, d == null ? void 0 : d.lat]), a = new Feature({
1196
+ geometry: new Point(w),
1197
+ name: d.cnname || d.enname || d.id || "未命名船舶",
1191
1198
  // 图标
1192
- rightIcons: getRightIcons(c),
1193
- selected: (c == null ? void 0 : c.id) === (l == null ? void 0 : l.id)
1199
+ rightIcons: getRightIcons(d),
1200
+ selected: (d == null ? void 0 : d.id) === (n == null ? void 0 : n.id),
1201
+ shipData: d
1194
1202
  });
1195
- u.set("id", c.id);
1196
- const M = createLabelFeatureStyle(u);
1197
- return u.setStyle(M), u;
1198
- }, W = (c) => {
1199
- const x = e.getView().getZoom();
1200
- c.forEach((u) => {
1201
- const M = y(u);
1202
- if (M.setStyle(createShipStyle(e, M)), n.addFeature(M), (l == null ? void 0 : l.id) == u.id || x >= MAP_ZOOM.shipModelMin)
1203
- if (o[u.id])
1204
- createLabelStyle(e, M);
1205
- else {
1206
- const D = B(u);
1207
- t.addFeature(D);
1203
+ a.set("id", d.id);
1204
+ const M = createLabelFeatureStyle(a);
1205
+ return a.setStyle(M), a;
1206
+ }, W = (d) => {
1207
+ const w = e.getView().getZoom();
1208
+ d.forEach((a) => {
1209
+ const M = y(a);
1210
+ if (M.setStyle(createShipStyle(e, M)), s.addFeature(M), (n == null ? void 0 : n.id) == a.id || w >= MAP_ZOOM.shipModelMin)
1211
+ if (o[a.id]) {
1212
+ if (a.id && r[a == null ? void 0 : a.id]) {
1213
+ const F = r[a == null ? void 0 : a.id] || {};
1214
+ console.log(F);
1215
+ const V = (F == null ? void 0 : F.blinkColors) || [], O = (F == null ? void 0 : F.shipState) || "", R = (a.cnname || a.enname || a.id || "未命名船舶") + "(" + O + ")", P = {
1216
+ ...a,
1217
+ name: R,
1218
+ blinking: o[a.id],
1219
+ blinkingColors: V || []
1220
+ };
1221
+ createLabelStyle(e, P);
1222
+ }
1223
+ } else {
1224
+ const F = B(a);
1225
+ t.addFeature(F);
1208
1226
  }
1209
1227
  });
1210
1228
  };
1211
1229
  return {
1212
1230
  render: p,
1213
- selected: L,
1231
+ selected: x,
1214
1232
  filter: k,
1215
- blinking: w,
1216
- clear: V,
1217
- handleShipMapEvent: S
1233
+ blinking: v,
1234
+ clear: $,
1235
+ handleShipMapEvent: C
1218
1236
  };
1219
1237
  }, useLayerManager = (e) => {
1220
- const s = () => e == null ? void 0 : e.getLayers(), l = ref("vector"), n = () => l.value, i = (o) => {
1221
- l.value = o;
1222
- const r = s();
1238
+ const l = () => e == null ? void 0 : e.getLayers(), n = ref("vector"), s = () => n.value, c = (o) => {
1239
+ n.value = o;
1240
+ const r = l();
1223
1241
  r && (r == null || r.getArray().forEach((p) => {
1224
1242
  (p.className_ === "vector" || p.className_ === "satellite") && p.setVisible(p.className_ === o);
1225
1243
  }));
1226
1244
  }, t = ref(!1);
1227
1245
  return {
1228
- getLayers: s,
1246
+ getLayers: l,
1229
1247
  getGreenTileVisible: () => t.value,
1230
1248
  setGreenTileVisible: (o) => {
1231
1249
  if (o !== t.value) {
1232
1250
  if (o) {
1233
- const r = s();
1251
+ const r = l();
1234
1252
  if (!r.getArray().find((y) => y.className_ === "greenTile")) {
1235
1253
  const y = new TileLayer({
1236
1254
  source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
@@ -1241,53 +1259,53 @@ const createLabelFeatureStyle = (e) => {
1241
1259
  r.push(y);
1242
1260
  }
1243
1261
  } else {
1244
- const r = s(), p = r.getArray().find((y) => y.className_ === "greenTile");
1262
+ const r = l(), p = r.getArray().find((y) => y.className_ === "greenTile");
1245
1263
  p && r.remove(p);
1246
1264
  }
1247
1265
  t.value = o;
1248
1266
  }
1249
1267
  },
1250
- getShowLayerType: n,
1251
- setShowLayerType: i
1268
+ getShowLayerType: s,
1269
+ setShowLayerType: c
1252
1270
  };
1253
1271
  }, usePropsManager = () => {
1254
1272
  const e = ref();
1255
1273
  return {
1256
- setProps: (n) => {
1257
- e.value = n;
1274
+ setProps: (s) => {
1275
+ e.value = s;
1258
1276
  },
1259
1277
  getProps: () => e.value
1260
1278
  };
1261
1279
  }, usePositionManager = (e) => {
1262
- const s = "zh-map-location-layer";
1263
- let l, n, i = null, t = null;
1264
- const m = (f) => {
1280
+ const l = "zh-map-location-layer";
1281
+ let n, s, c = null, t = null;
1282
+ const L = (f) => {
1265
1283
  if (!(!f || f.length === 0)) {
1266
- if (n || (n = new VectorSource()), n.clear(), t) {
1267
- const w = f.find((k) => k.id === t.id);
1268
- w ? t = w : f.push(t);
1284
+ if (s || (s = new VectorSource()), s.clear(), t) {
1285
+ const v = f.find((k) => k.id === t.id);
1286
+ v ? t = v : f.push(t);
1269
1287
  }
1270
- f.forEach((w) => {
1271
- v(w);
1272
- }), l || (l = new VectorLayer({
1273
- className: s,
1274
- source: n,
1288
+ f.forEach((v) => {
1289
+ m(v);
1290
+ }), n || (n = new VectorLayer({
1291
+ className: l,
1292
+ source: s,
1275
1293
  zIndex: 100
1276
- }), e == null || e.addLayer(l));
1294
+ }), e == null || e.addLayer(n));
1277
1295
  }
1278
- }, v = (f) => {
1279
- const w = getZoom(), [k, L] = f.latLon.split(","), S = new Feature({
1280
- geometry: new Point(fromLonLat([Number(k), Number(L)]))
1296
+ }, m = (f) => {
1297
+ const v = e == null ? void 0 : e.getView().getZoom(), [k, x] = f.latLon.split(","), C = new Feature({
1298
+ geometry: new Point(fromLonLat([Number(k), Number(x)]))
1281
1299
  });
1282
- S.setStyle(o(f, w, f.id === (t == null ? void 0 : t.id))), S.set("loactionData", f), n.addFeature(S);
1283
- }, o = (f, w, k) => {
1284
- const L = {
1300
+ C.setStyle(o(f, v, f.id === (t == null ? void 0 : t.id))), C.set("loactionData", f), s.addFeature(C);
1301
+ }, o = (f, v, k) => {
1302
+ const x = {
1285
1303
  image: new Icon({
1286
1304
  src: k && f.selectedPath || f.defaultPath,
1287
- scale: 0.5 * w / 10
1305
+ scale: 0.5 * v / 10
1288
1306
  })
1289
1307
  };
1290
- return f.name && (L.text = new Text({
1308
+ return f.name && (x.text = new Text({
1291
1309
  text: f.name,
1292
1310
  font: "12px sans-serif",
1293
1311
  fill: new Fill({
@@ -1297,57 +1315,59 @@ const createLabelFeatureStyle = (e) => {
1297
1315
  color: "#FFFFFF"
1298
1316
  }),
1299
1317
  offsetY: 30
1300
- })), new Style(L);
1318
+ })), new Style(x);
1301
1319
  }, r = () => {
1302
- if (i) {
1303
- const f = i.get("loactionData").id;
1304
- n.getFeatures().forEach((w) => {
1305
- w.get("loactionData").id !== f && n.removeFeature(w);
1320
+ if (c) {
1321
+ const f = c.get("loactionData").id;
1322
+ s.getFeatures().forEach((v) => {
1323
+ v.get("loactionData").id !== f && s.removeFeature(v);
1306
1324
  });
1307
1325
  } else
1308
- n.clear();
1326
+ s.clear();
1309
1327
  }, p = () => {
1310
- const f = i.get("loactionData"), w = getZoom();
1311
- n.getFeatures().forEach((L) => {
1312
- L.get("loactionData").id === f.id && (L == null || L.setStyle(o(f, w, !1)));
1313
- }), t = null, i = null;
1328
+ var x;
1329
+ const f = c.get("loactionData"), v = (x = e == null ? void 0 : e.getView()) == null ? void 0 : x.getZoom();
1330
+ s.getFeatures().forEach((C) => {
1331
+ C.get("loactionData").id === f.id && (C == null || C.setStyle(o(f, v, !1)));
1332
+ }), t = null, c = null;
1314
1333
  }, y = (f) => {
1315
- f ? (P(), V(f)) : clearSelectedPort();
1316
- }, P = () => {
1317
- if (i) {
1318
- const f = i.get("loactionData"), w = getZoom();
1319
- i.setStyle(o(f, w, !1));
1334
+ f ? (N(), $(f)) : clearSelectedPort();
1335
+ }, N = () => {
1336
+ var f;
1337
+ if (c) {
1338
+ const v = c.get("loactionData"), k = (f = e == null ? void 0 : e.getView()) == null ? void 0 : f.getZoom();
1339
+ c.setStyle(o(v, k, !1));
1320
1340
  }
1321
- }, V = (f) => {
1322
- const w = n.getFeatures();
1323
- t = f, i = w.find((k) => k.get("loactionData").id === f.id);
1341
+ }, $ = (f) => {
1342
+ const v = s.getFeatures();
1343
+ t = f, c = v.find((k) => k.get("loactionData").id === f.id);
1324
1344
  };
1325
1345
  return {
1326
- render: m,
1346
+ render: L,
1327
1347
  selected: y,
1328
1348
  clearSelected: p,
1329
1349
  clear: r
1330
1350
  };
1331
1351
  }, disableDoubleClickZoom = (e) => {
1332
- e.getInteractions().forEach((s) => {
1333
- s instanceof DoubleClickZoom && s.setActive(!1);
1352
+ e.getInteractions().forEach((l) => {
1353
+ l instanceof DoubleClickZoom && l.setActive(!1);
1334
1354
  });
1335
1355
  }, enableDoubleClickZoom = (e) => {
1336
- e.getInteractions().forEach((s) => {
1337
- s instanceof DoubleClickZoom && s.setActive(!0);
1356
+ e.getInteractions().forEach((l) => {
1357
+ l instanceof DoubleClickZoom && l.setActive(!0);
1338
1358
  });
1339
- }, changeCursor = (e, s) => {
1340
- const l = e.getViewport();
1341
- l && (l.style.cursor = s);
1342
- }, useDrawLineManager = (e, s) => {
1343
- const l = ref([]), n = ref("km"), i = (u) => {
1344
- n.value = u;
1359
+ }, changeCursor = (e, l) => {
1360
+ const n = e.getViewport();
1361
+ n && (n.style.cursor = l);
1362
+ }, useDrawLineManager = (e, l) => {
1363
+ const n = ref([]), s = ref("km"), c = (a) => {
1364
+ s.value = a;
1345
1365
  };
1346
1366
  let t;
1347
- const m = ref(!1), v = () => {
1348
- p(), disableDoubleClickZoom(e), changeCursor(e, "crosshair"), e.on("pointermove", V), e.getViewport().addEventListener("mouseout", () => {
1367
+ const L = ref(!1), m = () => {
1368
+ p(), disableDoubleClickZoom(e), changeCursor(e, "crosshair"), e.on("pointermove", $), e.getViewport().addEventListener("mouseout", () => {
1349
1369
  t && t.classList.add("hidden");
1350
- }), w(), m.value = !0;
1370
+ }), v(), L.value = !0;
1351
1371
  };
1352
1372
  let o, r;
1353
1373
  const p = () => {
@@ -1363,15 +1383,15 @@ const createLabelFeatureStyle = (e) => {
1363
1383
  }
1364
1384
  }), e == null || e.addLayer(r);
1365
1385
  };
1366
- let y, P;
1367
- const V = (u) => {
1368
- if (u.dragging)
1386
+ let y, N;
1387
+ const $ = (a) => {
1388
+ if (a.dragging)
1369
1389
  return;
1370
1390
  let M = "点击选择起点";
1371
- y && (M = "单击继续,双击结束"), t && (t.innerHTML = M, P.setPosition(u.coordinate), t.classList.remove("hidden"));
1391
+ y && (M = "单击继续,双击结束"), t && (t.innerHTML = M, N.setPosition(a.coordinate), t.classList.remove("hidden"));
1372
1392
  };
1373
1393
  let f;
1374
- const w = () => {
1394
+ const v = () => {
1375
1395
  f = new Draw({
1376
1396
  source: o,
1377
1397
  type: "LineString",
@@ -1396,108 +1416,108 @@ const createLabelFeatureStyle = (e) => {
1396
1416
  }),
1397
1417
  // 添加条件函数,判断是否应该出发点绘制
1398
1418
  condition: (M) => M.originalEvent.target.tagName !== "DIV"
1399
- }), e == null || e.addInteraction(f), _(), H();
1400
- let u;
1419
+ }), e == null || e.addInteraction(f), A(), H();
1420
+ let a;
1401
1421
  f.on("drawstart", function(M) {
1402
- var N;
1422
+ var V;
1403
1423
  y = M.feature, y.set("randomId", k());
1404
- let D;
1405
- u = (N = y.getGeometry()) == null ? void 0 : N.on("change", function(O) {
1406
- const z = O.target, F = computedDistance(z, n.value);
1407
- D = z.getLastCoordinate(), L && F && (L.innerHTML = F), S.setPosition(D);
1424
+ let F;
1425
+ a = (V = y.getGeometry()) == null ? void 0 : V.on("change", function(O) {
1426
+ const R = O.target, P = computedDistance(R, s.value);
1427
+ F = R.getLastCoordinate(), x && P && (x.innerHTML = P), C.setPosition(F);
1408
1428
  });
1409
1429
  }), f.on("drawend", function() {
1410
- var M, D, N;
1411
- if (L && (L.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), L != null && L.innerHTML) {
1430
+ var M, F, V;
1431
+ if (x && (x.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), x != null && x.innerHTML) {
1412
1432
  const O = (y == null ? void 0 : y.get("randomId")) || k();
1413
- l.value.push({ id: O, value: L == null ? void 0 : L.innerHTML }), L.innerHTML = `${L.innerHTML}<div class="ol-tooltip-delete-button" data-id="${O}"><i class="map-iconfont icon-delete"></i></div>`;
1433
+ n.value.push({ id: O, value: x == null ? void 0 : x.innerHTML }), x.innerHTML = `${x.innerHTML}<div class="ol-tooltip-delete-button" data-id="${O}"><i class="map-iconfont icon-delete"></i></div>`;
1414
1434
  }
1415
1435
  (M = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || M.addEventListener("click", (O) => {
1416
- var F;
1436
+ var P;
1417
1437
  O.preventDefault(), O.stopPropagation();
1418
- const z = (F = O.target) == null ? void 0 : F.getAttribute("data-id");
1419
- z && W(z);
1420
- }), S.setOffset([0, -7]), y = null, L = null, _(), u && unByKey(u), (N = (D = s.getProps()) == null ? void 0 : D.lineDrawEnd) == null || N.call(D, l.value);
1438
+ const R = (P = O.target) == null ? void 0 : P.getAttribute("data-id");
1439
+ R && W(R);
1440
+ }), C.setOffset([0, -7]), y = null, x = null, A(), a && unByKey(a), (V = (F = l.getProps()) == null ? void 0 : F.lineDrawEnd) == null || V.call(F, n.value);
1421
1441
  });
1422
1442
  }, k = () => Math.random().toString(36).substring(2, 9);
1423
- let L, S;
1424
- const _ = () => {
1425
- L != null && L.parentNode && L.parentNode.removeChild(L), L = document.createElement("div"), L.className = "ol-tooltip ol-tooltip-measure", S = new Overlay({
1426
- element: L,
1443
+ let x, C;
1444
+ const A = () => {
1445
+ x != null && x.parentNode && x.parentNode.removeChild(x), x = document.createElement("div"), x.className = "ol-tooltip ol-tooltip-measure", C = new Overlay({
1446
+ element: x,
1427
1447
  offset: [0, -15],
1428
1448
  positioning: "bottom-center",
1429
1449
  stopEvent: !1,
1430
1450
  insertFirst: !1
1431
- }), e == null || e.addOverlay(S);
1451
+ }), e == null || e.addOverlay(C);
1432
1452
  }, H = () => {
1433
- t != null && t.parentNode && t.parentNode.removeChild(t), t = document.createElement("div"), t.className = "ol-tooltip hidden", P = new Overlay({
1453
+ t != null && t.parentNode && t.parentNode.removeChild(t), t = document.createElement("div"), t.className = "ol-tooltip hidden", N = new Overlay({
1434
1454
  element: t,
1435
1455
  offset: [15, 0],
1436
1456
  positioning: "center-left"
1437
- }), e == null || e.addOverlay(P);
1457
+ }), e == null || e.addOverlay(N);
1438
1458
  }, B = () => {
1439
- l.value.forEach((u, M) => {
1440
- var O, z;
1441
- const D = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1442
- D[M] && ((z = (O = D[M]) == null ? void 0 : O.parentNode) == null || z.removeChild(D[M]));
1443
- const N = o.getFeatures();
1444
- N[M] && o.removeFeature(N[M]);
1445
- }), c(), enableDoubleClickZoom(e), m.value = !1;
1446
- }, W = (u) => {
1447
- var D, N, O, z;
1448
- const M = l.value.findIndex((F) => F.id === u);
1449
- if (M !== -1) {
1450
- l.value.splice(M, 1);
1459
+ n.value.forEach((a, M) => {
1460
+ var O, R;
1451
1461
  const F = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1452
- F[M] && ((N = (D = F[M]) == null ? void 0 : D.parentNode) == null || N.removeChild(F[M]));
1462
+ F[M] && ((R = (O = F[M]) == null ? void 0 : O.parentNode) == null || R.removeChild(F[M]));
1463
+ const V = o.getFeatures();
1464
+ V[M] && o.removeFeature(V[M]);
1465
+ }), d(), enableDoubleClickZoom(e), L.value = !1;
1466
+ }, W = (a) => {
1467
+ var F, V, O, R;
1468
+ const M = n.value.findIndex((P) => P.id === a);
1469
+ if (M !== -1) {
1470
+ n.value.splice(M, 1);
1471
+ const P = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1472
+ P[M] && ((V = (F = P[M]) == null ? void 0 : F.parentNode) == null || V.removeChild(P[M]));
1453
1473
  const Z = o.getFeatures();
1454
1474
  Z[M] && o.removeFeature(Z[M]);
1455
1475
  }
1456
- (z = (O = s.getProps()) == null ? void 0 : O.lineDrawEnd) == null || z.call(O, l.value);
1457
- }, c = () => {
1458
- if (l.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((u) => {
1476
+ (R = (O = l.getProps()) == null ? void 0 : O.lineDrawEnd) == null || R.call(O, n.value);
1477
+ }, d = () => {
1478
+ if (n.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((a) => {
1459
1479
  var M;
1460
- (M = u == null ? void 0 : u.parentNode) == null || M.removeChild(u);
1480
+ (M = a == null ? void 0 : a.parentNode) == null || M.removeChild(a);
1461
1481
  }), o.clear(), f) {
1462
- const u = e.getInteractions().getArray().find((M) => getUid(M) === getUid(f));
1463
- u && e.removeInteraction(u);
1482
+ const a = e.getInteractions().getArray().find((M) => getUid(M) === getUid(f));
1483
+ a && e.removeInteraction(a);
1464
1484
  }
1465
- e.removeLayer(r), t != null && t.parentNode && t.parentNode.removeChild(t), L != null && L.parentNode && L.parentNode.removeChild(L);
1485
+ e.removeLayer(r), t != null && t.parentNode && t.parentNode.removeChild(t), x != null && x.parentNode && x.parentNode.removeChild(x);
1466
1486
  };
1467
1487
  return {
1468
- open: v,
1488
+ open: m,
1469
1489
  close: B,
1470
1490
  deleteLine: W,
1471
- setUnit: i,
1472
- getState: () => m.value
1491
+ setUnit: c,
1492
+ getState: () => L.value
1473
1493
  };
1474
- }, computedDistance = (e, s) => {
1475
- const n = getLength(e);
1476
- let i = "";
1477
- switch (s) {
1494
+ }, computedDistance = (e, l) => {
1495
+ const s = getLength(e);
1496
+ let c = "";
1497
+ switch (l) {
1478
1498
  case "m":
1479
- i = `${Math.round(n * 100) / 100} m`;
1499
+ c = `${Math.round(s * 100) / 100} m`;
1480
1500
  break;
1481
1501
  case "km":
1482
- i = `${Math.round(n / 1e3 * 100) / 100} km`;
1502
+ c = `${Math.round(s / 1e3 * 100) / 100} km`;
1483
1503
  break;
1484
1504
  case "nm":
1485
- i = `${Math.round(n / 1.852 * 100) / 100} nm`;
1505
+ c = `${Math.round(s / 1.852 * 100) / 100} nm`;
1486
1506
  break;
1487
1507
  }
1488
- return i;
1489
- }, useDrawPolygonManager = (e, s) => {
1490
- let l, n;
1491
- const i = () => {
1508
+ return c;
1509
+ }, useDrawPolygonManager = (e, l) => {
1510
+ let n, s;
1511
+ const c = () => {
1492
1512
  t(), changeCursor(e, "crosshair");
1493
1513
  }, t = () => {
1494
- o(), L(), H(), V();
1514
+ o(), x(), H(), $();
1495
1515
  };
1496
- let m = null, v = null;
1516
+ let L = null, m = null;
1497
1517
  const o = () => {
1498
- if (m && v) return;
1499
- const c = new VectorSource(), x = new VectorLayer({
1500
- source: c,
1518
+ if (L && m) return;
1519
+ const d = new VectorSource(), w = new VectorLayer({
1520
+ source: d,
1501
1521
  style: new Style({
1502
1522
  stroke: new Stroke({
1503
1523
  color: "#fbcc33",
@@ -1505,45 +1525,45 @@ const createLabelFeatureStyle = (e) => {
1505
1525
  })
1506
1526
  })
1507
1527
  });
1508
- m = x, v = c, e.on("pointermove", p), e.addLayer(x), e.on(["dblclick"], function(u) {
1509
- y && (u.stopPropagation(), u.preventDefault());
1528
+ L = w, m = d, e.on("pointermove", p), e.addLayer(w), e.on(["dblclick"], function(a) {
1529
+ y && (a.stopPropagation(), a.preventDefault());
1510
1530
  });
1511
1531
  };
1512
1532
  let r;
1513
- const p = (c) => {
1514
- if (c.dragging) return;
1515
- const x = r ? "单击继续,双击结束" : "点击选择起点";
1516
- S && (S.innerHTML = x, _.setPosition(c.coordinate));
1533
+ const p = (d) => {
1534
+ if (d.dragging) return;
1535
+ const w = r ? "单击继续,双击结束" : "点击选择起点";
1536
+ C && (C.innerHTML = w, A.setPosition(d.coordinate));
1517
1537
  };
1518
- let y, P = !1;
1519
- const V = () => {
1520
- if (l) {
1521
- S != null && S.parentNode && S.parentNode.removeChild(S);
1522
- const c = l.getGeometry();
1523
- if (!c) return;
1524
- const x = f(c, "nm");
1525
- w && (w.innerHTML = `
1526
- <span class="text">面积:${x}${P ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1527
- `), w && (w.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
1528
- const u = c.getCoordinates(), M = u[0][u[0].length - 2];
1529
- if (k.setPosition(M), m) {
1530
- const N = m.getSource();
1531
- N && l && (N.clear(), N.addFeature(l));
1538
+ let y, N = !1;
1539
+ const $ = () => {
1540
+ if (n) {
1541
+ C != null && C.parentNode && C.parentNode.removeChild(C);
1542
+ const d = n.getGeometry();
1543
+ if (!d) return;
1544
+ const w = f(d, "nm");
1545
+ v && (v.innerHTML = `
1546
+ <span class="text">面积:${w}${N ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1547
+ `), v && (v.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
1548
+ const a = d.getCoordinates(), M = a[0][a[0].length - 2];
1549
+ if (k.setPosition(M), L) {
1550
+ const V = L.getSource();
1551
+ V && n && (V.clear(), V.addFeature(n));
1532
1552
  }
1533
1553
  setTimeout(() => {
1534
- var N;
1535
- (N = document.querySelector(".delete-icon")) == null || N.addEventListener("click", () => {
1536
- var O, z;
1537
- console.log("delete"), B(), (z = (O = s.getProps()) == null ? void 0 : O.areaDrawEnd) == null || z.call(O, []);
1554
+ var V;
1555
+ (V = document.querySelector(".delete-icon")) == null || V.addEventListener("click", () => {
1556
+ var O, R;
1557
+ console.log("delete"), B(), (R = (O = l.getProps()) == null ? void 0 : O.areaDrawEnd) == null || R.call(O, []);
1538
1558
  });
1539
1559
  }, 0);
1540
- const D = getCenter(l.getGeometry().getExtent());
1541
- e == null || e.getView().setCenter(D);
1560
+ const F = getCenter(n.getGeometry().getExtent());
1561
+ e == null || e.getView().setCenter(F);
1542
1562
  return;
1543
1563
  }
1544
1564
  y = new Draw({
1545
1565
  type: "Polygon",
1546
- source: v,
1566
+ source: m,
1547
1567
  trace: !0,
1548
1568
  style: [new Style({
1549
1569
  stroke: new Stroke({
@@ -1561,29 +1581,29 @@ const createLabelFeatureStyle = (e) => {
1561
1581
  color: "rgb(51,112,255, 1)"
1562
1582
  })
1563
1583
  }),
1564
- geometry: function(c) {
1565
- const x = c.getGeometry().getCoordinates();
1566
- return new MultiPoint(x);
1584
+ geometry: function(d) {
1585
+ const w = d.getGeometry().getCoordinates();
1586
+ return new MultiPoint(w);
1567
1587
  }
1568
1588
  })]
1569
- }), e == null || e.addInteraction(y), y.on("drawstart", (c) => {
1570
- var x;
1571
- r = c.feature, n = (x = r.getGeometry()) == null ? void 0 : x.on("change", (u) => {
1572
- const M = u.target, D = f(M, "nm"), O = M.getCoordinates()[0], z = new LineString([O[O.length - 2], O[O.length - 1]]), F = computedDistance(z, "nm");
1573
- if (P = Number(getLength(z) / 1e3) > 150, !D) return;
1589
+ }), e == null || e.addInteraction(y), y.on("drawstart", (d) => {
1590
+ var w;
1591
+ r = d.feature, s = (w = r.getGeometry()) == null ? void 0 : w.on("change", (a) => {
1592
+ const M = a.target, F = f(M, "nm"), O = M.getCoordinates()[0], R = new LineString([O[O.length - 2], O[O.length - 1]]), P = computedDistance(R, "nm");
1593
+ if (N = Number(getLength(R) / 1e3) > 150, !F) return;
1574
1594
  const Z = '<span class="error pl-4">超出可以绘画的距离</span>';
1575
- w && (w.innerHTML = `
1595
+ v && (v.innerHTML = `
1576
1596
  <div class="text">
1577
- 面积:${D}
1578
- ${P ? Z : ""}
1597
+ 面积:${F}
1598
+ ${N ? Z : ""}
1579
1599
  </div>
1580
- `), S && (S.innerHTML = `
1600
+ `), C && (C.innerHTML = `
1581
1601
  <div class="text">
1582
- 面积:${D}
1602
+ 面积:${F}
1583
1603
  </div>
1584
- <div class="text ${P ? "error" : ""}">
1585
- 线段 ${O.length - 2}: ${F}
1586
- ${P ? Z : ""}
1604
+ <div class="text ${N ? "error" : ""}">
1605
+ 线段 ${O.length - 2}: ${P}
1606
+ ${N ? Z : ""}
1587
1607
 
1588
1608
  </div>
1589
1609
  <div>
@@ -1591,84 +1611,84 @@ const createLabelFeatureStyle = (e) => {
1591
1611
  </div>
1592
1612
  `);
1593
1613
  });
1594
- }), y.on("drawend", (c) => {
1595
- var D, N, O, z;
1596
- if (!c.feature.getGeometry()) return;
1597
- l = c.feature, w && (w.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), k.setOffset([10, 0]);
1598
- const u = c.feature.getGeometry().getCoordinates(), M = u[0][u[0].length - 2];
1599
- if (k.setPosition(M), S != null && S.parentNode && S.parentNode.removeChild(S), (D = s.getProps()) != null && D.areaDrawEnd) {
1600
- const F = u[0].map((Z) => transform(Z, projection.mercator, projection.data));
1601
- (O = (N = s.getProps()) == null ? void 0 : N.areaDrawEnd) == null || O.call(N, F);
1614
+ }), y.on("drawend", (d) => {
1615
+ var F, V, O, R;
1616
+ if (!d.feature.getGeometry()) return;
1617
+ n = d.feature, v && (v.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), k.setOffset([10, 0]);
1618
+ const a = d.feature.getGeometry().getCoordinates(), M = a[0][a[0].length - 2];
1619
+ if (k.setPosition(M), C != null && C.parentNode && C.parentNode.removeChild(C), (F = l.getProps()) != null && F.areaDrawEnd) {
1620
+ const P = a[0].map((Z) => transform(Z, projection.mercator, projection.data));
1621
+ (O = (V = l.getProps()) == null ? void 0 : V.areaDrawEnd) == null || O.call(V, P);
1602
1622
  }
1603
1623
  y && (y.setActive(!1), e == null || e.removeInteraction(y), (e == null ? void 0 : e.getInteractions()).forEach((Z) => {
1604
1624
  Z instanceof Draw && (Z.setActive(!1), e == null || e.removeInteraction(Z));
1605
- })), n && unByKey(n), (z = document.querySelector(".delete-icon")) == null || z.addEventListener("click", () => {
1606
- var F, Z;
1607
- B(), (Z = (F = s.getProps()) == null ? void 0 : F.areaDrawEnd) == null || Z.call(F, []);
1625
+ })), s && unByKey(s), (R = document.querySelector(".delete-icon")) == null || R.addEventListener("click", () => {
1626
+ var P, Z;
1627
+ B(), (Z = (P = l.getProps()) == null ? void 0 : P.areaDrawEnd) == null || Z.call(P, []);
1608
1628
  });
1609
1629
  });
1610
- }, f = (c, x) => {
1611
- const u = getArea(c);
1612
- switch (x) {
1630
+ }, f = (d, w) => {
1631
+ const a = getArea(d);
1632
+ switch (w) {
1613
1633
  case "km":
1614
- return u > 1e4 ? Math.round(u / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(u * 100) / 100 + " m<sup>2</sup>";
1634
+ return a > 1e4 ? Math.round(a / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(a * 100) / 100 + " m<sup>2</sup>";
1615
1635
  case "nm":
1616
- return u > 1e4 ? Math.round(u / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(u * 100) / 100 + " m<sup>2</sup>";
1636
+ return a > 1e4 ? Math.round(a / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(a * 100) / 100 + " m<sup>2</sup>";
1617
1637
  }
1618
1638
  };
1619
- let w, k;
1620
- const L = () => {
1621
- w != null && w.parentNode && w.parentNode.removeChild(w), w = document.createElement("div"), w.style.display = "flex", w.className = "ol-tooltip ol-tooltip-draw-polygon", k = new Overlay({
1622
- element: w,
1639
+ let v, k;
1640
+ const x = () => {
1641
+ v != null && v.parentNode && v.parentNode.removeChild(v), v = document.createElement("div"), v.style.display = "flex", v.className = "ol-tooltip ol-tooltip-draw-polygon", k = new Overlay({
1642
+ element: v,
1623
1643
  offset: [0, -15],
1624
1644
  positioning: "bottom-center",
1625
1645
  stopEvent: !1,
1626
1646
  insertFirst: !1
1627
1647
  }), e == null || e.addOverlay(k);
1628
1648
  };
1629
- let S, _;
1649
+ let C, A;
1630
1650
  const H = () => {
1631
- S != null && S.parentNode && S.parentNode.removeChild(S), S = document.createElement("div"), S.className = "ol-tooltip ol-help-tooltip", _ = new Overlay({
1632
- element: S,
1651
+ C != null && C.parentNode && C.parentNode.removeChild(C), C = document.createElement("div"), C.className = "ol-tooltip ol-help-tooltip", A = new Overlay({
1652
+ element: C,
1633
1653
  offset: [15, 0],
1634
1654
  positioning: "center-left"
1635
- }), e == null || e.addOverlay(_);
1655
+ }), e == null || e.addOverlay(A);
1636
1656
  }, B = () => {
1637
- v == null || v.clear(), l = null, L(), H(), V();
1657
+ m == null || m.clear(), n = null, x(), H(), $();
1638
1658
  };
1639
1659
  return {
1640
- open: i,
1660
+ open: c,
1641
1661
  close: () => {
1642
- v == null || v.clear(), v = null, m && (e.removeLayer(m), m = null), r = null, y && (y.setActive(!1), (e == null ? void 0 : e.getInteractions()).forEach((x) => {
1643
- x instanceof Draw && (x.setActive(!1), e == null || e.removeInteraction(x));
1644
- }), y = null), n && unByKey(n), S != null && S.parentElement && S.parentElement.removeChild(S), w != null && w.parentElement && w.parentElement.removeChild(w), _ && e.removeOverlay(_), k && e.removeOverlay(k), changeCursor(e, "pointer");
1662
+ m == null || m.clear(), m = null, L && (e.removeLayer(L), L = null), r = null, y && (y.setActive(!1), (e == null ? void 0 : e.getInteractions()).forEach((w) => {
1663
+ w instanceof Draw && (w.setActive(!1), e == null || e.removeInteraction(w));
1664
+ }), y = null), s && unByKey(s), C != null && C.parentElement && C.parentElement.removeChild(C), v != null && v.parentElement && v.parentElement.removeChild(v), A && e.removeOverlay(A), k && e.removeOverlay(k), changeCursor(e, "pointer");
1645
1665
  },
1646
1666
  reset: B
1647
1667
  };
1648
1668
  }, PORT_LAYER_CLASS_NAME = "zh-map-port-layer", usePortManager = (e) => {
1649
- const s = e.getInstall();
1650
- let l, n, i = null, t = null;
1651
- const m = (f, w = !0) => {
1669
+ const l = e.getInstall();
1670
+ let n, s, c = null, t = null;
1671
+ const L = (f, v = !0) => {
1652
1672
  if (!(!f || f.length === 0)) {
1653
- if (n || (n = new VectorSource()), n.clear(), t) {
1654
- const k = f.find((L) => L.id === t.id);
1673
+ if (s || (s = new VectorSource()), s.clear(), t) {
1674
+ const k = f.find((x) => x.id === t.id);
1655
1675
  k ? t = k : f.push(t);
1656
1676
  }
1657
1677
  f.forEach((k) => {
1658
- v(k, w);
1659
- }), l || (l = new VectorLayer({
1678
+ m(k, v);
1679
+ }), n || (n = new VectorLayer({
1660
1680
  className: PORT_LAYER_CLASS_NAME,
1661
- source: n,
1681
+ source: s,
1662
1682
  zIndex: 100
1663
- }), s.addLayer(l));
1683
+ }), l.addLayer(n));
1664
1684
  }
1665
- }, v = (f, w = !0) => {
1666
- const k = e.getZoom(), [L, S] = f.latLon.split(","), _ = new Feature({
1667
- geometry: new Point(fromLonLat([Number(L), Number(S)]))
1685
+ }, m = (f, v = !0) => {
1686
+ const k = e.getZoom(), [x, C] = f.latLon.split(","), A = new Feature({
1687
+ geometry: new Point(fromLonLat([Number(x), Number(C)]))
1668
1688
  });
1669
- _.setStyle(o(f, k, f.id === (t == null ? void 0 : t.id), w)), _.set("portData", f), n.addFeature(_);
1670
- }, o = (f, w, k, L = !0) => {
1671
- const S = (H) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
1689
+ A.setStyle(o(f, k, f.id === (t == null ? void 0 : t.id), v)), A.set("portData", f), s.addFeature(A);
1690
+ }, o = (f, v, k, x = !0) => {
1691
+ const C = (H) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
1672
1692
  <path fill-rule="evenodd" clip-rule="evenodd" d="M22.6563 44.9304C22.5453 44.8844 22.4445 44.817 22.3595 44.7321C22.3595 44.7321 9.36986 31.7424 9.32952 31.6913C7.09059 29.0791 5.64794 25.8802 5.17255 22.4736C4.69716 19.0671 5.20896 15.5957 6.64728 12.471C8.08561 9.34625 10.3902 6.69909 13.2878 4.84325C16.1855 2.98741 19.5548 2.00068 22.9965 2C26.4381 1.99932 29.8078 2.98473 32.7062 4.83943C35.6046 6.69414 37.9102 9.34039 39.3498 12.4646C40.7893 15.5888 41.3025 19.0599 40.8284 22.4666C40.3544 25.8734 38.913 29.0729 36.6751 31.686C36.6401 31.737 23.6531 44.7321 23.6531 44.7321C23.5682 44.817 23.4674 44.8844 23.3564 44.9304C23.2454 44.9763 23.1265 45 23.0063 45C22.8862 45 22.7673 44.9763 22.6563 44.9304Z" fill="${H}"/>
1673
1693
  <g clip-path="url(#clip0_10059_122082)">
1674
1694
  <path d="M34.8624 22.8687L32.5874 25.6313L33.4812 25.7125C33.4812 25.7125 30.5562 28.0687 27.9562 28.2312C25.3562 28.3937 24.1374 24.9 24.1374 24.9V19.1312H27.6312V17.425H24.2999V15.15C25.7624 14.6625 26.7374 13.2812 26.7374 11.6562C26.7374 9.625 25.1124 8 23.0812 8H22.9999C20.9687 8 19.3437 9.625 19.3437 11.6562C19.3437 13.2812 20.3999 14.6625 21.7812 15.15V17.425H18.4499V19.1312H21.9437V24.9C21.9437 24.9 20.6437 28.3125 18.0437 28.2312C15.4437 28.0687 12.5187 25.7125 12.5187 25.7125L13.4124 25.6313L11.0562 22.8687L10.2437 26.2812L11.2187 26.0375C11.2187 26.0375 13.1687 29.5313 16.1749 30.8313C19.1812 32.2125 22.1874 33.9187 22.8374 34C23.4874 33.9187 26.4937 32.2125 29.4187 30.8313C32.3437 29.45 34.3749 26.0375 34.3749 26.0375L35.3499 26.2812L34.8624 22.8687ZM23.0812 13.6875C21.9437 13.6875 21.0499 12.7937 21.0499 11.6562C21.0499 10.6 21.9437 9.70625 22.9999 9.70625H23.0812C24.1374 9.70625 25.0312 10.6 25.0312 11.6562C25.1124 12.7937 24.1374 13.6875 23.0812 13.6875Z" fill="white"/>
@@ -1679,8 +1699,8 @@ const createLabelFeatureStyle = (e) => {
1679
1699
  </clipPath>
1680
1700
  </defs>
1681
1701
  </svg>
1682
- `, _ = () => `data:image/svg+xml;utf8,${encodeURIComponent(S(k ? "#FF5733" : "#3370FF"))}`;
1683
- return L ? new Style({
1702
+ `, A = () => `data:image/svg+xml;utf8,${encodeURIComponent(C(k ? "#FF5733" : "#3370FF"))}`;
1703
+ return x ? new Style({
1684
1704
  text: new Text({
1685
1705
  text: f.shortName,
1686
1706
  font: "12px sans-serif",
@@ -1693,111 +1713,113 @@ const createLabelFeatureStyle = (e) => {
1693
1713
  offsetY: 30
1694
1714
  }),
1695
1715
  image: new Icon({
1696
- src: _(),
1697
- scale: 0.5 * w / 10
1716
+ src: A(),
1717
+ scale: 0.5 * v / 10
1698
1718
  }),
1699
1719
  zIndex: k ? 110 : 100
1700
1720
  }) : new Style({
1701
1721
  image: new Icon({
1702
- src: _(),
1703
- scale: 0.5 * w / 10
1722
+ src: A(),
1723
+ scale: 0.5 * v / 10
1704
1724
  }),
1705
1725
  zIndex: k ? 110 : 100
1706
1726
  });
1707
1727
  }, r = () => {
1708
- if (i) {
1728
+ if (c) {
1709
1729
  console.log("清除非选中的港口");
1710
- const f = i.get("portData").id;
1711
- n.getFeatures().forEach((w) => {
1712
- w.get("portData").id !== f && n.removeFeature(w);
1730
+ const f = c.get("portData").id;
1731
+ s.getFeatures().forEach((v) => {
1732
+ v.get("portData").id !== f && s.removeFeature(v);
1713
1733
  });
1714
1734
  } else
1715
- console.log("清除所有港口", n), n == null || n.clear();
1735
+ console.log("清除所有港口", s), s == null || s.clear();
1716
1736
  }, p = (f) => {
1717
1737
  if (!f)
1718
1738
  return y();
1719
- (i == null ? void 0 : i.get("portData").id) !== f.id && (y(), P(f));
1739
+ (c == null ? void 0 : c.get("portData").id) !== f.id && (y(), N(f));
1720
1740
  }, y = () => {
1721
- if (i) {
1722
- const f = i == null ? void 0 : i.get("portData"), w = e.getZoom();
1723
- i.setStyle(o(f, w, !1));
1741
+ if (c) {
1742
+ const f = c == null ? void 0 : c.get("portData"), v = e.getZoom();
1743
+ s.getFeatures().forEach((x) => {
1744
+ x.get("portData").id === f.id && (x.setStyle(o(x.get("portData"), v, !1)), c = null);
1745
+ });
1724
1746
  }
1725
- }, P = (f) => {
1726
- const w = n.getFeatures();
1727
- t = f, i = w.find((k) => k.get("portData").id === f.id), i == null || i.setStyle(o(f, e.getZoom(), !0));
1747
+ }, N = (f) => {
1748
+ const v = s.getFeatures();
1749
+ t = f, c = v.find((k) => k.get("portData").id === f.id), c == null || c.setStyle(o(f, e.getZoom(), !0));
1728
1750
  };
1729
1751
  return {
1730
- render: m,
1752
+ render: L,
1731
1753
  clear: r,
1732
1754
  selected: p,
1733
1755
  handlePortHover: (f) => {
1734
- const w = s == null ? void 0 : s.getTargetElement();
1735
- f && f.get("portData") && w && (w.style.cursor = "pointer");
1756
+ const v = l == null ? void 0 : l.getTargetElement();
1757
+ f && f.get("portData") && v && (v.style.cursor = "pointer");
1736
1758
  }
1737
1759
  };
1738
- }, useEventManager = (e, s, l, n, i, t) => {
1739
- const m = e.getInstall();
1740
- m.on("moveend", () => {
1760
+ }, useEventManager = (e, l, n, s, c, t) => {
1761
+ const L = e.getInstall();
1762
+ L.on("moveend", () => {
1741
1763
  var o, r;
1742
- const v = e.getZoom();
1743
- (r = (o = s.getProps()).mapMoveEnd) == null || r.call(o, v), l.reRenderTrackLine();
1744
- }), m.on("pointermove", (v) => {
1745
- const o = m.getEventPixel(v.originalEvent), r = m.forEachFeatureAtPixel(o, (p) => p);
1746
- n.handleShipMapEvent(r, "hover"), l.handleTrackMapEvent(r, "hover", v), r && i.handlePortHover(r);
1747
- }), m.on("movestart", () => {
1764
+ const m = e.getZoom();
1765
+ (r = (o = l.getProps()).mapMoveEnd) == null || r.call(o, m), n.reRenderTrackLine();
1766
+ }), L.on("pointermove", (m) => {
1767
+ const o = L.getEventPixel(m.originalEvent), r = L.forEachFeatureAtPixel(o, (p) => p);
1768
+ s.handleShipMapEvent(r, "hover"), n.handleTrackMapEvent(r, "hover", m), r && c.handlePortHover(r);
1769
+ }), L.on("movestart", () => {
1748
1770
  console.log("movestart-----------------------");
1749
- }), m.on("click", debounce((v) => {
1750
- var p, y, P;
1771
+ }), L.on("click", debounce((m) => {
1772
+ var p, y, N;
1751
1773
  if (console.log("1", t.getState()), t.getState()) return;
1752
- const o = m.getEventPixel(v.originalEvent), r = m.forEachFeatureAtPixel(
1774
+ const o = L.getEventPixel(m.originalEvent), r = L.forEachFeatureAtPixel(
1753
1775
  o,
1754
- (V) => {
1755
- if (V != null && V.get("shipData") || V != null && V.get("portData"))
1756
- return V;
1776
+ ($) => {
1777
+ if ($ != null && $.get("shipData") || $ != null && $.get("portData"))
1778
+ return $;
1757
1779
  }
1758
1780
  );
1759
1781
  if (console.log("2", r), !!r) {
1760
- if (v.preventDefault(), v.stopPropagation(), r.get("shipData"))
1761
- n.handleShipMapEvent(r, "click", (p = s.getProps()) == null ? void 0 : p.selectShip);
1782
+ if (m.preventDefault(), m.stopPropagation(), r.get("shipData"))
1783
+ s.handleShipMapEvent(r, "click", (p = l.getProps()) == null ? void 0 : p.selectShip);
1762
1784
  else if (r.get("portData")) {
1763
- const V = r.get("portData");
1764
- i.selected(V), (P = (y = s.getProps()) == null ? void 0 : y.selectPort) == null || P.call(y, V);
1785
+ const $ = r.get("portData");
1786
+ c.selected($), (N = (y = l.getProps()) == null ? void 0 : y.selectPort) == null || N.call(y, $);
1765
1787
  }
1766
1788
  }
1767
1789
  }, 150));
1768
1790
  }, useMapController = () => {
1769
1791
  const e = reactive([]);
1770
1792
  return {
1771
- createInstance: (n, i) => {
1793
+ createInstance: (s, c) => {
1772
1794
  const t = useMapInitializer();
1773
- t.initMap(n, i);
1774
- const m = t.getInstall(), v = useLayerManager(m), o = usePropsManager();
1775
- o.setProps(i), v.setShowLayerType(i.layerType), v.setGreenTileVisible(i.showGreenLayer);
1776
- const r = useTrackManager(m), p = useCarTrackManager(m, r), y = useShipManager(m), P = usePositionManager(m), V = useDrawLineManager(m, o), f = useDrawPolygonManager(m, o), w = usePortManager(t);
1777
- useEventManager(t, o, r, y, w, V);
1795
+ t.initMap(s, c);
1796
+ const L = t.getInstall(), m = useLayerManager(L), o = usePropsManager();
1797
+ o.setProps(c), m.setShowLayerType(c.layerType), m.setGreenTileVisible(c.showGreenLayer);
1798
+ const r = useTrackManager(L), p = useCarTrackManager(L, r), y = useShipManager(L), N = usePositionManager(L), $ = useDrawLineManager(L, o), f = useDrawPolygonManager(L, o), v = usePortManager(t);
1799
+ useEventManager(t, o, r, y, v, $);
1778
1800
  const k = () => {
1779
- const S = m.getView().calculateExtent(t.getSize()), _ = transform([S[0], S[1]], projection.mercator, projection.data), H = transform([S[2], S[3]], projection.mercator, projection.data);
1780
- return [_[0], _[1], H[0], H[1]];
1781
- }, L = {
1801
+ const C = L.getView().calculateExtent(t.getSize()), A = transform([C[0], C[1]], projection.mercator, projection.data), H = transform([C[2], C[3]], projection.mercator, projection.data);
1802
+ return [A[0], A[1], H[0], H[1]];
1803
+ }, x = {
1782
1804
  id: Symbol("map-instance"),
1783
1805
  innerMap: null,
1784
1806
  map: t.getInstall(),
1785
1807
  destroy: () => {
1786
- e.splice(e.indexOf(L), 1);
1808
+ e.splice(e.indexOf(x), 1);
1787
1809
  },
1788
1810
  methods: {
1789
1811
  ...t,
1790
- layer: v,
1812
+ layer: m,
1791
1813
  ship: y,
1792
1814
  track: r,
1793
1815
  carTrack: p,
1794
1816
  port: {
1795
- render: w.render,
1796
- clear: w.clear,
1797
- selected: w.selected
1817
+ render: v.render,
1818
+ clear: v.clear,
1819
+ selected: v.selected
1798
1820
  },
1799
- position: P,
1800
- drawLine: V,
1821
+ position: N,
1822
+ drawLine: $,
1801
1823
  drawPolygon: f,
1802
1824
  // 子模块
1803
1825
  utils: {
@@ -1807,14 +1829,14 @@ const createLabelFeatureStyle = (e) => {
1807
1829
  }
1808
1830
  }
1809
1831
  };
1810
- return e.push(L), L;
1832
+ return e.push(x), x;
1811
1833
  },
1812
- destroyInstance: (n) => {
1813
- const i = e.findIndex((t) => t.id === n);
1814
- i > -1 && (e[i].destroy(), e.splice(i, 1));
1834
+ destroyInstance: (s) => {
1835
+ const c = e.findIndex((t) => t.id === s);
1836
+ c > -1 && (e[c].destroy(), e.splice(c, 1));
1815
1837
  },
1816
1838
  destroyAll: () => {
1817
- e.forEach((n) => n.destroy()), e.splice(0, e.length);
1839
+ e.forEach((s) => s.destroy()), e.splice(0, e.length);
1818
1840
  },
1819
1841
  getAllInstances: () => [...e]
1820
1842
  };
@@ -1837,18 +1859,18 @@ const createLabelFeatureStyle = (e) => {
1837
1859
  selectPort: { type: Function, default: () => {
1838
1860
  } }
1839
1861
  },
1840
- setup(e, { expose: s }) {
1841
- const l = ref(), n = ref(), i = useMapController(), t = ref(), m = e, v = ref({
1862
+ setup(e, { expose: l }) {
1863
+ const n = ref(), s = ref(), c = useMapController(), t = ref(), L = e, m = ref({
1842
1864
  getInstall() {
1843
1865
  }
1844
1866
  });
1845
1867
  return onMounted(() => {
1846
1868
  var o;
1847
- t.value = i.createInstance(l.value, m), console.log(" instance.value?.methods", t.value.map), v.value = t.value.methods, (o = n.value) == null || o.setScaleLine(t.value.map, m.scaleLineUnit);
1869
+ t.value = c.createInstance(n.value, L), console.log(" instance.value?.methods", t.value.map), m.value = t.value.methods, (o = s.value) == null || o.setScaleLine(t.value.map, L.scaleLineUnit);
1848
1870
  }), onUnmounted(() => {
1849
1871
  var o, r;
1850
- i.destroyInstance((o = t == null ? void 0 : t.value) == null ? void 0 : o.id), (r = t.value) == null || r.destroy();
1851
- }), s({
1872
+ c.destroyInstance((o = t == null ? void 0 : t.value) == null ? void 0 : o.id), (r = t.value) == null || r.destroy();
1873
+ }), l({
1852
1874
  getZoom: () => {
1853
1875
  var o;
1854
1876
  return (o = t.value) == null ? void 0 : o.methods.getZoom();
@@ -2056,12 +2078,12 @@ const createLabelFeatureStyle = (e) => {
2056
2078
  createElementVNode("div", {
2057
2079
  id: "map",
2058
2080
  ref_key: "zhMapRef",
2059
- ref: l,
2081
+ ref: n,
2060
2082
  class: "zh-map"
2061
2083
  }, null, 512),
2062
2084
  createVNode(ScaleLine, {
2063
2085
  ref_key: "scaleLineRef",
2064
- ref: n
2086
+ ref: s
2065
2087
  }, null, 512),
2066
2088
  createVNode(ZoomControl, {
2067
2089
  ref: "zoomControlRef",
@@ -2069,7 +2091,7 @@ const createLabelFeatureStyle = (e) => {
2069
2091
  }, null, 8, ["map-instance"])
2070
2092
  ]));
2071
2093
  }
2072
- }), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-cb0faecb"]]), ZhMap = withInstall(Map$1);
2094
+ }), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8370bb85"]]), ZhMap = withInstall(Map$1);
2073
2095
  export {
2074
2096
  ZhMap as Z
2075
2097
  };