zhihao-ui 1.3.15 → 1.3.17

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: n }) {
8
- return n({
9
- setScaleLine: (s, a) => {
7
+ setup(e, { expose: s }) {
8
+ return s({
9
+ setScaleLine: (n, a) => {
10
10
  a || (a = "metric");
11
11
  const o = new ScaleLine$1({
12
12
  units: a
13
- }), y = document.getElementById("scale-line-container");
14
- y && (o.setTarget(y), s.addControl(o));
13
+ }), m = document.getElementById("scale-line-container");
14
+ m && (o.setTarget(m), n.addControl(o));
15
15
  }
16
- }), (s, a) => (openBlock(), createElementBlock("div", _hoisted_1$2));
16
+ }), (n, a) => (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,17 +24,17 @@ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__
24
24
  }
25
25
  },
26
26
  setup(e) {
27
- const n = e;
28
- console.log("props", n);
27
+ const s = e;
28
+ console.log("props", s);
29
29
  const l = () => {
30
30
  console.log("props");
31
- const { setZoom: a, getZoom: o, getInstall: y } = n.mapInstance.methods;
32
- if (!y()) return;
31
+ const { setZoom: a, getZoom: o, getInstall: m } = s.mapInstance.methods;
32
+ if (!m()) return;
33
33
  const t = o();
34
34
  t && a(t + 1);
35
- }, s = () => {
36
- const { setZoom: a, getZoom: o, getInstall: y } = n.mapInstance.methods;
37
- if (!y()) return;
35
+ }, n = () => {
36
+ const { setZoom: a, getZoom: o, getInstall: m } = s.mapInstance.methods;
37
+ if (!m()) return;
38
38
  const t = o();
39
39
  t && a(t - 1);
40
40
  };
@@ -45,7 +45,7 @@ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__
45
45
  }, " + "),
46
46
  createElementVNode("div", {
47
47
  class: "button small-button",
48
- onClick: s
48
+ onClick: n
49
49
  }, " - ")
50
50
  ]));
51
51
  }
@@ -72,34 +72,34 @@ 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(), n = () => e.value, l = () => n().getView(), s = () => {
76
- var m;
77
- return (m = l()) == null ? void 0 : m.getZoom();
78
- }, a = (m) => {
79
- var F;
80
- (F = l()) == null || F.setZoom(m);
81
- }, o = (m, F) => {
82
- var V;
83
- (V = l()) == null || V.setCenter(fromLonLat([m, F]));
84
- }, y = () => {
85
- var F;
86
- const m = (F = l()) == null ? void 0 : F.getCenter();
87
- return toLonLat(m);
88
- }, E = () => {
89
- var m;
90
- return (m = n()) == null ? void 0 : m.getSize();
91
- }, t = new Map$2(), r = (m, F) => {
92
- f(F);
93
- const V = {
94
- zoom: F.zoom,
95
- center: fromLonLat(F.center),
75
+ const e = ref(), s = () => e.value, l = () => s().getView(), n = () => {
76
+ var v;
77
+ return (v = l()) == null ? void 0 : v.getZoom();
78
+ }, a = (v) => {
79
+ var P;
80
+ (P = l()) == null || P.setZoom(v);
81
+ }, o = (v, P) => {
82
+ var O;
83
+ (O = l()) == null || O.setCenter(fromLonLat([v, P]));
84
+ }, m = () => {
85
+ var P;
86
+ const v = (P = l()) == null ? void 0 : P.getCenter();
87
+ return toLonLat(v);
88
+ }, L = () => {
89
+ var v;
90
+ return (v = s()) == null ? void 0 : v.getSize();
91
+ }, t = new Map$2(), r = (v, P) => {
92
+ w(P);
93
+ const O = {
94
+ zoom: P.zoom,
95
+ center: fromLonLat(P.center),
96
96
  minZoom: MAP_ZOOM.min,
97
97
  maxZoom: MAP_ZOOM.max,
98
98
  constrainResolution: !0,
99
99
  enableRotation: !1,
100
100
  multiWorld: !0
101
- }, v = new Map$2({
102
- target: m,
101
+ }, f = new Map$2({
102
+ target: v,
103
103
  controls: defaults({
104
104
  zoom: !1
105
105
  }),
@@ -109,62 +109,62 @@ function useMapInitializer() {
109
109
  t.get("satelliteImgTile"),
110
110
  t.get("satelliteImgTileMark")
111
111
  ],
112
- view: new View(V)
112
+ view: new View(O)
113
113
  });
114
- e.value = v;
115
- }, f = (m) => {
114
+ e.value = f;
115
+ }, w = (v) => {
116
116
  t.set("vectorTile", new TileLayer({
117
117
  source: new XYZ({ url: BASE_MAP_LINK.vectorTile }),
118
- visible: m.layerType === "vector",
118
+ visible: v.layerType === "vector",
119
119
  zIndex: 0,
120
120
  preload: 1,
121
121
  className: "vector"
122
122
  })), t.set("vectorTileMark", new TileLayer({
123
123
  source: new XYZ({ url: BASE_MAP_LINK.vectorTileMark }),
124
- visible: m.layerType === "vector",
124
+ visible: v.layerType === "vector",
125
125
  zIndex: 1,
126
126
  preload: 1,
127
127
  className: "vector"
128
128
  })), t.set("satelliteImgTile", new TileLayer({
129
129
  source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTile }),
130
- visible: m.layerType === "satellite",
130
+ visible: v.layerType === "satellite",
131
131
  zIndex: 0,
132
132
  preload: 1,
133
133
  className: "satellite"
134
134
  })), t.set("satelliteImgTileMark", new TileLayer({
135
135
  source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTileMark }),
136
- visible: m.layerType === "satellite",
136
+ visible: v.layerType === "satellite",
137
137
  zIndex: 1,
138
138
  preload: 1,
139
139
  className: "satellite"
140
140
  })), t.set("greenMark", new TileLayer({
141
141
  source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
142
- visible: m.showGreenLayer,
142
+ visible: v.showGreenLayer,
143
143
  zIndex: 2,
144
144
  className: "greenTile"
145
145
  }));
146
146
  };
147
147
  return {
148
- getInstall: n,
148
+ getInstall: s,
149
149
  getView: l,
150
- getZoom: s,
150
+ getZoom: n,
151
151
  setZoom: a,
152
152
  setCenter: o,
153
- getCenter: y,
154
- getSize: E,
153
+ getCenter: m,
154
+ getSize: L,
155
155
  initMap: r,
156
- setBaseLayerMap: f
156
+ setBaseLayerMap: w
157
157
  };
158
158
  }
159
- const convertSixHundredThousandToLatLng = function(e, n) {
160
- const l = Number(n) / 6e5;
159
+ const convertSixHundredThousandToLatLng = function(e, s) {
160
+ const l = Number(s) / 6e5;
161
161
  return [Number(e) / 6e5, l];
162
- }, calculateCirclePoints = (e, n) => {
163
- const l = fromLonLat(e), s = n * 1e3, a = [
164
- l[0] - s,
165
- l[1] - s,
166
- l[0] + s,
167
- l[1] + s
162
+ }, calculateCirclePoints = (e, s) => {
163
+ const l = fromLonLat(e), n = s * 1e3, a = [
164
+ l[0] - n,
165
+ l[1] - n,
166
+ l[0] + n,
167
+ l[1] + n
168
168
  ], o = transformExtent(a, projection.mercator, projection.data);
169
169
  return {
170
170
  leftTopPoint: { lng: o[0], lat: o[3] },
@@ -172,134 +172,134 @@ const convertSixHundredThousandToLatLng = function(e, n) {
172
172
  rightBottomPoint: { lng: o[2], lat: o[1] },
173
173
  leftBottomPoint: { lng: o[0], lat: o[1] }
174
174
  };
175
- }, formatLength = function(e, n) {
176
- const s = getLength(e);
175
+ }, formatLength = function(e, s) {
176
+ const n = getLength(e);
177
177
  let a = "";
178
- switch (console.log(n, LENGTH_UNIT), n) {
178
+ switch (console.log(s, LENGTH_UNIT), s) {
179
179
  case LENGTH_UNIT.M:
180
- a = Math.round(s * 100) / 100 + " m";
180
+ a = Math.round(n * 100) / 100 + " m";
181
181
  break;
182
182
  case LENGTH_UNIT.KM:
183
- a = Math.round(s / 1e3 * 100) / 100 + " km";
183
+ a = Math.round(n / 1e3 * 100) / 100 + " km";
184
184
  break;
185
185
  case LENGTH_UNIT.NM:
186
- a = (Math.round(s / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
186
+ a = (Math.round(n / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
187
187
  break;
188
188
  }
189
189
  return a;
190
190
  };
191
191
  function lonLatToMercator(e) {
192
- const n = e[0] * equatorialCircumference / 180;
192
+ const s = e[0] * equatorialCircumference / 180;
193
193
  let l = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
194
- return l = l * equatorialCircumference / 180, [n, l];
194
+ return l = l * equatorialCircumference / 180, [s, l];
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 n = new Text({
200
+ const s = 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: n,
207
+ text: s,
208
208
  zIndex: 100
209
209
  });
210
- }, mercatorToLonLat = (e, n = "lonlat") => {
211
- const l = { lon: 0, lat: 0 }, s = e[0] / equatorialCircumference * 180;
210
+ }, mercatorToLonLat = (e, s = "lonlat") => {
211
+ const l = { lon: 0, lat: 0 }, n = e[0] / equatorialCircumference * 180;
212
212
  let a = e[1] / equatorialCircumference * 180;
213
- return a = 180 / Math.PI * (2 * Math.atan(Math.exp(a * Math.PI / 180)) - Math.PI / 2), l.lon = s, l.lat = a, n === "lonlat" ? l : [s, a];
213
+ return a = 180 / Math.PI * (2 * Math.atan(Math.exp(a * Math.PI / 180)) - Math.PI / 2), l.lon = n, l.lat = a, s === "lonlat" ? l : [n, a];
214
214
  }, formatMinutesToDDHHMM = (e) => {
215
- const n = hooks.duration(e, "minutes"), l = Math.floor(n.asDays()), s = n.hours(), a = n.minutes();
215
+ const s = hooks.duration(e, "minutes"), l = Math.floor(s.asDays()), n = s.hours(), a = s.minutes();
216
216
  let o = `${String(a).padStart(2, "0")}分`;
217
- return s !== 0 && (o = `${String(s).padStart(2, "0")}时${o}`), l !== 0 && (o = `${String(l).padStart(2, "0")}天${o}`), o;
218
- }, useCarTrackManager = (e, n) => {
217
+ return n !== 0 && (o = `${String(n).padStart(2, "0")}时${o}`), l !== 0 && (o = `${String(l).padStart(2, "0")}天${o}`), o;
218
+ }, useCarTrackManager = (e, s) => {
219
219
  let l = null;
220
- const s = async (f) => {
221
- if (!e || (console.log("vehicleInfo", f), !(f != null && f.lon && (f != null && f.lat)))) return;
222
- const m = Math.abs(Number(f.lon)) > 180 ? convertSixHundredThousandToLatLng(f.lon, f.lat) : [f.lon, f.lat];
223
- a(f, fromLonLat(m));
224
- const F = e == null ? void 0 : e.getView(), V = new Point(m);
225
- F.setCenter(transform(V.getCoordinates(), projection.data, projection.mercator));
226
- }, a = (f, m) => {
227
- const F = `${CDN_URL}map/car-icon.gif`;
220
+ const n = async (w) => {
221
+ if (!e || (console.log("vehicleInfo", w), !(w != null && w.lon && (w != null && w.lat)))) return;
222
+ const v = Math.abs(Number(w.lon)) > 180 ? convertSixHundredThousandToLatLng(w.lon, w.lat) : [w.lon, w.lat];
223
+ a(w, fromLonLat(v));
224
+ const P = e == null ? void 0 : e.getView(), O = new Point(v);
225
+ P.setCenter(transform(O.getCoordinates(), projection.data, projection.mercator));
226
+ }, a = (w, v) => {
227
+ const P = `${CDN_URL}map/car-icon.gif`;
228
228
  l || (l = new Overlay({
229
229
  element: document.createElement("div"),
230
230
  positioning: "center-center",
231
231
  stopEvent: !1
232
232
  // 允许交互事件穿透
233
233
  }), e.addOverlay(l));
234
- const V = l.getElement();
235
- V.style.backgroundImage = `url(${F})`, V.style.width = "80px", V.style.height = "80px";
236
- const v = (f == null ? void 0 : f.drc) || "";
237
- V.style.transform = `rotate(${v}deg)`, V.style.backgroundSize = "cover", l == null || l.setPosition(m);
234
+ const O = l.getElement();
235
+ O.style.backgroundImage = `url(${P})`, O.style.width = "80px", O.style.height = "80px";
236
+ const f = (w == null ? void 0 : w.drc) || "";
237
+ O.style.transform = `rotate(${f}deg)`, O.style.backgroundSize = "cover", l == null || l.setPosition(v);
238
238
  };
239
239
  return {
240
- location: s,
240
+ location: n,
241
241
  remove: () => {
242
- const f = l == null ? void 0 : l.getElement();
243
- f && (f.innerHTML = "");
242
+ const w = l == null ? void 0 : l.getElement();
243
+ w && (w.innerHTML = "");
244
244
  },
245
- renderTrack: (f, m, F) => {
246
- n.render(f, m, F, "truck", 1e3);
245
+ renderTrack: (w, v, P) => {
246
+ s.render(w, v, P, "truck", 1e3);
247
247
  },
248
- setCenter: (f) => {
249
- n.setCenter(f);
248
+ setCenter: (w) => {
249
+ s.setCenter(w);
250
250
  },
251
251
  closeTrack: () => {
252
- n.close();
252
+ s.close();
253
253
  },
254
- playTrack: (f, m) => {
255
- n.play(f, m);
254
+ playTrack: (w, v) => {
255
+ s.play(w, v);
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 n = /* @__PURE__ */ new Map(), l = {};
262
- let s = null;
261
+ const s = /* @__PURE__ */ new Map(), l = {};
262
+ let n = null;
263
263
  const a = "--";
264
264
  let o = null;
265
- const y = document.createElement("div"), E = new Overlay({
266
- element: y,
265
+ const m = document.createElement("div"), L = new Overlay({
266
+ element: m,
267
267
  positioning: "top-left",
268
268
  stopEvent: !1,
269
269
  className: "track-label-popup"
270
270
  });
271
- let t, r, f, m, F, V = !1, v = Date.now(), g, T = 0, p = null, C = 20, Z = !1;
272
- const Y = 5, X = [], H = (i) => {
271
+ let t, r, w, v, P, O = !1, f = Date.now(), y, F = 0, E = null, T = 20, G = !1;
272
+ const q = 5, W = [], Q = (i) => {
273
273
  var c;
274
- for (X.unshift(i); X.length > Y; ) {
275
- const d = X.pop(), w = n.get(d);
276
- w && ((c = w.getSource()) == null || c.clear(), e == null || e.removeLayer(w), n.delete(d), delete l[d]);
274
+ for (W.unshift(i); W.length > q; ) {
275
+ const d = W.pop(), p = s.get(d);
276
+ p && ((c = p.getSource()) == null || c.clear(), e == null || e.removeLayer(p), s.delete(d), delete l[d]);
277
277
  }
278
278
  };
279
279
  let u = "";
280
- const L = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], S = debounce(() => {
281
- if (s && l[s] && n.get(s).getVisible() && Z) {
280
+ const x = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], g = debounce(() => {
281
+ if (n && l[n] && s.get(n).getVisible() && G) {
282
282
  console.log("reRenderTrackLine------------");
283
- const i = cloneDeep(P(s, l[s]));
284
- ce(s, i);
283
+ const i = cloneDeep(M(n, l[n]));
284
+ ce(n, i);
285
285
  }
286
- }, 300), P = (i, c) => {
286
+ }, 300), M = (i, c) => {
287
287
  let d = [];
288
- const w = Math.max(1, Math.floor(c.length / C));
289
- return d = c.filter((b, _) => _ % w === 0).map((b, _) => {
290
- if (Number(b.lon) > 180 || Number(b.lat) > 180) {
291
- const [O, A] = convertSixHundredThousandToLatLng(b.lon, b.lat);
292
- b.lon = O, b.lat = A;
288
+ const p = Math.max(1, Math.floor(c.length / T));
289
+ return d = c.filter((k, _) => _ % p === 0).map((k, _) => {
290
+ if (Number(k.lon) > 180 || Number(k.lat) > 180) {
291
+ const [N, z] = convertSixHundredThousandToLatLng(k.lon, k.lat);
292
+ k.lon = N, k.lat = z;
293
293
  }
294
- return b.center = [b.lon, b.lat], b.centerPoint = lonLatToMercator(b.center), b.time = hooks(b.createdAt).format("YYYY-MM-DD HH:mm:ss"), b.id = i, b.index = _, b;
294
+ return k.center = [k.lon, k.lat], k.centerPoint = lonLatToMercator(k.center), k.time = hooks(k.createdAt).format("YYYY-MM-DD HH:mm:ss"), k.id = i, k.index = _, k;
295
295
  }), d;
296
- }, x = async (i, c, d, w = "ship", M = 200) => {
297
- if (!e || (c = c == null ? void 0 : c.reverse(), E && w === "ship" && (e != null && e.getOverlays().getArray().includes(E) || e.addOverlay(E)), (c == null ? void 0 : c.length) < 2))
296
+ }, V = async (i, c, d, p = "ship", b = 200) => {
297
+ if (!e || (c = c == null ? void 0 : c.reverse(), L && p === "ship" && (e != null && e.getOverlays().getArray().includes(L) || e.addOverlay(L)), (c == null ? void 0 : c.length) < 2))
298
298
  return;
299
- H(i), s = i, l[i] = c, C = M;
300
- const b = Object.keys(l).findIndex((_) => _ === i) || 0;
301
- u = d || L[b > 10 ? 10 : b], Z = !0, await z(), await ne(s);
302
- }, N = (i) => {
299
+ Q(i), n = i, l[i] = c, T = b;
300
+ const k = Object.keys(l).findIndex((_) => _ === i) || 0;
301
+ u = d || x[k > 10 ? 10 : k], G = !0, await R(), await ne(n);
302
+ }, D = (i) => {
303
303
  const c = new VectorSource();
304
304
  return new VectorLayer({
305
305
  source: c,
@@ -309,48 +309,48 @@ const useTrackManager = (e) => {
309
309
  renderBuffer: 1024
310
310
  // 增大渲染缓冲区
311
311
  });
312
- }, D = (i) => {
313
- n.forEach((c, d) => {
314
- var M;
315
- const w = d === i;
316
- c.getVisible() !== w && (c.setVisible(w), e.getLayers().getArray().includes(c) || e.addLayer(c), w || (M = c.getSource()) == null || M.clear());
317
- }), s = i;
318
- }, z = async () => {
319
- const i = s;
320
- if (!n.has(i)) {
321
- const b = N(i);
322
- n.set(i, b);
312
+ }, $ = (i) => {
313
+ s.forEach((c, d) => {
314
+ var b;
315
+ const p = d === i;
316
+ c.getVisible() !== p && (c.setVisible(p), e.getLayers().getArray().includes(c) || e.addLayer(c), p || (b = c.getSource()) == null || b.clear());
317
+ }), n = i;
318
+ }, R = async () => {
319
+ const i = n;
320
+ if (!s.has(i)) {
321
+ const k = D(i);
322
+ s.set(i, k);
323
323
  }
324
- await D(i);
324
+ await $(i);
325
325
  const c = u || "", d = l[i] || [];
326
326
  if (!(d && d.length > 1)) return [];
327
- let w = [];
328
- w = P(i, d);
329
- const M = w.map((b) => b.centerPoint);
330
- w.length >= 2 && await $(i, M, c);
331
- }, $ = (i, c, d) => {
332
- const w = new LineString(c), M = n.get(i).getSource(), b = M.getFeatureById(i);
333
- if (b)
334
- b.setGeometry(w), b.setId(i), b.setStyle(R(d)), p = b;
327
+ let p = [];
328
+ p = M(i, d);
329
+ const b = p.map((k) => k.centerPoint);
330
+ p.length >= 2 && await S(i, b, c);
331
+ }, S = (i, c, d) => {
332
+ const p = new LineString(c), b = s.get(i).getSource(), k = b.getFeatureById(i);
333
+ if (k)
334
+ k.setGeometry(p), k.setId(i), k.setStyle(A(d)), E = k;
335
335
  else {
336
- const _ = new Feature({ geometry: w });
337
- _.setId(i), _.set("type", "line"), _.setStyle(R(d)), M.addFeature(_), p = _;
336
+ const _ = new Feature({ geometry: p });
337
+ _.setId(i), _.set("type", "line"), _.setStyle(A(d)), b.addFeature(_), E = _;
338
338
  }
339
- return p;
340
- }, R = (i) => new Style({
339
+ return E;
340
+ }, A = (i) => new Style({
341
341
  stroke: new Stroke({
342
342
  color: i,
343
343
  width: 2
344
344
  })
345
- }), K = (i, c, d) => {
346
- const w = i == null ? void 0 : i.get("trackId");
347
- if (i && w && c === "hover") {
348
- e.getTargetElement().style.cursor = w ? "pointer" : "";
349
- const M = i.get("data"), b = Q(M), _ = d == null ? void 0 : d.coordinate;
350
- _ && (y.querySelector(".popup-content"), y.innerHTML = b, E == null || E.setPosition(_));
345
+ }), X = (i, c, d) => {
346
+ const p = i == null ? void 0 : i.get("trackId");
347
+ if (i && p && c === "hover") {
348
+ e.getTargetElement().style.cursor = p ? "pointer" : "";
349
+ const b = i.get("data"), k = K(b), _ = d == null ? void 0 : d.coordinate;
350
+ _ && (m.querySelector(".popup-content"), m.innerHTML = k, L == null || L.setPosition(_));
351
351
  } else
352
- E && E.setPosition(void 0);
353
- }, Q = (i) => {
352
+ L && L.setPosition(void 0);
353
+ }, K = (i) => {
354
354
  if (!(i != null && i.time)) return;
355
355
  let c = "";
356
356
  return i != null && i.stayTime && (c = `
@@ -391,63 +391,63 @@ const useTrackManager = (e) => {
391
391
  ${c ?? c}
392
392
  </div>`;
393
393
  }, ie = (i) => {
394
- const d = i.map((O) => {
395
- const A = e.getPixelFromCoordinate(fromLonLat(O.center));
394
+ const d = i.map((N) => {
395
+ const z = e.getPixelFromCoordinate(fromLonLat(N.center));
396
396
  return {
397
- ...O,
398
- original: O,
399
- pixel: A,
397
+ ...N,
398
+ original: N,
399
+ pixel: z,
400
400
  distance: 0
401
401
  // 先初始化,后续计算
402
402
  };
403
403
  });
404
- let w = 0;
404
+ let p = 0;
405
405
  d[0].distance = 0;
406
- for (let O = 1; O < d.length; O++) {
407
- const A = d[O - 1].pixel, B = d[O].pixel, q = B[0] - A[0], k = B[1] - A[1];
408
- w += Math.sqrt(q * q + k * k), d[O].distance = w;
406
+ for (let N = 1; N < d.length; N++) {
407
+ const z = d[N - 1].pixel, H = d[N].pixel, Y = H[0] - z[0], C = H[1] - z[1];
408
+ p += Math.sqrt(Y * Y + C * C), d[N].distance = p;
409
409
  }
410
- const M = d.filter(
411
- (O, A) => A === 0 || A === d.length - 1
412
- ), b = [];
413
- for (let O = 0; O < M.length; O++) {
414
- const A = M[O];
415
- if (b.push(A), O < M.length - 1) {
416
- const B = M[O + 1], q = B.distance - A.distance, k = Math.floor(q / 100);
417
- for (let G = 1; G <= k; G++) {
418
- const j = A.distance + G * 100;
419
- if (j >= B.distance) break;
420
- const W = ae(
410
+ const b = d.filter(
411
+ (N, z) => z === 0 || z === d.length - 1
412
+ ), k = [];
413
+ for (let N = 0; N < b.length; N++) {
414
+ const z = b[N];
415
+ if (k.push(z), N < b.length - 1) {
416
+ const H = b[N + 1], Y = H.distance - z.distance, C = Math.floor(Y / 100);
417
+ for (let Z = 1; Z <= C; Z++) {
418
+ const B = z.distance + Z * 100;
419
+ if (B >= H.distance) break;
420
+ const j = ae(
421
421
  d,
422
- j
422
+ B
423
423
  );
424
- W && b.push(W);
424
+ j && k.push(j);
425
425
  }
426
426
  }
427
427
  }
428
428
  return Array.from(
429
- new Map(b.map((O) => [O.distance.toFixed(2), O])).values()
430
- ).map((O) => ({
431
- ...O.original,
429
+ new Map(k.map((N) => [N.distance.toFixed(2), N])).values()
430
+ ).map((N) => ({
431
+ ...N.original,
432
432
  // 优先保留原始数据
433
- ...O,
433
+ ...N,
434
434
  // 覆盖坐标等计算属性
435
- coord: O.coord,
435
+ coord: N.coord,
436
436
  // 确保使用插值后的坐标
437
- pixel: O.pixel,
438
- distance: O.distance
437
+ pixel: N.pixel,
438
+ distance: N.distance
439
439
  }));
440
440
  };
441
441
  function ae(i, c) {
442
442
  for (let d = 1; d < i.length; d++) {
443
- const w = i[d - 1], M = i[d];
444
- if (c >= w.distance && c <= M.distance) {
445
- const b = (c - w.distance) / (M.distance - w.distance), _ = w.pixel[0] + b * (M.pixel[0] - w.pixel[0]), O = w.pixel[1] + b * (M.pixel[1] - w.pixel[1]), A = e == null ? void 0 : e.getCoordinateFromPixel([_, O]);
443
+ const p = i[d - 1], b = i[d];
444
+ if (c >= p.distance && c <= b.distance) {
445
+ const k = (c - p.distance) / (b.distance - p.distance), _ = p.pixel[0] + k * (b.pixel[0] - p.pixel[0]), N = p.pixel[1] + k * (b.pixel[1] - p.pixel[1]), z = e == null ? void 0 : e.getCoordinateFromPixel([_, N]);
446
446
  return {
447
- ...w,
447
+ ...p,
448
448
  // 继承前一个点的属性(可调整)
449
- coord: A,
450
- pixel: [_, O],
449
+ coord: z,
450
+ pixel: [_, N],
451
451
  distance: c,
452
452
  original: void 0
453
453
  // 明确标记为插值生成点
@@ -458,9 +458,9 @@ const useTrackManager = (e) => {
458
458
  }
459
459
  const ce = async (i, c) => {
460
460
  await re(), await ge(i);
461
- const d = ie(c), w = d.map((b) => de(b));
462
- n.get(i).getSource().addFeatures(w), me(i, d, c, u), d.forEach((b) => {
463
- const _ = ue(i, u, b);
461
+ const d = ie(c), p = d.map((k) => de(k));
462
+ s.get(i).getSource().addFeatures(p), he(i, d, c, u), d.forEach((k) => {
463
+ const _ = ue(i, u, k);
464
464
  e.addOverlay(_);
465
465
  });
466
466
  }, de = (i) => {
@@ -474,8 +474,8 @@ const useTrackManager = (e) => {
474
474
  ];
475
475
  return (i.index === 0 || i.index === l[i.id].length - 1) && (d = [...ve(i)], c.set("type", "track_begin")), i.state !== void 0 && i.state !== null && (d = [...ye(i)], c.set("type", "track_icon")), c.setStyle(d), c;
476
476
  }, ue = (i, c, d) => {
477
- const w = document.createElement("div");
478
- w.className = "track-overlay-label", w.style.position = "relative", w.style.backgroundColor = "rgba(255,255,255,0.8)", w.style.border = `1px solid ${c}`, w.style.fontSize = "12px", w.innerHTML = `
477
+ const p = document.createElement("div");
478
+ p.className = "track-overlay-label", p.style.position = "relative", p.style.backgroundColor = "rgba(255,255,255,0.8)", p.style.border = `1px solid ${c}`, p.style.fontSize = "12px", p.innerHTML = `
479
479
  <span>${d.time}</span>
480
480
  <svg
481
481
  style="position: absolute;left: -20px;top: 0;"
@@ -488,22 +488,22 @@ const useTrackManager = (e) => {
488
488
  stroke="${c}"
489
489
  stroke-width="1" />
490
490
  `;
491
- const M = new Overlay({
492
- element: w,
491
+ const b = new Overlay({
492
+ element: p,
493
493
  position: fromLonLat(d.center),
494
494
  positioning: "top-left",
495
495
  offset: [20, -20],
496
496
  stopEvent: !1,
497
497
  className: "track-label-time-overlay"
498
498
  });
499
- return M.set("class", "track-label-overlay"), M.set("trackId", i), M;
499
+ return b.set("class", "track-label-overlay"), b.set("trackId", i), b;
500
500
  }, re = () => {
501
501
  const i = e == null ? void 0 : e.getOverlays().getArray(), c = i == null ? void 0 : i.filter((d) => d.get("class") === "track-label-overlay");
502
502
  c && c.length > 0 && c.forEach((d) => {
503
503
  d.setPosition(void 0), d.dispose();
504
504
  });
505
505
  }, ge = (i) => {
506
- const c = n.get(i).getSource();
506
+ const c = s.get(i).getSource();
507
507
  c.forEachFeature((d) => {
508
508
  d.get("type") !== "line" && c.removeFeature(d);
509
509
  });
@@ -525,107 +525,107 @@ const useTrackManager = (e) => {
525
525
  })
526
526
  // textStyle,
527
527
  ]), ye = (i) => {
528
- const c = "#E31818", d = "#1890FF", w = "&#xe6d2", M = new Style({
528
+ const c = "#E31818", d = "#1890FF", p = "&#xe6d2", b = new Style({
529
529
  text: new Text({
530
530
  font: "Normal 22px map-iconfont",
531
- text: getIconFont(w),
531
+ text: getIconFont(p),
532
532
  offsetY: -10,
533
533
  fill: new Fill({
534
534
  color: Number(i.state) === 0 ? c : Number(i.state) === 1 ? d : ""
535
535
  })
536
536
  }),
537
537
  zIndex: 99
538
- }), _ = getIconStyle("&#xe6e2;"), A = getIconStyle("&#xe703;"), B = [];
539
- return Number(i.state) === 0 ? B.push(_) : Number(i.state) === 1 && B.push(A), B.push(M), B;
540
- }, me = (i, c, d, w) => {
541
- const M = c || [], b = c.length;
542
- b || (M.push(d[0]), M.push(d[d.length - 1]));
538
+ }), _ = getIconStyle("&#xe6e2;"), z = getIconStyle("&#xe703;"), H = [];
539
+ return Number(i.state) === 0 ? H.push(_) : Number(i.state) === 1 && H.push(z), H.push(b), H;
540
+ }, he = (i, c, d, p) => {
541
+ const b = c || [], k = c.length;
542
+ k || (b.push(d[0]), b.push(d[d.length - 1]));
543
543
  const _ = [];
544
- for (let A = 0; A < b - 1; A++) {
545
- let B;
546
- const q = c[A], k = (c[A + 1].index + q.index) / 2;
547
- if (k % 2 === 0)
548
- B = d[k].centerPoint;
544
+ for (let z = 0; z < k - 1; z++) {
545
+ let H;
546
+ const Y = c[z], C = (c[z + 1].index + Y.index) / 2;
547
+ if (C % 2 === 0)
548
+ H = d[C].centerPoint;
549
549
  else {
550
- const G = d[Math.floor(k)], j = d[Math.ceil(k)];
551
- if (G && j) {
552
- const [W, J] = G.centerPoint, [I, ee] = j.centerPoint;
553
- B = [(W + I) / 2, (J + ee) / 2];
550
+ const Z = d[Math.floor(C)], B = d[Math.ceil(C)];
551
+ if (Z && B) {
552
+ const [j, J] = Z.centerPoint, [I, ee] = B.centerPoint;
553
+ H = [(j + I) / 2, (J + ee) / 2];
554
554
  }
555
555
  }
556
- if (B) {
557
- const G = new Feature({
558
- geometry: new Point(B)
556
+ if (H) {
557
+ const Z = new Feature({
558
+ geometry: new Point(H)
559
559
  });
560
- G.set("type", "track_arrow"), G.setStyle(
560
+ Z.set("type", "track_arrow"), Z.setStyle(
561
561
  new Style({
562
562
  text: new Text({
563
563
  font: "700 12px map-iconfont",
564
564
  text: getIconFont("&#xe6bc;"),
565
- fill: new Fill({ color: w }),
565
+ fill: new Fill({ color: p }),
566
566
  // 设置箭头旋转 角度转为弧度
567
567
  rotation: le(
568
- c[A].center,
569
- c[A + 1].center
568
+ c[z].center,
569
+ c[z + 1].center
570
570
  ) * (Math.PI / 180)
571
571
  })
572
572
  })
573
- ), _.push(G);
573
+ ), _.push(Z);
574
574
  }
575
575
  }
576
- const O = n.get(i).getSource();
577
- O == null || O.addFeatures(_);
576
+ const N = s.get(i).getSource();
577
+ N == null || N.addFeatures(_);
578
578
  }, ne = (i) => {
579
- var b, _;
580
- const c = e.getView(), d = (b = n == null ? void 0 : n.get(i)) == null ? void 0 : b.getSource(), w = p || (i ? d == null ? void 0 : d.getFeatureById(i) : null);
581
- if (!w) return;
582
- const M = (_ = w == null ? void 0 : w.getGeometry()) == null ? void 0 : _.getExtent();
583
- if (M != null && M.length)
579
+ var k, _;
580
+ const c = e.getView(), d = (k = s == null ? void 0 : s.get(i)) == null ? void 0 : k.getSource(), p = E || (i ? d == null ? void 0 : d.getFeatureById(i) : null);
581
+ if (!p) return;
582
+ const b = (_ = p == null ? void 0 : p.getGeometry()) == null ? void 0 : _.getExtent();
583
+ if (b != null && b.length)
584
584
  try {
585
- const O = buffer(M, Math.max(M[2] - M[0], M[3] - M[1]) * 0.02);
586
- c.fit(O);
587
- } catch (O) {
588
- console.log(O);
585
+ const N = buffer(b, Math.max(b[2] - b[0], b[3] - b[1]) * 0.02);
586
+ c.fit(N);
587
+ } catch (N) {
588
+ console.log(N);
589
589
  }
590
590
  }, ve = (i) => {
591
- const c = "&#xe69b;", M = i.index === 0 ? "#fcdc3f" : "#ff0000";
591
+ const c = "&#xe69b;", b = i.index === 0 ? "#fcdc3f" : "#ff0000";
592
592
  return [new Style({
593
593
  text: new Text({
594
594
  font: "Normal 14px map-iconfont",
595
595
  text: getIconFont(c),
596
- fill: new Fill({ color: M })
596
+ fill: new Fill({ color: b })
597
597
  }),
598
598
  zIndex: 101
599
599
  })];
600
- }, he = () => {
601
- console.log("清除所有的轨迹-----"), U(), n.forEach((c) => {
600
+ }, me = () => {
601
+ console.log("清除所有的轨迹-----"), U(), s.forEach((c) => {
602
602
  var d;
603
603
  (d = c.getSource()) == null || d.clear(), e == null || e.removeLayer(c);
604
604
  }), Object.keys(l).forEach((c) => {
605
- n.delete(c), delete l[c];
606
- }), Z = !1, re();
605
+ s.delete(c), delete l[c];
606
+ }), G = !1, re();
607
607
  }, we = (i) => {
608
- const c = n.get(i || s);
608
+ const c = s.get(i || n);
609
609
  c == null || c.setVisible(!1);
610
610
  const d = e.getOverlays().getArray();
611
- for (let w = 0; w < d.length; ) {
612
- const M = d[w];
613
- M.get("class") === "track-label-overlay" ? (M.setPosition(void 0), e.removeOverlay(M)) : w++;
611
+ for (let p = 0; p < d.length; ) {
612
+ const b = d[p];
613
+ b.get("class") === "track-label-overlay" ? (b.setPosition(void 0), e.removeOverlay(b)) : p++;
614
614
  }
615
615
  U();
616
616
  }, pe = (i, c = LENGTH_UNIT.NM) => {
617
617
  const d = {
618
618
  id: i,
619
619
  length: "--"
620
- }, M = (l[i] || []).map(
620
+ }, b = (l[i] || []).map(
621
621
  (_) => transform([_.lon, _.lat], projection.data, projection.mercator)
622
- ), b = new LineString(M);
623
- return d.length = formatLength(b, c) || "--", d;
622
+ ), k = new LineString(b);
623
+ return d.length = formatLength(k, c) || "--", d;
624
624
  }, Le = (i, c) => {
625
625
  xe(String(i), c);
626
626
  }, xe = (i, c) => {
627
- const d = l[String(i)], w = d == null ? void 0 : d.map((M) => [M.lon, M.lat]);
628
- w && ke(w, c);
627
+ const d = l[String(i)], p = d == null ? void 0 : d.map((b) => [b.lon, b.lat]);
628
+ p && ke(p, c);
629
629
  }, te = new Style({
630
630
  text: new Text({
631
631
  font: "700 20px map-iconfont",
@@ -635,120 +635,120 @@ const useTrackManager = (e) => {
635
635
  // 初始旋转角度
636
636
  })
637
637
  }), Me = (i, c) => {
638
- var k, G;
639
- const d = Number(50 * c), w = ((k = i.frameState) == null ? void 0 : k.time) ?? Date.now(), M = w - v;
640
- if (T = (T + d * M / 1e6) % 2, v = w, T >= 1) {
638
+ var C, Z;
639
+ const d = Number(50 * c), p = ((C = i.frameState) == null ? void 0 : C.time) ?? Date.now(), b = p - f;
640
+ if (F = (F + d * b / 1e6) % 2, f = p, F >= 1) {
641
641
  U();
642
642
  return;
643
643
  }
644
- const b = r.getCoordinateAt(
645
- T > 1 ? 2 - T : T
644
+ const k = r.getCoordinateAt(
645
+ F > 1 ? 2 - F : F
646
646
  ), _ = r.getCoordinateAt(
647
- T > 1 ? T - 0.01 : T
648
- ), O = r.getCoordinateAt(
649
- T > 1 ? 2 - T : T + 0.01
650
- ), B = le(
647
+ F > 1 ? F - 0.01 : F
648
+ ), N = r.getCoordinateAt(
649
+ F > 1 ? 2 - F : F + 0.01
650
+ ), H = le(
651
651
  mercatorToLonLat(_, "array"),
652
- mercatorToLonLat(O, "array")
652
+ mercatorToLonLat(N, "array")
653
653
  ) * Math.PI / 180;
654
- (G = te.getText()) == null || G.setRotation(B), m.setCoordinates(b);
655
- const q = getVectorContext(i);
656
- q.setStyle(te), q.drawGeometry(m), e == null || e.render();
654
+ (Z = te.getText()) == null || Z.setRotation(H), v.setCoordinates(k);
655
+ const Y = getVectorContext(i);
656
+ Y.setStyle(te), Y.drawGeometry(v), e == null || e.render();
657
657
  }, be = () => {
658
658
  var i;
659
- V = !0, v = Date.now(), T = 0, m = ((i = f.getGeometry()) == null ? void 0 : i.clone()) || new Point([0, 0]), o && (g == null || g.on("postrender", o)), F == null || F.setGeometry(void 0);
659
+ O = !0, f = Date.now(), F = 0, v = ((i = w.getGeometry()) == null ? void 0 : i.clone()) || new Point([0, 0]), o && (y == null || y.on("postrender", o)), P == null || P.setGeometry(void 0);
660
660
  }, U = () => {
661
- V && (V = !1, F == null || F.setGeometry(void 0), o && g && g.un("postrender", o), g && (e == null || e.removeLayer(g)), g = null, F = null);
661
+ O && (O = !1, P == null || P.setGeometry(void 0), o && y && y.un("postrender", o), y && (e == null || e.removeLayer(y)), y = null, P = null);
662
662
  }, ke = (i, c) => {
663
- V && U(), t = new Polyline({
663
+ O && U(), t = new Polyline({
664
664
  factor: 1e6
665
665
  }).writeGeometry(new LineString(i)), r = new Polyline({
666
666
  factor: 1e6
667
667
  }).readGeometry(t, {
668
668
  dataProjection: projection.data,
669
669
  featureProjection: projection.mercator
670
- }), f = new Feature({
670
+ }), w = new Feature({
671
671
  type: "icon",
672
672
  geometry: new Point(r.getFirstCoordinate())
673
673
  });
674
- const d = f.getGeometry();
675
- m = d ? d.clone() : new Point([0, 0]), F = new Feature({
674
+ const d = w.getGeometry();
675
+ v = d ? d.clone() : new Point([0, 0]), P = new Feature({
676
676
  type: "geoMarker",
677
677
  style: te,
678
- geometry: m
679
- }), g = new VectorLayer({
678
+ geometry: v
679
+ }), y = new VectorLayer({
680
680
  source: new VectorSource({
681
- features: [F]
681
+ features: [P]
682
682
  })
683
- }), e == null || e.addLayer(g), o = (w) => Me(w, c), be();
683
+ }), e == null || e.addLayer(y), o = (p) => Me(p, c), be();
684
684
  }, le = (i, c, d) => {
685
- function w(k) {
686
- return 180 * (k % (2 * Math.PI)) / Math.PI;
685
+ function p(C) {
686
+ return 180 * (C % (2 * Math.PI)) / Math.PI;
687
687
  }
688
- function M(k) {
689
- return k % 360 * Math.PI / 180;
688
+ function b(C) {
689
+ return C % 360 * Math.PI / 180;
690
690
  }
691
- function b(k) {
692
- var G;
693
- if (!k) throw new Error("Coordinate is required");
694
- if (!Array.isArray(k)) {
695
- if ((k == null ? void 0 : k.type) === "Feature" && (k == null ? void 0 : k.geometry) !== null && ((G = k == null ? void 0 : k.geometry) == null ? void 0 : G.type) === "Point")
696
- return k == null ? void 0 : k.geometry.coordinates;
697
- if (k.type === "Point") return (k == null ? void 0 : k.coordinates) || [];
691
+ function k(C) {
692
+ var Z;
693
+ if (!C) throw new Error("Coordinate is required");
694
+ if (!Array.isArray(C)) {
695
+ if ((C == null ? void 0 : C.type) === "Feature" && (C == null ? void 0 : C.geometry) !== null && ((Z = C == null ? void 0 : C.geometry) == null ? void 0 : Z.type) === "Point")
696
+ return C == null ? void 0 : C.geometry.coordinates;
697
+ if (C.type === "Point") return (C == null ? void 0 : C.coordinates) || [];
698
698
  }
699
- if (Array.isArray(k) && k.length >= 2 && !Array.isArray(k[0]) && !Array.isArray(k[1]))
700
- return k;
699
+ if (Array.isArray(C) && C.length >= 2 && !Array.isArray(C[0]) && !Array.isArray(C[1]))
700
+ return C;
701
701
  throw new Error(
702
702
  "Coordinate must be GeoJSON Point or an Array of numbers"
703
703
  );
704
704
  }
705
- function _(k, G, j = {}) {
706
- if (j.final)
705
+ function _(C, Z, B = {}) {
706
+ if (B.final)
707
707
  return function(Te, Se) {
708
708
  return (_(Se, Te) + 180) % 360;
709
- }(k, G);
710
- const W = b(k), J = b(G), I = M(W[0]), ee = M(J[0]), se = M(W[1]), oe = M(J[1]), Ce = Math.sin(ee - I) * Math.cos(oe), Ee = Math.cos(se) * Math.sin(oe) - Math.sin(se) * Math.cos(oe) * Math.cos(ee - I);
711
- return w(Math.atan2(Ce, Ee));
709
+ }(C, Z);
710
+ const j = k(C), J = k(Z), I = b(j[0]), ee = b(J[0]), se = b(j[1]), oe = b(J[1]), Ce = Math.sin(ee - I) * Math.cos(oe), Ee = Math.cos(se) * Math.sin(oe) - Math.sin(se) * Math.cos(oe) * Math.cos(ee - I);
711
+ return p(Math.atan2(Ce, Ee));
712
712
  }
713
- function O(k) {
714
- return !isNaN(k) && k !== null && !Array.isArray(k);
713
+ function N(C) {
714
+ return !isNaN(C) && C !== null && !Array.isArray(C);
715
715
  }
716
- function A(k, G = {}, j = {}) {
717
- return k || console.log("Coordinates are required"), Array.isArray(k) || console.log("Coordinates must be an Array"), k.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!O(k[0]) || !O(k[1])) && console.log("Coordinates must contain numbers"), B({ type: "Point", coordinates: k }, G, j);
716
+ function z(C, Z = {}, B = {}) {
717
+ return C || console.log("Coordinates are required"), Array.isArray(C) || console.log("Coordinates must be an Array"), C.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!N(C[0]) || !N(C[1])) && console.log("Coordinates must contain numbers"), H({ type: "Point", coordinates: C }, Z, B);
718
718
  }
719
- function B(k, G = {}, j = {}) {
720
- const W = {
719
+ function H(C, Z = {}, B = {}) {
720
+ const j = {
721
721
  type: "Feature",
722
722
  id: "",
723
723
  properties: {},
724
724
  bbox: {},
725
725
  geometry: {}
726
726
  };
727
- return j.id !== void 0 && (W.id = j.id), j.bbox && (W.bbox = j.bbox), W.properties = G, W.geometry = k, W;
727
+ return B.id !== void 0 && (j.id = B.id), B.bbox && (j.bbox = B.bbox), j.properties = Z, j.geometry = C, j;
728
728
  }
729
- const q = _(A(i), A(c), d);
730
- return q < 0 ? 360 + q : q;
729
+ const Y = _(z(i), z(c), d);
730
+ return Y < 0 ? 360 + Y : Y;
731
731
  };
732
732
  return {
733
- render: x,
734
- remove: he,
733
+ render: V,
734
+ remove: me,
735
735
  play: Le,
736
736
  setCenter: ne,
737
737
  close: we,
738
738
  getLength: pe,
739
- handleTrackMapEvent: K,
740
- reRenderTrackLine: S
739
+ handleTrackMapEvent: X,
740
+ reRenderTrackLine: g
741
741
  };
742
742
  };
743
743
  function useShipOverlay(e) {
744
- const n = ref(null);
744
+ const s = ref(null);
745
745
  ref(null);
746
746
  const l = computed(() => ({
747
747
  "--overlay-color": e.color || "#FFF",
748
748
  "--bg-color": e.selected ? e.color : "#ffffff",
749
749
  position: "relative",
750
750
  "pointer-events": "none"
751
- })), s = computed(() => ({
751
+ })), n = computed(() => ({
752
752
  position: "relative",
753
753
  "border-radius": "1px",
754
754
  "background-color": "var(--bg-color)",
@@ -784,7 +784,7 @@ function useShipOverlay(e) {
784
784
  left: "-20px"
785
785
  }));
786
786
  return () => h("div", {
787
- ref: n,
787
+ ref: s,
788
788
  class: "ship-overlay-container",
789
789
  style: l.value
790
790
  }, [
@@ -792,7 +792,7 @@ function useShipOverlay(e) {
792
792
  "div",
793
793
  {
794
794
  class: "ship-overlay-content",
795
- style: s.value
795
+ style: n.value
796
796
  },
797
797
  [
798
798
  h("div", {
@@ -849,43 +849,43 @@ function useShipOverlay(e) {
849
849
  ]);
850
850
  }
851
851
  ref([]);
852
- function addOverlay(e, n, l, s) {
853
- if (n) {
852
+ function addOverlay(e, s, l, n) {
853
+ if (s) {
854
854
  const a = new Overlay({
855
855
  element: l,
856
856
  positioning: "top-left",
857
- id: "label-" + (s == null ? void 0 : s.id),
857
+ id: "label-" + (n == null ? void 0 : n.id),
858
858
  offset: [20, -20],
859
859
  autoPan: !1,
860
- position: n,
861
- className: s.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
860
+ position: s,
861
+ className: n.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
862
862
  });
863
863
  a.set("class", "zh-map-ship-overlay"), e.addOverlay(a);
864
864
  }
865
865
  }
866
866
  const getShipDirectPath = (e) => {
867
- const { spd: n, hdg: l, cog: s } = e;
868
- return n ? l !== null && +l != 511 && s !== null ? s - +l >= 3 ? SHIP_DIRECT.right : s - +l <= -3 ? SHIP_DIRECT.left : SHIP_DIRECT.front : SHIP_DIRECT.front : "";
869
- }, createShipStyle = (e, n) => {
870
- const { shipData: l } = n.getProperties(), s = getShipType(e), a = getShipScale(e, l, s);
871
- return initShipStyle(n, a, s);
867
+ const { spd: s, hdg: l, cog: n } = e;
868
+ 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 : "";
869
+ }, createShipStyle = (e, s) => {
870
+ const { shipData: l } = s.getProperties(), n = getShipType(e), a = getShipScale(e, l, n);
871
+ return initShipStyle(s, a, n);
872
872
  }, getShipType = (e) => {
873
- const n = e == null ? void 0 : e.getView().getZoom();
874
- return n <= MAP_ZOOM.shipModelMax && n >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
875
- }, getShipScale = (e, n, l) => {
873
+ const s = e == null ? void 0 : e.getView().getZoom();
874
+ return s <= MAP_ZOOM.shipModelMax && s >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
875
+ }, getShipScale = (e, s, l) => {
876
876
  if (l === "ship") {
877
- const { len: s, wid: a } = n, o = 97, y = 20, t = 1 / (e == null ? void 0 : e.getView().getResolution()), r = s * t / o, f = a * t / y;
878
- return Math.max(r, f);
877
+ const { len: n, wid: a } = s, o = 97, m = 20, t = 1 / (e == null ? void 0 : e.getView().getResolution()), r = n * t / o, w = a * t / m;
878
+ return Math.max(r, w);
879
879
  }
880
880
  return MAP_ZOOM.scaleNum;
881
- }, initShipStyle = (e, n, l) => {
882
- const { color: s, direct: a, isHighlight: o, shipData: y } = e.getProperties(), E = ((y == null ? void 0 : y.cog) - 90 + 360) % 360;
881
+ }, initShipStyle = (e, s, l) => {
882
+ const { color: n, direct: a, isHighlight: o, shipData: m } = e.getProperties(), L = ((m == null ? void 0 : m.cog) - 90 + 360) % 360;
883
883
  return new Style({
884
884
  image: new Icon({
885
885
  src: t(),
886
- scale: n || MAP_ZOOM.scaleNum,
886
+ scale: s || MAP_ZOOM.scaleNum,
887
887
  anchor: [0.5, 0.5],
888
- rotation: E * Math.PI / 180,
888
+ rotation: L * Math.PI / 180,
889
889
  rotateWithView: !1
890
890
  })
891
891
  });
@@ -897,7 +897,7 @@ const getShipDirectPath = (e) => {
897
897
  case "triangle":
898
898
  return `<svg width="41" height="24" viewBox="0 0 41 24" fill="none" xmlns="http://www.w3.org/2000/svg">
899
899
  <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"
900
- fill="${s}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "2" : "0.578947"}" />
900
+ fill="${n}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "2" : "0.578947"}" />
901
901
  <!--path船航向左边或者向前-->
902
902
  ${a === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${o ? "#FF2424" : "black"}" stroke-width="2"/>`}
903
903
  <!--path船航向右边-->
@@ -909,7 +909,7 @@ const getShipDirectPath = (e) => {
909
909
  case "ship":
910
910
  return `<svg width="97" height="20" viewBox="0 0 97 20" fill="none" xmlns="http://www.w3.org/2000/svg">
911
911
  <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"
912
- fill="${s}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "4" : "0.578947"}"/>
912
+ fill="${n}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "4" : "0.578947"}"/>
913
913
  ${a === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
914
914
  ${a === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
915
915
  ${a === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
@@ -919,53 +919,53 @@ const getShipDirectPath = (e) => {
919
919
  return "";
920
920
  }
921
921
  }
922
- }, selectedShipStyle = (e, n) => {
923
- const l = selectedShipElement(e, n), s = n.id, { lon: a, lat: o } = n, y = new Overlay({
922
+ }, selectedShipStyle = (e, s) => {
923
+ const l = selectedShipElement(e, s), n = s.id, { lon: a, lat: o } = s, m = new Overlay({
924
924
  element: l,
925
925
  position: fromLonLat([a, o]),
926
- id: "selected-" + s,
926
+ id: "selected-" + n,
927
927
  positioning: "center-center",
928
928
  offset: [0, 5],
929
929
  className: "ship-selected-overlay"
930
930
  });
931
- return y.set("class", "ship-overlay-selected"), y;
932
- }, selectedShipElement = (e, n) => {
933
- const l = getShipType(e), s = getShipScale(e, n, l), a = l === "ship" ? 109 : 49, o = `
934
- <svg style="transform:scale(${s});" xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 49 49" fill="none">
931
+ return m.set("class", "ship-overlay-selected"), m;
932
+ }, selectedShipElement = (e, s) => {
933
+ const l = getShipType(e), n = getShipScale(e, s, l), a = l === "ship" ? 109 : 49, o = `
934
+ <svg style="transform:scale(${n});" xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 49 49" fill="none">
935
935
  <path d="M1.99982 46.9998L1.99982 1.99982L46.9998 1.99982L46.9998 46.9998L1.99982 46.9998Z" fill="#FF2424" fill-opacity="0.2"/>
936
936
  <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"/>
937
937
  </svg>
938
- `, y = document.createElement("div");
939
- return y.className = "ship-overlay-selected", y.innerHTML = o, y;
940
- }, createLabelStyle = (e, n) => {
941
- const { shipData: l, blinking: s } = n.getProperties(), { lon: a, lat: o } = l, y = createLabelElement(n);
942
- a && o && addOverlay(e, fromLonLat([a, o]), y, { ...l, blinking: s });
938
+ `, m = document.createElement("div");
939
+ return m.className = "ship-overlay-selected", m.innerHTML = o, m;
940
+ }, createLabelStyle = (e, s) => {
941
+ const { shipData: l, blinking: n } = s.getProperties(), { lon: a, lat: o } = l, m = createLabelElement(s);
942
+ a && o && addOverlay(e, fromLonLat([a, o]), m, { ...l, blinking: n });
943
943
  }, createLabelElement = (e) => {
944
- const n = document.createElement("div");
945
- n.className = "ship-overlay-box", n.style.position = "relative";
946
- const l = e.getProperties(), { shipData: s, blinking: a, blinkingColor: o, name: y } = l, { lon: E, lat: t } = s, r = createVNode({
944
+ const s = document.createElement("div");
945
+ s.className = "ship-overlay-box", s.style.position = "relative";
946
+ const l = e.getProperties(), { shipData: n, blinking: a, blinkingColor: o, name: m } = l, { lon: L, lat: t } = n, r = createVNode({
947
947
  setup() {
948
948
  return useShipOverlay({
949
949
  selected: a,
950
- name: y,
950
+ name: m,
951
951
  color: o,
952
- existDevice: s == null ? void 0 : s.existDevice,
953
- existMobile: s == null ? void 0 : s.existMobile,
954
- existWaterGauge: s == null ? void 0 : s.existWaterGauge
952
+ existDevice: n == null ? void 0 : n.existDevice,
953
+ existMobile: n == null ? void 0 : n.existMobile,
954
+ existWaterGauge: n == null ? void 0 : n.existWaterGauge
955
955
  });
956
956
  }
957
957
  });
958
- return render(r, n), n;
958
+ return render(r, s), s;
959
959
  }, getRightIcons = (e) => {
960
- const n = [];
961
- return e.existDevice && n.push("&#xe687;"), e.existMobile && n.push("&#xe688;"), e.existWaterGauge && n.push("&#xe686;"), n;
960
+ const s = [];
961
+ return e.existDevice && s.push("&#xe687;"), e.existMobile && s.push("&#xe688;"), e.existWaterGauge && s.push("&#xe686;"), s;
962
962
  }, createLabelFeatureStyle = (e) => {
963
- const { name: n, rightIcons: l } = e.getProperties(), s = `${n} ${l.map((f) => getIconFont(f)).join(" ")} `, a = [20, -20], y = -Math.atan2(-a[1], a[0]), E = Math.sqrt(a[0] ** 2 + a[1] ** 2), t = `<svg viewBox="0 0 ${E + 10} 20" width="${E + 10}" height="20" xmlns="http://www.w3.org/2000/svg" >
964
- <line x1="0" y1="0" x2="${10 + E}" y2="10" stroke="white" stroke-width="1"></line>
963
+ const { name: s, rightIcons: l } = e.getProperties(), n = `${s} ${l.map((w) => getIconFont(w)).join(" ")} `, a = [20, -20], m = -Math.atan2(-a[1], a[0]), L = Math.sqrt(a[0] ** 2 + a[1] ** 2), t = `<svg viewBox="0 0 ${L + 10} 20" width="${L + 10}" height="20" xmlns="http://www.w3.org/2000/svg" >
964
+ <line x1="0" y1="0" x2="${10 + L}" y2="10" stroke="white" stroke-width="1"></line>
965
965
  </svg>`;
966
966
  return [new Style({
967
967
  text: new Text({
968
- text: s,
968
+ text: n,
969
969
  fill: new Fill({ color: "#000000" }),
970
970
  stroke: new Stroke({ color: "#ffffff", width: 1 }),
971
971
  font: "Normal 12px map-iconfont",
@@ -978,18 +978,18 @@ const getShipDirectPath = (e) => {
978
978
  src: `data:image/svg+xml;utf8,${encodeURIComponent(t)}`,
979
979
  displacement: [16, -10],
980
980
  anchor: [0.5, 0.5],
981
- rotation: y,
981
+ rotation: m,
982
982
  rotateWithView: !1
983
983
  })
984
984
  })];
985
985
  }, useShipManager = (e) => {
986
- let n = null, l = null;
987
- const s = new VectorSource(), a = new VectorImageLayer({
988
- source: s,
986
+ let s = null, l = null;
987
+ const n = new VectorSource(), a = new VectorImageLayer({
988
+ source: n,
989
989
  className: "zh-map--ship-layer",
990
990
  renderBuffer: 300,
991
991
  zIndex: 101
992
- }), o = new VectorSource(), y = new VectorLayer({
992
+ }), o = new VectorSource(), m = new VectorLayer({
993
993
  source: o,
994
994
  className: "zh-map--ship-label-layer",
995
995
  zIndex: 102,
@@ -997,24 +997,24 @@ const getShipDirectPath = (e) => {
997
997
  updateWhileAnimating: !1,
998
998
  declutter: !0
999
999
  });
1000
- e == null || e.addLayer(a), e == null || e.addLayer(y);
1001
- let E = "", t = {}, r = {};
1002
- const f = (u) => {
1000
+ e == null || e.addLayer(a), e == null || e.addLayer(m);
1001
+ let L = "", t = {}, r = {};
1002
+ const w = (u) => {
1003
1003
  if (!u || !e) return;
1004
- const L = (l == null ? void 0 : l.id) || (n == null ? void 0 : n.get("id"));
1004
+ const x = (l == null ? void 0 : l.id) || (s == null ? void 0 : s.get("id"));
1005
1005
  if (l) {
1006
- const S = u.filter((P) => P.id === L);
1007
- S.length === 0 ? u.push(l) : l = S[0];
1006
+ const g = u.filter((M) => M.id === x);
1007
+ g.length === 0 ? u.push(l) : l = g[0];
1008
1008
  }
1009
- V(), v(!0), H(u), F();
1010
- }, m = (u) => {
1011
- const L = (l == null ? void 0 : l.id) || (n == null ? void 0 : n.get("id")), S = fromLonLat([u == null ? void 0 : u.lon, u == null ? void 0 : u.lat]), P = u.fill || "#04C900", x = getShipDirectPath(u), N = new Feature({
1012
- geometry: new Point(S),
1009
+ O(), f(!0), Q(u), P();
1010
+ }, v = (u) => {
1011
+ const x = (l == null ? void 0 : l.id) || (s == null ? void 0 : s.get("id")), g = fromLonLat([u == null ? void 0 : u.lon, u == null ? void 0 : u.lat]), M = u.fill || "#04C900", V = getShipDirectPath(u), D = new Feature({
1012
+ geometry: new Point(g),
1013
1013
  // 船舶数据
1014
1014
  shipData: u,
1015
1015
  id: u.id,
1016
1016
  name: u.cnname || "未命名船舶",
1017
- selected: u.id === L,
1017
+ selected: u.id === x,
1018
1018
  // 图标
1019
1019
  rightIcons: getRightIcons(u),
1020
1020
  // 是否闪烁
@@ -1022,198 +1022,207 @@ const getShipDirectPath = (e) => {
1022
1022
  // 闪烁颜色
1023
1023
  blinkingColor: r[u.id] || "",
1024
1024
  // 船舶颜色
1025
- color: P,
1025
+ color: M,
1026
1026
  // 船艏向的方向
1027
- direct: x,
1027
+ direct: V,
1028
1028
  // shipType,
1029
1029
  // scale:scaleNum,
1030
1030
  // rotation,
1031
1031
  // 高亮
1032
1032
  isHighlight: !1
1033
1033
  });
1034
- return N.set("clickGeometry", new Circle(S)), N;
1035
- }, F = async () => {
1034
+ return D.set("clickGeometry", new Circle(g)), D;
1035
+ }, P = async () => {
1036
1036
  if (!l || !e) return;
1037
- let L = e.getOverlays().getArray().find((S) => S.get("class") == "ship-overlay-selected");
1038
- if (console.log("selectedOverlay----------", L), L) {
1039
- const S = selectedShipElement(e, l);
1040
- await L.setElement(S), await L.setPosition(fromLonLat([l.lon, l.lat]));
1037
+ let x = e.getOverlays().getArray().find((g) => g.get("class") == "ship-overlay-selected");
1038
+ if (console.log("selectedOverlay----------", x), x) {
1039
+ const g = selectedShipElement(e, l);
1040
+ await x.setElement(g), await x.setPosition(fromLonLat([l.lon, l.lat]));
1041
1041
  } else
1042
- L = selectedShipStyle(e, l), L && e.addOverlay(L);
1042
+ x = selectedShipStyle(e, l), x && e.addOverlay(x);
1043
1043
  setTimeout(() => {
1044
- var S;
1045
- L && ((S = L.get("element")) != null && S.parentElement) && (L.get("element").parentElement.style.display = "block");
1044
+ var g;
1045
+ x && ((g = x.get("element")) != null && g.parentElement) && (x.get("element").parentElement.style.display = "block");
1046
1046
  }, 20);
1047
- }, V = () => {
1048
- e && s && (s.clear(), o.clear(), v());
1049
- }, v = (u) => {
1050
- const L = e.getOverlays().getArray().filter((S) => S.get("class") == "zh-map-ship-overlay");
1051
- if (L && L.length > 0) {
1052
- for (let S = 0; S < L.length; S++)
1053
- if (!u && L[S].get("class") !== "ship-overlay-selected") {
1054
- const P = L[S];
1055
- P.setPosition(void 0), e.removeOverlay(P), P.dispose();
1047
+ }, O = () => {
1048
+ e && n && (n.clear(), o.clear(), f());
1049
+ }, f = (u) => {
1050
+ const x = e.getOverlays().getArray().filter((g) => g.get("class") == "zh-map-ship-overlay");
1051
+ if (x && x.length > 0) {
1052
+ for (let g = 0; g < x.length; g++)
1053
+ if (!u && x[g].get("class") !== "ship-overlay-selected") {
1054
+ const M = x[g];
1055
+ M.setPosition(void 0), e.removeOverlay(M), M.dispose();
1056
1056
  }
1057
1057
  }
1058
- }, g = (u, L) => {
1059
- t = u, r = L;
1060
- const S = e.getOverlays().getArray(), P = s.getFeatures();
1061
- for (const x in t) {
1062
- const N = t[x], D = S.find(($) => $.getId() === "label-" + x), z = P.find(($) => x === $.get("id"));
1063
- if (D && z) {
1064
- z.set("blinking", N), z.set("blinkingColor", r[x] || "");
1065
- const $ = D.getElement(), R = createLabelElement(z), K = R.querySelector(".ship-overlay-line"), Q = $ == null ? void 0 : $.querySelector(".ship-overlay-line");
1066
- $ && $ !== R && (Q && K && K.replaceWith(Q), D.setElement(R));
1058
+ }, y = (u, x) => {
1059
+ t = u, r = x;
1060
+ const g = e.getOverlays().getArray(), M = n.getFeatures();
1061
+ for (const V in t) {
1062
+ const D = t[V], $ = g.find((S) => S.getId() === "label-" + V), R = M.find((S) => V === S.get("id"));
1063
+ if ($ && R) {
1064
+ R.set("blinking", D), R.set("blinkingColor", r[V] || "");
1065
+ const S = $.getElement(), A = createLabelElement(R), X = A.querySelector(".ship-overlay-line"), K = S == null ? void 0 : S.querySelector(".ship-overlay-line");
1066
+ S && S !== A && (K && X && X.replaceWith(K), $.setElement(A));
1067
1067
  }
1068
1068
  }
1069
- }, T = (u) => {
1069
+ }, F = (u) => {
1070
1070
  if (!e) return;
1071
- const L = s.getFeatures(), S = n ? n.get("id") : "", P = L.filter((D) => D.get("id") !== S), x = /* @__PURE__ */ new Map();
1072
- u.forEach((D) => {
1073
- x.set(D.id, !0);
1071
+ const x = n.getFeatures(), g = o.getFeatures(), M = s ? s.get("id") : "", V = x.filter((S) => S.get("id") !== M), D = g == null ? void 0 : g.filter((S) => S.get("id") !== M), $ = /* @__PURE__ */ new Map();
1072
+ u.forEach((S) => {
1073
+ $.set(S.id, !0);
1074
1074
  });
1075
- const N = e.getOverlays().getArray();
1076
- P.forEach((D) => {
1077
- const z = D.get("id"), $ = N.find((R) => R.getId() === "label-" + z);
1078
- if (!x.has(z))
1079
- D.setStyle([]), $ && ($.get("element").style.visibility = "hidden");
1075
+ const R = e.getOverlays().getArray();
1076
+ V.forEach((S) => {
1077
+ const A = S.get("id");
1078
+ if (!$.has(A))
1079
+ S.setStyle([]);
1080
1080
  else {
1081
- $ && ($.get("element").style.visibility = "visible");
1082
- const R = D.getStyle();
1083
- (R == null ? void 0 : R.length) == 0 && D.setStyle(createShipStyle(e, D));
1081
+ const K = S.getStyle();
1082
+ (K == null ? void 0 : K.length) == 0 && S.setStyle(createShipStyle(e, S));
1083
+ }
1084
+ const X = R.find((K) => K.getId() === "label-" + A);
1085
+ X && X.setPosition(void 0);
1086
+ }), D.forEach((S) => {
1087
+ const A = S.get("id");
1088
+ if (!$.has(A))
1089
+ S.setStyle([]);
1090
+ else {
1091
+ const X = S.getStyle();
1092
+ (X == null ? void 0 : X.length) == 0 && S.setStyle(createLabelFeatureStyle(S));
1084
1093
  }
1085
1094
  });
1086
- }, p = (u) => {
1095
+ }, E = (u) => {
1087
1096
  if (u) {
1088
1097
  console.log("选中", u);
1089
- const L = s.getFeatures().find((S) => S.get("id") === u.id);
1090
- L && (n = L), l = u, F();
1098
+ const x = n.getFeatures().find((g) => g.get("id") === u.id);
1099
+ x && (s = x), l = u, P();
1091
1100
  } else
1092
- console.log("取消选中"), l = null, n = null, Y();
1093
- }, C = debounce((u, L, S) => {
1101
+ console.log("取消选中"), l = null, s = null, q();
1102
+ }, T = debounce((u, x, g) => {
1094
1103
  if (u) {
1095
- const P = u.get("shipData"), x = u.get("id");
1096
- if (e.getTargetElement().style.cursor = x ? "pointer" : "", L === "click" && (p(P), S && S(x)), L === "hover") {
1097
- E && E !== x && Z(), E = x;
1098
- const N = s.getFeatures().find((D) => D.get("id") === E);
1099
- N == null || N.set("isHighlight", !0), N == null || N.setStyle(createShipStyle(e, N));
1104
+ const M = u.get("shipData"), V = u.get("id");
1105
+ if (e.getTargetElement().style.cursor = V ? "pointer" : "", x === "click" && (E(M), g && g(V)), x === "hover") {
1106
+ L && L !== V && G(), L = V;
1107
+ const D = n.getFeatures().find(($) => $.get("id") === L);
1108
+ D == null || D.set("isHighlight", !0), D == null || D.setStyle(createShipStyle(e, D));
1100
1109
  }
1101
1110
  } else
1102
- e.getTargetElement().style.cursor = "", Z();
1103
- }, 10), Z = () => {
1104
- const u = E ? s.getFeatures().find((L) => L.get("id") === E) : null;
1105
- E = null, u == null || u.set("isHighlight", !1), u == null || u.setStyle(createShipStyle(e, u));
1106
- }, Y = () => {
1111
+ e.getTargetElement().style.cursor = "", G();
1112
+ }, 10), G = () => {
1113
+ const u = L ? n.getFeatures().find((x) => x.get("id") === L) : null;
1114
+ L = null, u == null || u.set("isHighlight", !1), u == null || u.setStyle(createShipStyle(e, u));
1115
+ }, q = () => {
1107
1116
  try {
1108
- const L = e.getOverlays().getArray().find((S) => S.get("class") == "ship-overlay-selected");
1109
- L && L.setPosition(void 0);
1117
+ const x = e.getOverlays().getArray().find((g) => g.get("class") == "ship-overlay-selected");
1118
+ x && x.setPosition(void 0);
1110
1119
  } catch (u) {
1111
1120
  console.log(u);
1112
1121
  }
1113
- }, X = (u) => {
1114
- const L = fromLonLat([u == null ? void 0 : u.lon, u == null ? void 0 : u.lat]), S = new Feature({
1115
- geometry: new Point(L),
1122
+ }, W = (u) => {
1123
+ const x = fromLonLat([u == null ? void 0 : u.lon, u == null ? void 0 : u.lat]), g = new Feature({
1124
+ geometry: new Point(x),
1116
1125
  name: u.cnname || "未命名船舶",
1117
1126
  // 图标
1118
1127
  rightIcons: getRightIcons(u)
1119
1128
  });
1120
- S.set("id", u.id);
1121
- const P = createLabelFeatureStyle(S);
1122
- return S.setStyle(P), S;
1123
- }, H = (u) => {
1124
- const L = e.getView().getZoom();
1125
- u.forEach((S) => {
1126
- const P = m(S);
1127
- if (P.setStyle(createShipStyle(e, P)), s.addFeature(P), (l == null ? void 0 : l.id) == S.id || L >= MAP_ZOOM.shipModelMin)
1128
- if (t[S.id])
1129
- createLabelStyle(e, P);
1129
+ g.set("id", u.id);
1130
+ const M = createLabelFeatureStyle(g);
1131
+ return g.setStyle(M), g;
1132
+ }, Q = (u) => {
1133
+ const x = e.getView().getZoom();
1134
+ u.forEach((g) => {
1135
+ const M = v(g);
1136
+ if (M.setStyle(createShipStyle(e, M)), n.addFeature(M), (l == null ? void 0 : l.id) == g.id || x >= MAP_ZOOM.shipModelMin)
1137
+ if (t[g.id])
1138
+ createLabelStyle(e, M);
1130
1139
  else {
1131
- const x = X(S);
1132
- o.addFeature(x);
1140
+ const V = W(g);
1141
+ o.addFeature(V);
1133
1142
  }
1134
1143
  });
1135
1144
  };
1136
1145
  return {
1137
- render: f,
1138
- selected: p,
1139
- filter: T,
1140
- blinking: g,
1141
- clear: V,
1142
- handleShipMapEvent: C
1146
+ render: w,
1147
+ selected: E,
1148
+ filter: F,
1149
+ blinking: y,
1150
+ clear: O,
1151
+ handleShipMapEvent: T
1143
1152
  };
1144
1153
  }, useLayerManager = (e) => {
1145
- const n = () => e == null ? void 0 : e.getLayers(), l = ref("vector"), s = () => l.value, a = (t) => {
1154
+ const s = () => e == null ? void 0 : e.getLayers(), l = ref("vector"), n = () => l.value, a = (t) => {
1146
1155
  l.value = t;
1147
- const r = n();
1148
- r && (r == null || r.getArray().forEach((f) => {
1149
- (f.className_ === "vector" || f.className_ === "satellite") && f.setVisible(f.className_ === t);
1156
+ const r = s();
1157
+ r && (r == null || r.getArray().forEach((w) => {
1158
+ (w.className_ === "vector" || w.className_ === "satellite") && w.setVisible(w.className_ === t);
1150
1159
  }));
1151
1160
  }, o = ref(!1);
1152
1161
  return {
1153
- getLayers: n,
1162
+ getLayers: s,
1154
1163
  getGreenTileVisible: () => o.value,
1155
1164
  setGreenTileVisible: (t) => {
1156
1165
  if (t !== o.value) {
1157
1166
  if (t) {
1158
- const r = n();
1159
- if (!r.getArray().find((m) => m.className_ === "greenTile")) {
1160
- const m = new TileLayer({
1167
+ const r = s();
1168
+ if (!r.getArray().find((v) => v.className_ === "greenTile")) {
1169
+ const v = new TileLayer({
1161
1170
  source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
1162
1171
  visible: t,
1163
1172
  zIndex: 2,
1164
1173
  className: "greenTile"
1165
1174
  });
1166
- r.push(m);
1175
+ r.push(v);
1167
1176
  }
1168
1177
  } else {
1169
- const r = n(), f = r.getArray().find((m) => m.className_ === "greenTile");
1170
- f && r.remove(f);
1178
+ const r = s(), w = r.getArray().find((v) => v.className_ === "greenTile");
1179
+ w && r.remove(w);
1171
1180
  }
1172
1181
  o.value = t;
1173
1182
  }
1174
1183
  },
1175
- getShowLayerType: s,
1184
+ getShowLayerType: n,
1176
1185
  setShowLayerType: a
1177
1186
  };
1178
1187
  }, usePropsManager = () => {
1179
1188
  const e = ref();
1180
1189
  return {
1181
- setProps: (s) => {
1182
- e.value = s;
1190
+ setProps: (n) => {
1191
+ e.value = n;
1183
1192
  },
1184
1193
  getProps: () => e.value
1185
1194
  };
1186
1195
  }, usePositionManager = (e) => {
1187
- const n = "zh-map-location-layer";
1188
- let l, s, a = null, o = null;
1189
- const y = (v) => {
1190
- if (!(!v || v.length === 0)) {
1191
- if (s || (s = new VectorSource()), s.clear(), o) {
1192
- const g = v.find((T) => T.id === o.id);
1193
- g ? o = g : v.push(o);
1196
+ const s = "zh-map-location-layer";
1197
+ let l, n, a = null, o = null;
1198
+ const m = (f) => {
1199
+ if (!(!f || f.length === 0)) {
1200
+ if (n || (n = new VectorSource()), n.clear(), o) {
1201
+ const y = f.find((F) => F.id === o.id);
1202
+ y ? o = y : f.push(o);
1194
1203
  }
1195
- v.forEach((g) => {
1196
- E(g);
1204
+ f.forEach((y) => {
1205
+ L(y);
1197
1206
  }), l || (l = new VectorLayer({
1198
- className: n,
1199
- source: s,
1207
+ className: s,
1208
+ source: n,
1200
1209
  zIndex: 100
1201
1210
  }), e == null || e.addLayer(l));
1202
1211
  }
1203
- }, E = (v) => {
1204
- const g = getZoom(), [T, p] = v.latLon.split(","), C = new Feature({
1205
- geometry: new Point(fromLonLat([Number(T), Number(p)]))
1212
+ }, L = (f) => {
1213
+ const y = getZoom(), [F, E] = f.latLon.split(","), T = new Feature({
1214
+ geometry: new Point(fromLonLat([Number(F), Number(E)]))
1206
1215
  });
1207
- C.setStyle(t(v, g, v.id === (o == null ? void 0 : o.id))), C.set("loactionData", v), s.addFeature(C);
1208
- }, t = (v, g, T) => {
1209
- const p = {
1216
+ T.setStyle(t(f, y, f.id === (o == null ? void 0 : o.id))), T.set("loactionData", f), n.addFeature(T);
1217
+ }, t = (f, y, F) => {
1218
+ const E = {
1210
1219
  image: new Icon({
1211
- src: T && v.selectedPath || v.defaultPath,
1212
- scale: 0.5 * g / 10
1220
+ src: F && f.selectedPath || f.defaultPath,
1221
+ scale: 0.5 * y / 10
1213
1222
  })
1214
1223
  };
1215
- return v.name && (p.text = new Text({
1216
- text: v.name,
1224
+ return f.name && (E.text = new Text({
1225
+ text: f.name,
1217
1226
  font: "12px sans-serif",
1218
1227
  fill: new Fill({
1219
1228
  color: "#000000"
@@ -1222,57 +1231,60 @@ const getShipDirectPath = (e) => {
1222
1231
  color: "#FFFFFF"
1223
1232
  }),
1224
1233
  offsetY: 30
1225
- })), new Style(p);
1234
+ })), new Style(E);
1226
1235
  }, r = () => {
1227
1236
  if (a) {
1228
- const v = a.get("loactionData").id;
1229
- s.getFeatures().forEach((g) => {
1230
- g.get("loactionData").id !== v && s.removeFeature(g);
1237
+ const f = a.get("loactionData").id;
1238
+ n.getFeatures().forEach((y) => {
1239
+ y.get("loactionData").id !== f && n.removeFeature(y);
1231
1240
  });
1232
1241
  } else
1233
- s.clear();
1234
- }, f = () => {
1235
- const v = a.get("loactionData"), g = getZoom();
1236
- s.getFeatures().forEach((p) => {
1237
- p.get("loactionData").id === v.id && (p == null || p.setStyle(t(v, g, !1)));
1242
+ n.clear();
1243
+ }, w = () => {
1244
+ const f = a.get("loactionData"), y = getZoom();
1245
+ n.getFeatures().forEach((E) => {
1246
+ E.get("loactionData").id === f.id && (E == null || E.setStyle(t(f, y, !1)));
1238
1247
  }), o = null, a = null;
1239
- }, m = (v) => {
1240
- v ? (F(), V(v)) : clearSelectedPort();
1241
- }, F = () => {
1248
+ }, v = (f) => {
1249
+ f ? (P(), O(f)) : clearSelectedPort();
1250
+ }, P = () => {
1242
1251
  if (a) {
1243
- const v = a.get("loactionData"), g = getZoom();
1244
- a.setStyle(t(v, g, !1));
1252
+ const f = a.get("loactionData"), y = getZoom();
1253
+ a.setStyle(t(f, y, !1));
1245
1254
  }
1246
- }, V = (v) => {
1247
- const g = s.getFeatures();
1248
- o = v, a = g.find((T) => T.get("loactionData").id === v.id);
1255
+ }, O = (f) => {
1256
+ const y = n.getFeatures();
1257
+ o = f, a = y.find((F) => F.get("loactionData").id === f.id);
1249
1258
  };
1250
1259
  return {
1251
- render: y,
1252
- selected: m,
1253
- clearSelected: f,
1260
+ render: m,
1261
+ selected: v,
1262
+ clearSelected: w,
1254
1263
  clear: r
1255
1264
  };
1256
- }, disableDoubleClickZoom = () => {
1257
- getInstall().getInteractions().forEach((n) => {
1258
- n instanceof DoubleClickZoom && n.setActive(!1);
1265
+ }, disableDoubleClickZoom = (e) => {
1266
+ e.getInteractions().forEach((s) => {
1267
+ s instanceof DoubleClickZoom && s.setActive(!1);
1259
1268
  });
1260
- }, enableDoubleClickZoom = () => {
1261
- getInstall().getInteractions().forEach((n) => {
1262
- n instanceof DoubleClickZoom && n.setActive(!0);
1269
+ }, enableDoubleClickZoom = (e) => {
1270
+ e.getInteractions().forEach((s) => {
1271
+ s instanceof DoubleClickZoom && s.setActive(!0);
1263
1272
  });
1264
- }, useDrawLineManager = (e, n) => {
1265
- const l = ref([]), s = ref("km"), a = (P) => {
1266
- s.value = P;
1273
+ }, changeCursor = (e, s) => {
1274
+ const l = e.getViewport();
1275
+ l && (l.style.cursor = s);
1276
+ }, useDrawLineManager = (e, s) => {
1277
+ const l = ref([]), n = ref("km"), a = (g) => {
1278
+ n.value = g;
1267
1279
  };
1268
1280
  let o;
1269
- const y = ref(!1), E = () => {
1270
- f(), disableDoubleClickZoom(), v("pointer"), e.on("pointermove", V), e.getViewport().addEventListener("mouseout", () => {
1281
+ const m = ref(!1), L = () => {
1282
+ w(), disableDoubleClickZoom(e), changeCursor(e, "crosshair"), e.on("pointermove", O), e.getViewport().addEventListener("mouseout", () => {
1271
1283
  o && o.classList.add("hidden");
1272
- }), T(), y.value = !0;
1284
+ }), y(), m.value = !0;
1273
1285
  };
1274
1286
  let t, r;
1275
- const f = () => {
1287
+ const w = () => {
1276
1288
  t = new VectorSource(), r = new VectorLayer({
1277
1289
  source: t,
1278
1290
  zIndex: 1e3,
@@ -1285,19 +1297,16 @@ const getShipDirectPath = (e) => {
1285
1297
  }
1286
1298
  }), e == null || e.addLayer(r);
1287
1299
  };
1288
- let m, F;
1289
- const V = (P) => {
1290
- if (P.dragging)
1300
+ let v, P;
1301
+ const O = (g) => {
1302
+ if (g.dragging)
1291
1303
  return;
1292
- let x = "点击选择起点";
1293
- m && (x = "单击继续,双击结束"), o && (o.innerHTML = x, F.setPosition(P.coordinate), o.classList.remove("hidden"));
1294
- }, v = (P) => {
1295
- const x = e == null ? void 0 : e.getTargetElement();
1296
- x && (x.style.cursor = P);
1304
+ let M = "点击选择起点";
1305
+ v && (M = "单击继续,双击结束"), o && (o.innerHTML = M, P.setPosition(g.coordinate), o.classList.remove("hidden"));
1297
1306
  };
1298
- let g;
1299
- const T = () => {
1300
- g = new Draw({
1307
+ let f;
1308
+ const y = () => {
1309
+ f = new Draw({
1301
1310
  source: t,
1302
1311
  type: "LineString",
1303
1312
  style: new Style({
@@ -1320,109 +1329,109 @@ const getShipDirectPath = (e) => {
1320
1329
  })
1321
1330
  }),
1322
1331
  // 添加条件函数,判断是否应该出发点绘制
1323
- condition: (x) => x.originalEvent.target.tagName !== "DIV"
1324
- }), e == null || e.addInteraction(g), Y(), X();
1325
- let P;
1326
- g.on("drawstart", function(x) {
1332
+ condition: (M) => M.originalEvent.target.tagName !== "DIV"
1333
+ }), e == null || e.addInteraction(f), G(), q();
1334
+ let g;
1335
+ f.on("drawstart", function(M) {
1327
1336
  var D;
1328
- m = x.feature, m.set("randomId", p());
1329
- let N;
1330
- P = (D = m.getGeometry()) == null ? void 0 : D.on("change", function(z) {
1331
- const $ = z.target, R = computedDistance($, s.value);
1332
- N = $.getLastCoordinate(), C && R && (C.innerHTML = R), Z.setPosition(N);
1337
+ v = M.feature, v.set("randomId", F());
1338
+ let V;
1339
+ g = (D = v.getGeometry()) == null ? void 0 : D.on("change", function($) {
1340
+ const R = $.target, S = computedDistance(R, n.value);
1341
+ V = R.getLastCoordinate(), E && S && (E.innerHTML = S), T.setPosition(V);
1333
1342
  });
1334
- }), g.on("drawend", function() {
1335
- var x, N, D;
1336
- if (C && (C.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), C != null && C.innerHTML) {
1337
- const z = (m == null ? void 0 : m.get("randomId")) || p();
1338
- l.value.push({ id: z, value: C == null ? void 0 : C.innerHTML }), C.innerHTML = `${C.innerHTML}<div class="ol-tooltip-delete-button" data-id="${z}"><i class="map-iconfont icon-delete"></i></div>`;
1343
+ }), f.on("drawend", function() {
1344
+ var M, V, D;
1345
+ if (E && (E.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), E != null && E.innerHTML) {
1346
+ const $ = (v == null ? void 0 : v.get("randomId")) || F();
1347
+ l.value.push({ id: $, value: E == null ? void 0 : E.innerHTML }), E.innerHTML = `${E.innerHTML}<div class="ol-tooltip-delete-button" data-id="${$}"><i class="map-iconfont icon-delete"></i></div>`;
1339
1348
  }
1340
- (x = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || x.addEventListener("click", (z) => {
1341
- var R;
1342
- z.preventDefault(), z.stopPropagation();
1343
- const $ = (R = z.target) == null ? void 0 : R.getAttribute("data-id");
1344
- $ && u($);
1345
- }), Z.setOffset([0, -7]), m = null, C = null, Y(), P && unByKey(P), (D = (N = n.getProps()) == null ? void 0 : N.lineDrawEnd) == null || D.call(N, l.value);
1349
+ (M = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || M.addEventListener("click", ($) => {
1350
+ var S;
1351
+ $.preventDefault(), $.stopPropagation();
1352
+ const R = (S = $.target) == null ? void 0 : S.getAttribute("data-id");
1353
+ R && Q(R);
1354
+ }), T.setOffset([0, -7]), v = null, E = null, G(), g && unByKey(g), (D = (V = s.getProps()) == null ? void 0 : V.lineDrawEnd) == null || D.call(V, l.value);
1346
1355
  });
1347
- }, p = () => Math.random().toString(36).substring(2, 9);
1348
- let C, Z;
1349
- const Y = () => {
1350
- C != null && C.parentNode && C.parentNode.removeChild(C), C = document.createElement("div"), C.className = "ol-tooltip ol-tooltip-measure", Z = new Overlay({
1351
- element: C,
1356
+ }, F = () => Math.random().toString(36).substring(2, 9);
1357
+ let E, T;
1358
+ const G = () => {
1359
+ E != null && E.parentNode && E.parentNode.removeChild(E), E = document.createElement("div"), E.className = "ol-tooltip ol-tooltip-measure", T = new Overlay({
1360
+ element: E,
1352
1361
  offset: [0, -15],
1353
1362
  positioning: "bottom-center",
1354
1363
  stopEvent: !1,
1355
1364
  insertFirst: !1
1356
- }), e == null || e.addOverlay(Z);
1357
- }, X = () => {
1358
- o != null && o.parentNode && o.parentNode.removeChild(o), o = document.createElement("div"), o.className = "ol-tooltip hidden", F = new Overlay({
1365
+ }), e == null || e.addOverlay(T);
1366
+ }, q = () => {
1367
+ o != null && o.parentNode && o.parentNode.removeChild(o), o = document.createElement("div"), o.className = "ol-tooltip hidden", P = new Overlay({
1359
1368
  element: o,
1360
1369
  offset: [15, 0],
1361
1370
  positioning: "center-left"
1362
- }), e == null || e.addOverlay(F);
1363
- }, H = () => {
1364
- l.value.forEach((P, x) => {
1365
- var z, $;
1366
- const N = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1367
- N[x] && (($ = (z = N[x]) == null ? void 0 : z.parentNode) == null || $.removeChild(N[x]));
1371
+ }), e == null || e.addOverlay(P);
1372
+ }, W = () => {
1373
+ l.value.forEach((g, M) => {
1374
+ var $, R;
1375
+ const V = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1376
+ V[M] && ((R = ($ = V[M]) == null ? void 0 : $.parentNode) == null || R.removeChild(V[M]));
1368
1377
  const D = t.getFeatures();
1369
- D[x] && t.removeFeature(D[x]);
1370
- }), L(), enableDoubleClickZoom(), y.value = !1;
1371
- }, u = (P) => {
1372
- var N, D, z, $;
1373
- const x = l.value.findIndex((R) => R.id === P);
1374
- if (x !== -1) {
1375
- l.value.splice(x, 1);
1376
- const R = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1377
- R[x] && ((D = (N = R[x]) == null ? void 0 : N.parentNode) == null || D.removeChild(R[x]));
1378
- const K = t.getFeatures();
1379
- K[x] && t.removeFeature(K[x]);
1378
+ D[M] && t.removeFeature(D[M]);
1379
+ }), u(), enableDoubleClickZoom(e), m.value = !1;
1380
+ }, Q = (g) => {
1381
+ var V, D, $, R;
1382
+ const M = l.value.findIndex((S) => S.id === g);
1383
+ if (M !== -1) {
1384
+ l.value.splice(M, 1);
1385
+ const S = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1386
+ S[M] && ((D = (V = S[M]) == null ? void 0 : V.parentNode) == null || D.removeChild(S[M]));
1387
+ const A = t.getFeatures();
1388
+ A[M] && t.removeFeature(A[M]);
1380
1389
  }
1381
- ($ = (z = n.getProps()) == null ? void 0 : z.lineDrawEnd) == null || $.call(z, l.value);
1382
- }, L = () => {
1383
- if (l.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((P) => {
1384
- var x;
1385
- (x = P == null ? void 0 : P.parentNode) == null || x.removeChild(P);
1386
- }), t.clear(), g) {
1387
- const P = e.getInteractions().getArray().find((x) => getUid(x) === getUid(g));
1388
- P && e.removeInteraction(P);
1390
+ (R = ($ = s.getProps()) == null ? void 0 : $.lineDrawEnd) == null || R.call($, l.value);
1391
+ }, u = () => {
1392
+ if (l.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((g) => {
1393
+ var M;
1394
+ (M = g == null ? void 0 : g.parentNode) == null || M.removeChild(g);
1395
+ }), t.clear(), f) {
1396
+ const g = e.getInteractions().getArray().find((M) => getUid(M) === getUid(f));
1397
+ g && e.removeInteraction(g);
1389
1398
  }
1390
- e.removeLayer(r), o != null && o.parentNode && o.parentNode.removeChild(o), C != null && C.parentNode && C.parentNode.removeChild(C);
1399
+ e.removeLayer(r), o != null && o.parentNode && o.parentNode.removeChild(o), E != null && E.parentNode && E.parentNode.removeChild(E);
1391
1400
  };
1392
1401
  return {
1393
- open: E,
1394
- close: H,
1395
- deleteLine: u,
1402
+ open: L,
1403
+ close: W,
1404
+ deleteLine: Q,
1396
1405
  setUnit: a,
1397
- getState: () => y.value
1406
+ getState: () => m.value
1398
1407
  };
1399
- }, computedDistance = (e, n) => {
1400
- const s = getLength(e);
1408
+ }, computedDistance = (e, s) => {
1409
+ const n = getLength(e);
1401
1410
  let a = "";
1402
- switch (n) {
1411
+ switch (s) {
1403
1412
  case "m":
1404
- a = `${Math.round(s * 100) / 100} m`;
1413
+ a = `${Math.round(n * 100) / 100} m`;
1405
1414
  break;
1406
1415
  case "km":
1407
- a = `${Math.round(s / 1e3 * 100) / 100} km`;
1416
+ a = `${Math.round(n / 1e3 * 100) / 100} km`;
1408
1417
  break;
1409
1418
  case "nm":
1410
- a = `${Math.round(s / 1.852 * 100) / 100} nm`;
1419
+ a = `${Math.round(n / 1.852 * 100) / 100} nm`;
1411
1420
  break;
1412
1421
  }
1413
1422
  return a;
1414
- }, useDrawPolygonManager = (e, n) => {
1415
- let l;
1416
- const s = () => {
1417
- a();
1418
- }, a = () => {
1419
- E(), T(), Z(), F();
1423
+ }, useDrawPolygonManager = (e, s) => {
1424
+ let l, n;
1425
+ const a = () => {
1426
+ o(), changeCursor(e, "crosshair");
1427
+ }, o = () => {
1428
+ t(), E(), q(), O();
1420
1429
  };
1421
- let o = null, y = null;
1422
- const E = () => {
1423
- if (o || y) return;
1424
- const H = new VectorSource(), u = new VectorLayer({
1425
- source: H,
1430
+ let m = null, L = null;
1431
+ const t = () => {
1432
+ if (m && L) return;
1433
+ const u = new VectorSource(), x = new VectorLayer({
1434
+ source: u,
1426
1435
  style: new Style({
1427
1436
  stroke: new Stroke({
1428
1437
  color: "#fbcc33",
@@ -1430,45 +1439,45 @@ const getShipDirectPath = (e) => {
1430
1439
  })
1431
1440
  })
1432
1441
  });
1433
- o = u, y = H, e.on("pointermove", r), e.addLayer(u), e.on(["dblclick"], function(L) {
1434
- f && (L.stopPropagation(), L.preventDefault());
1442
+ m = x, L = u, e.on("pointermove", w), e.addLayer(x), e.on(["dblclick"], function(g) {
1443
+ v && (g.stopPropagation(), g.preventDefault());
1435
1444
  });
1436
1445
  };
1437
- let t;
1438
- const r = (H) => {
1439
- if (H.dragging) return;
1440
- const u = t ? "单击继续,双击结束" : "点击选择起点";
1441
- p && (p.innerHTML = u, C.setPosition(H.coordinate));
1446
+ let r;
1447
+ const w = (u) => {
1448
+ if (u.dragging) return;
1449
+ const x = r ? "单击继续,双击结束" : "点击选择起点";
1450
+ T && (T.innerHTML = x, G.setPosition(u.coordinate));
1442
1451
  };
1443
- let f, m = !1;
1444
- const F = () => {
1452
+ let v, P = !1;
1453
+ const O = () => {
1445
1454
  if (l) {
1446
- p != null && p.parentNode && p.parentNode.removeChild(p);
1455
+ T != null && T.parentNode && T.parentNode.removeChild(T);
1447
1456
  const u = l.getGeometry();
1448
1457
  if (!u) return;
1449
- const L = V(u, "nm");
1450
- v && (v.innerHTML = `
1451
- <span class="text">面积:${L}${m ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1452
- `), v && (v.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
1453
- const S = u.getCoordinates(), P = S[0][S[0].length - 2];
1454
- if (g.setPosition(P), o) {
1455
- const N = o.getSource();
1456
- N && l && (N.clear(), N.addFeature(l));
1458
+ const x = f(u, "nm");
1459
+ y && (y.innerHTML = `
1460
+ <span class="text">面积:${x}${P ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1461
+ `), y && (y.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
1462
+ const g = u.getCoordinates(), M = g[0][g[0].length - 2];
1463
+ if (F.setPosition(M), m) {
1464
+ const D = m.getSource();
1465
+ D && l && (D.clear(), D.addFeature(l));
1457
1466
  }
1458
1467
  setTimeout(() => {
1459
- var N;
1460
- (N = document.querySelector(".delete-icon")) == null || N.addEventListener("click", () => {
1461
- var D, z;
1462
- console.log("delete"), Y(), (z = (D = n.getProps()) == null ? void 0 : D.areaDrawEnd) == null || z.call(D, []);
1468
+ var D;
1469
+ (D = document.querySelector(".delete-icon")) == null || D.addEventListener("click", () => {
1470
+ var $, R;
1471
+ console.log("delete"), W(), (R = ($ = s.getProps()) == null ? void 0 : $.areaDrawEnd) == null || R.call($, []);
1463
1472
  });
1464
1473
  }, 0);
1465
- const x = getCenter(l.getGeometry().getExtent());
1466
- e == null || e.getView().setCenter(x);
1474
+ const V = getCenter(l.getGeometry().getExtent());
1475
+ e == null || e.getView().setCenter(V);
1467
1476
  return;
1468
1477
  }
1469
- f = new Draw({
1478
+ v = new Draw({
1470
1479
  type: "Polygon",
1471
- source: y,
1480
+ source: L,
1472
1481
  trace: !0,
1473
1482
  style: [new Style({
1474
1483
  stroke: new Stroke({
@@ -1487,30 +1496,28 @@ const getShipDirectPath = (e) => {
1487
1496
  })
1488
1497
  }),
1489
1498
  geometry: function(u) {
1490
- const L = u.getGeometry().getCoordinates();
1491
- return new MultiPoint(L);
1499
+ const x = u.getGeometry().getCoordinates();
1500
+ return new MultiPoint(x);
1492
1501
  }
1493
1502
  })]
1494
- }), e == null || e.addInteraction(f);
1495
- let H;
1496
- f.on("drawstart", (u) => {
1497
- var L;
1498
- t = u.feature, H = (L = t.getGeometry()) == null ? void 0 : L.on("change", (S) => {
1499
- const P = S.target, x = V(P, "nm"), D = P.getCoordinates()[0], z = new LineString([D[D.length - 2], D[D.length - 1]]), $ = computedDistance(z, "nm");
1500
- if (m = Number(getLength(z) / 1e3) > 150, !x) return;
1501
- const R = '<span class="error pl-4">超出可以绘画的距离</span>';
1502
- v && (v.innerHTML = `
1503
+ }), e == null || e.addInteraction(v), v.on("drawstart", (u) => {
1504
+ var x;
1505
+ r = u.feature, n = (x = r.getGeometry()) == null ? void 0 : x.on("change", (g) => {
1506
+ const M = g.target, V = f(M, "nm"), $ = M.getCoordinates()[0], R = new LineString([$[$.length - 2], $[$.length - 1]]), S = computedDistance(R, "nm");
1507
+ if (P = Number(getLength(R) / 1e3) > 150, !V) return;
1508
+ const A = '<span class="error pl-4">超出可以绘画的距离</span>';
1509
+ y && (y.innerHTML = `
1503
1510
  <div class="text">
1504
- 面积:${x}
1505
- ${m ? R : ""}
1511
+ 面积:${V}
1512
+ ${P ? A : ""}
1506
1513
  </div>
1507
- `), p && (p.innerHTML = `
1514
+ `), T && (T.innerHTML = `
1508
1515
  <div class="text">
1509
- 面积:${x}
1516
+ 面积:${V}
1510
1517
  </div>
1511
- <div class="text ${m ? "error" : ""}">
1512
- 线段 ${D.length - 2}: ${$}
1513
- ${m ? R : ""}
1518
+ <div class="text ${P ? "error" : ""}">
1519
+ 线段 ${$.length - 2}: ${S}
1520
+ ${P ? A : ""}
1514
1521
 
1515
1522
  </div>
1516
1523
  <div>
@@ -1518,85 +1525,85 @@ const getShipDirectPath = (e) => {
1518
1525
  </div>
1519
1526
  `);
1520
1527
  });
1521
- }), f.on("drawend", (u) => {
1522
- var x, N, D, z;
1528
+ }), v.on("drawend", (u) => {
1529
+ var V, D, $, R;
1523
1530
  if (!u.feature.getGeometry()) return;
1524
- l = u.feature, v && (v.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), g.setOffset([10, 0]);
1525
- const S = u.feature.getGeometry().getCoordinates(), P = S[0][S[0].length - 2];
1526
- if (g.setPosition(P), p != null && p.parentNode && p.parentNode.removeChild(p), (x = n.getProps()) != null && x.areaDrawEnd) {
1527
- const $ = S[0].map((R) => transform(R, projection.mercator, projection.data));
1528
- (D = (N = n.getProps()) == null ? void 0 : N.areaDrawEnd) == null || D.call(N, $);
1531
+ l = u.feature, y && (y.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), F.setOffset([10, 0]);
1532
+ const g = u.feature.getGeometry().getCoordinates(), M = g[0][g[0].length - 2];
1533
+ if (F.setPosition(M), T != null && T.parentNode && T.parentNode.removeChild(T), (V = s.getProps()) != null && V.areaDrawEnd) {
1534
+ const S = g[0].map((A) => transform(A, projection.mercator, projection.data));
1535
+ ($ = (D = s.getProps()) == null ? void 0 : D.areaDrawEnd) == null || $.call(D, S);
1529
1536
  }
1530
- f && (f.setActive(!1), e == null || e.removeInteraction(f), (e == null ? void 0 : e.getInteractions()).forEach((R) => {
1531
- R instanceof Draw && (R.setActive(!1), e == null || e.removeInteraction(R));
1532
- })), H && unByKey(H), (z = document.querySelector(".delete-icon")) == null || z.addEventListener("click", () => {
1533
- var $, R;
1534
- Y(), (R = ($ = n.getProps()) == null ? void 0 : $.areaDrawEnd) == null || R.call($, []);
1537
+ v && (v.setActive(!1), e == null || e.removeInteraction(v), (e == null ? void 0 : e.getInteractions()).forEach((A) => {
1538
+ A instanceof Draw && (A.setActive(!1), e == null || e.removeInteraction(A));
1539
+ })), n && unByKey(n), (R = document.querySelector(".delete-icon")) == null || R.addEventListener("click", () => {
1540
+ var S, A;
1541
+ W(), (A = (S = s.getProps()) == null ? void 0 : S.areaDrawEnd) == null || A.call(S, []);
1535
1542
  });
1536
1543
  });
1537
- }, V = (H, u) => {
1538
- const L = getArea(H);
1539
- switch (u) {
1544
+ }, f = (u, x) => {
1545
+ const g = getArea(u);
1546
+ switch (x) {
1540
1547
  case "km":
1541
- return L > 1e4 ? Math.round(L / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(L * 100) / 100 + " m<sup>2</sup>";
1548
+ return g > 1e4 ? Math.round(g / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(g * 100) / 100 + " m<sup>2</sup>";
1542
1549
  case "nm":
1543
- return L > 1e4 ? Math.round(L / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(L * 100) / 100 + " m<sup>2</sup>";
1550
+ return g > 1e4 ? Math.round(g / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(g * 100) / 100 + " m<sup>2</sup>";
1544
1551
  }
1545
1552
  };
1546
- let v, g;
1547
- const T = () => {
1548
- v != null && v.parentNode && v.parentNode.removeChild(v), v = document.createElement("div"), v.style.display = "flex", v.className = "ol-tooltip ol-tooltip-draw-polygon", g = new Overlay({
1549
- element: v,
1553
+ let y, F;
1554
+ const E = () => {
1555
+ y != null && y.parentNode && y.parentNode.removeChild(y), y = document.createElement("div"), y.style.display = "flex", y.className = "ol-tooltip ol-tooltip-draw-polygon", F = new Overlay({
1556
+ element: y,
1550
1557
  offset: [0, -15],
1551
1558
  positioning: "bottom-center",
1552
1559
  stopEvent: !1,
1553
1560
  insertFirst: !1
1554
- }), e == null || e.addOverlay(g);
1561
+ }), e == null || e.addOverlay(F);
1555
1562
  };
1556
- let p, C;
1557
- const Z = () => {
1558
- p != null && p.parentNode && p.parentNode.removeChild(p), p = document.createElement("div"), p.className = "ol-tooltip ol-help-tooltip", C = new Overlay({
1559
- element: p,
1563
+ let T, G;
1564
+ const q = () => {
1565
+ T != null && T.parentNode && T.parentNode.removeChild(T), T = document.createElement("div"), T.className = "ol-tooltip ol-help-tooltip", G = new Overlay({
1566
+ element: T,
1560
1567
  offset: [15, 0],
1561
1568
  positioning: "center-left"
1562
- }), e == null || e.addOverlay(C);
1563
- }, Y = () => {
1564
- y == null || y.clear(), l = null, T(), Z(), F();
1569
+ }), e == null || e.addOverlay(G);
1570
+ }, W = () => {
1571
+ L == null || L.clear(), l = null, E(), q(), O();
1565
1572
  };
1566
1573
  return {
1567
- open: s,
1574
+ open: a,
1568
1575
  close: () => {
1569
- y == null || y.clear(), y = null, o && (e.removeLayer(o), o = null), t = null, f && (f = null, e.getInteractions().forEach((H) => {
1570
- H instanceof Draw && e.removeInteraction(H);
1571
- })), p != null && p.parentElement && p.parentElement.removeChild(p), v != null && v.parentElement && v.parentElement.removeChild(v), C && e.removeOverlay(C), g && e.removeOverlay(g);
1576
+ L == null || L.clear(), L = null, m && (e.removeLayer(m), m = null), r = null, v && (v.setActive(!1), (e == null ? void 0 : e.getInteractions()).forEach((x) => {
1577
+ x instanceof Draw && (x.setActive(!1), e == null || e.removeInteraction(x));
1578
+ }), v = null), n && unByKey(n), T != null && T.parentElement && T.parentElement.removeChild(T), y != null && y.parentElement && y.parentElement.removeChild(y), G && e.removeOverlay(G), F && e.removeOverlay(F), changeCursor(e, "pointer");
1572
1579
  },
1573
- reset: Y
1580
+ reset: W
1574
1581
  };
1575
1582
  }, PORT_LAYER_CLASS_NAME = "zh-map-port-layer", usePortManager = (e) => {
1576
- const n = e.getInstall();
1577
- let l, s, a = null, o = null;
1578
- const y = (g) => {
1579
- if (!(!g || g.length === 0)) {
1580
- if (s || (s = new VectorSource()), s.clear(), o) {
1581
- const T = g.find((p) => p.id === o.id);
1582
- T ? o = T : g.push(o);
1583
+ const s = e.getInstall();
1584
+ let l, n, a = null, o = null;
1585
+ const m = (f) => {
1586
+ if (!(!f || f.length === 0)) {
1587
+ if (n || (n = new VectorSource()), n.clear(), o) {
1588
+ const y = f.find((F) => F.id === o.id);
1589
+ y ? o = y : f.push(o);
1583
1590
  }
1584
- g.forEach((T) => {
1585
- E(T);
1591
+ f.forEach((y) => {
1592
+ L(y);
1586
1593
  }), l || (l = new VectorLayer({
1587
1594
  className: PORT_LAYER_CLASS_NAME,
1588
- source: s,
1595
+ source: n,
1589
1596
  zIndex: 100
1590
- }), n.addLayer(l));
1597
+ }), s.addLayer(l));
1591
1598
  }
1592
- }, E = (g) => {
1593
- const T = e.getZoom(), [p, C] = g.latLon.split(","), Z = new Feature({
1594
- geometry: new Point(fromLonLat([Number(p), Number(C)]))
1599
+ }, L = (f) => {
1600
+ const y = e.getZoom(), [F, E] = f.latLon.split(","), T = new Feature({
1601
+ geometry: new Point(fromLonLat([Number(F), Number(E)]))
1595
1602
  });
1596
- Z.setStyle(t(g, T, g.id === (o == null ? void 0 : o.id))), Z.set("portData", g), s.addFeature(Z);
1597
- }, t = (g, T, p) => {
1598
- const C = (Y) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
1599
- <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="${Y}"/>
1603
+ T.setStyle(t(f, y, f.id === (o == null ? void 0 : o.id))), T.set("portData", f), n.addFeature(T);
1604
+ }, t = (f, y, F) => {
1605
+ const E = (G) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
1606
+ <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="${G}"/>
1600
1607
  <g clip-path="url(#clip0_10059_122082)">
1601
1608
  <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"/>
1602
1609
  </g>
@@ -1606,138 +1613,136 @@ const getShipDirectPath = (e) => {
1606
1613
  </clipPath>
1607
1614
  </defs>
1608
1615
  </svg>
1609
- `, Z = () => `data:image/svg+xml;utf8,${encodeURIComponent(C(p ? "#FF5733" : "#3370FF"))}`;
1616
+ `, T = () => `data:image/svg+xml;utf8,${encodeURIComponent(E(F ? "#FF5733" : "#3370FF"))}`;
1610
1617
  return new Style({
1611
1618
  text: new Text({
1612
- text: g.shortName,
1619
+ text: f.shortName,
1613
1620
  font: "12px sans-serif",
1614
1621
  fill: new Fill({
1615
- color: p ? "#ffffff" : "#000000"
1622
+ color: F ? "#ffffff" : "#000000"
1616
1623
  }),
1617
1624
  backgroundFill: new Fill({
1618
- color: p ? "#FF5733" : "#FFFFFF"
1625
+ color: F ? "#FF5733" : "#FFFFFF"
1619
1626
  }),
1620
1627
  offsetY: 30
1621
1628
  }),
1622
1629
  image: new Icon({
1623
- src: Z(),
1624
- scale: 0.5 * T / 10
1625
- })
1630
+ src: T(),
1631
+ scale: 0.5 * y / 10
1632
+ }),
1633
+ zIndex: F ? 110 : 100
1626
1634
  });
1627
1635
  }, r = () => {
1628
1636
  if (a) {
1629
1637
  console.log("清除非选中的港口");
1630
- const g = a.get("portData").id;
1631
- s.getFeatures().forEach((T) => {
1632
- T.get("portData").id !== g && s.removeFeature(T);
1638
+ const f = a.get("portData").id;
1639
+ n.getFeatures().forEach((y) => {
1640
+ y.get("portData").id !== f && n.removeFeature(y);
1633
1641
  });
1634
1642
  } else
1635
- console.log("清除所有港口"), s.clear();
1636
- }, f = () => {
1637
- const g = a == null ? void 0 : a.get("portData"), T = e.getZoom();
1638
- g && s.getFeatures().forEach((C) => {
1639
- C.get("portData").id === g.id && (C == null || C.setStyle(t(g, T, !1)));
1640
- }), o = null, a = null;
1641
- }, m = (g) => {
1642
- g ? (F(), V(g)) : f();
1643
- }, F = () => {
1643
+ console.log("清除所有港口", n), n == null || n.clear();
1644
+ }, w = (f) => {
1645
+ if (!f)
1646
+ return v();
1647
+ (a == null ? void 0 : a.get("portData").id) !== f.id && (v(), P(f));
1648
+ }, v = () => {
1644
1649
  if (a) {
1645
- const g = a == null ? void 0 : a.get("portData"), T = e.getZoom();
1646
- a.setStyle(t(g, T, !1));
1650
+ const f = a == null ? void 0 : a.get("portData"), y = e.getZoom();
1651
+ a.setStyle(t(f, y, !1));
1647
1652
  }
1648
- }, V = (g) => {
1649
- const T = s.getFeatures();
1650
- o = g, a = T.find((p) => p.get("portData").id === g.id);
1653
+ }, P = (f) => {
1654
+ const y = n.getFeatures();
1655
+ o = f, a = y.find((F) => F.get("portData").id === f.id), a.setStyle(t(f, e.getZoom(), !0));
1651
1656
  };
1652
1657
  return {
1653
- render: y,
1658
+ render: m,
1654
1659
  clear: r,
1655
- selected: m,
1656
- handlePortHover: (g) => {
1657
- const T = n == null ? void 0 : n.getTargetElement();
1658
- g && g.get("portData") && T && (T.style.cursor = "pointer");
1660
+ selected: w,
1661
+ handlePortHover: (f) => {
1662
+ const y = s == null ? void 0 : s.getTargetElement();
1663
+ f && f.get("portData") && y && (y.style.cursor = "pointer");
1659
1664
  }
1660
1665
  };
1661
- }, useEventManager = (e, n, l, s, a, o) => {
1662
- const y = e.getInstall();
1663
- y.on("moveend", () => {
1666
+ }, useEventManager = (e, s, l, n, a, o) => {
1667
+ const m = e.getInstall();
1668
+ m.on("moveend", () => {
1664
1669
  var t, r;
1665
- const E = e.getZoom();
1666
- (r = (t = n.getProps()).mapMoveEnd) == null || r.call(t, E), l.reRenderTrackLine();
1667
- }), y.on("pointermove", (E) => {
1668
- const t = y.getEventPixel(E.originalEvent), r = y.forEachFeatureAtPixel(t, (f) => f);
1669
- s.handleShipMapEvent(r, "hover"), l.handleTrackMapEvent(r, "hover", E), r && a.handlePortHover(r);
1670
- }), y.on("movestart", () => {
1670
+ const L = e.getZoom();
1671
+ (r = (t = s.getProps()).mapMoveEnd) == null || r.call(t, L), l.reRenderTrackLine();
1672
+ }), m.on("pointermove", (L) => {
1673
+ const t = m.getEventPixel(L.originalEvent), r = m.forEachFeatureAtPixel(t, (w) => w);
1674
+ n.handleShipMapEvent(r, "hover"), l.handleTrackMapEvent(r, "hover", L), r && a.handlePortHover(r);
1675
+ }), m.on("movestart", () => {
1671
1676
  console.log("movestart-----------------------");
1672
- }), y.on("click", debounce((E) => {
1673
- var f, m, F;
1677
+ }), m.on("click", debounce((L) => {
1678
+ var w, v, P;
1674
1679
  if (console.log("1", o.getState()), o.getState()) return;
1675
- const t = y.getEventPixel(E.originalEvent), r = y.forEachFeatureAtPixel(
1680
+ const t = m.getEventPixel(L.originalEvent), r = m.forEachFeatureAtPixel(
1676
1681
  t,
1677
- (V) => {
1678
- if (V != null && V.get("shipData") || V != null && V.get("portData"))
1679
- return V;
1682
+ (O) => {
1683
+ if (O != null && O.get("shipData") || O != null && O.get("portData"))
1684
+ return O;
1680
1685
  }
1681
1686
  );
1682
1687
  if (console.log("2", r), !!r) {
1683
- if (E.preventDefault(), E.stopPropagation(), r.get("shipData"))
1684
- s.handleShipMapEvent(r, "click", (f = n.getProps()) == null ? void 0 : f.selectShip);
1688
+ if (L.preventDefault(), L.stopPropagation(), r.get("shipData"))
1689
+ n.handleShipMapEvent(r, "click", (w = s.getProps()) == null ? void 0 : w.selectShip);
1685
1690
  else if (r.get("portData")) {
1686
- const V = r.get("portData");
1687
- a.selected(V), (F = (m = n.getProps()) == null ? void 0 : m.selectPort) == null || F.call(m, V);
1691
+ const O = r.get("portData");
1692
+ a.selected(O), (P = (v = s.getProps()) == null ? void 0 : v.selectPort) == null || P.call(v, O);
1688
1693
  }
1689
1694
  }
1690
1695
  }, 150));
1691
1696
  }, useMapController = () => {
1692
1697
  const e = reactive([]);
1693
1698
  return {
1694
- createInstance: (s, a) => {
1699
+ createInstance: (n, a) => {
1695
1700
  const o = useMapInitializer();
1696
- o.initMap(s, a);
1697
- const y = o.getInstall(), E = useLayerManager(y), t = usePropsManager();
1698
- t.setProps(a), E.setShowLayerType(a.layerType), E.setGreenTileVisible(a.showGreenLayer);
1699
- const r = useTrackManager(y), f = useCarTrackManager(y, r), m = useShipManager(y), F = usePositionManager(y), V = useDrawLineManager(y, t), v = useDrawPolygonManager(y, t), g = usePortManager(o);
1700
- useEventManager(o, t, r, m, g, V);
1701
- const T = () => {
1702
- const C = y.getView().calculateExtent(o.getSize()), Z = transform([C[0], C[1]], projection.mercator, projection.data), Y = transform([C[2], C[3]], projection.mercator, projection.data);
1703
- return [Z[0], Z[1], Y[0], Y[1]];
1704
- }, p = {
1701
+ o.initMap(n, a);
1702
+ const m = o.getInstall(), L = useLayerManager(m), t = usePropsManager();
1703
+ t.setProps(a), L.setShowLayerType(a.layerType), L.setGreenTileVisible(a.showGreenLayer);
1704
+ const r = useTrackManager(m), w = useCarTrackManager(m, r), v = useShipManager(m), P = usePositionManager(m), O = useDrawLineManager(m, t), f = useDrawPolygonManager(m, t), y = usePortManager(o);
1705
+ useEventManager(o, t, r, v, y, O);
1706
+ const F = () => {
1707
+ const T = m.getView().calculateExtent(o.getSize()), G = transform([T[0], T[1]], projection.mercator, projection.data), q = transform([T[2], T[3]], projection.mercator, projection.data);
1708
+ return [G[0], G[1], q[0], q[1]];
1709
+ }, E = {
1705
1710
  id: Symbol("map-instance"),
1706
1711
  innerMap: null,
1707
1712
  map: o.getInstall(),
1708
1713
  destroy: () => {
1709
- e.splice(e.indexOf(p), 1);
1714
+ e.splice(e.indexOf(E), 1);
1710
1715
  },
1711
1716
  methods: {
1712
1717
  ...o,
1713
- layer: E,
1714
- ship: m,
1718
+ layer: L,
1719
+ ship: v,
1715
1720
  track: r,
1716
- carTrack: f,
1721
+ carTrack: w,
1717
1722
  port: {
1718
- render: g.render,
1719
- clear: g.clear,
1720
- selected: g.selected
1723
+ render: y.render,
1724
+ clear: y.clear,
1725
+ selected: y.selected
1721
1726
  },
1722
- position: F,
1723
- drawLine: V,
1724
- drawPolygon: v,
1727
+ position: P,
1728
+ drawLine: O,
1729
+ drawPolygon: f,
1725
1730
  // 子模块
1726
1731
  utils: {
1727
- getCalculateExtent: T,
1732
+ getCalculateExtent: F,
1728
1733
  convertSixHundredThousandToLatLng,
1729
1734
  calculateCirclePoints
1730
1735
  }
1731
1736
  }
1732
1737
  };
1733
- return e.push(p), p;
1738
+ return e.push(E), E;
1734
1739
  },
1735
- destroyInstance: (s) => {
1736
- const a = e.findIndex((o) => o.id === s);
1740
+ destroyInstance: (n) => {
1741
+ const a = e.findIndex((o) => o.id === n);
1737
1742
  a > -1 && (e[a].destroy(), e.splice(a, 1));
1738
1743
  },
1739
1744
  destroyAll: () => {
1740
- e.forEach((s) => s.destroy()), e.splice(0, e.length);
1745
+ e.forEach((n) => n.destroy()), e.splice(0, e.length);
1741
1746
  },
1742
1747
  getAllInstances: () => [...e]
1743
1748
  };
@@ -1760,18 +1765,18 @@ const getShipDirectPath = (e) => {
1760
1765
  selectPort: { type: Function, default: () => {
1761
1766
  } }
1762
1767
  },
1763
- setup(e, { expose: n }) {
1764
- const l = ref(), s = ref(), a = useMapController(), o = ref(), y = e, E = ref({
1768
+ setup(e, { expose: s }) {
1769
+ const l = ref(), n = ref(), a = useMapController(), o = ref(), m = e, L = ref({
1765
1770
  getInstall() {
1766
1771
  }
1767
1772
  });
1768
1773
  return onMounted(() => {
1769
1774
  var t;
1770
- o.value = a.createInstance(l.value, y), console.log(" instance.value?.methods", o.value.map), E.value = o.value.methods, (t = s.value) == null || t.setScaleLine(o.value.map, y.scaleLineUnit);
1775
+ o.value = a.createInstance(l.value, m), console.log(" instance.value?.methods", o.value.map), L.value = o.value.methods, (t = n.value) == null || t.setScaleLine(o.value.map, m.scaleLineUnit);
1771
1776
  }), onUnmounted(() => {
1772
1777
  var t, r;
1773
1778
  a.destroyInstance((t = o == null ? void 0 : o.value) == null ? void 0 : t.id), (r = o.value) == null || r.destroy();
1774
- }), n({
1779
+ }), s({
1775
1780
  getZoom: () => {
1776
1781
  var t;
1777
1782
  return (t = o.value) == null ? void 0 : t.methods.getZoom();
@@ -1789,16 +1794,16 @@ const getShipDirectPath = (e) => {
1789
1794
  return (t = o.value) == null ? void 0 : t.methods.getView();
1790
1795
  },
1791
1796
  setCenter: (t, r) => {
1792
- var f;
1793
- return (f = o.value) == null ? void 0 : f.methods.setCenter(t, r);
1797
+ var w;
1798
+ return (w = o.value) == null ? void 0 : w.methods.setCenter(t, r);
1794
1799
  },
1795
1800
  getSize: () => {
1796
1801
  var t;
1797
1802
  return (t = o.value) == null ? void 0 : t.methods.getSize();
1798
1803
  },
1799
1804
  getCenter: (t, r) => {
1800
- var f;
1801
- return (f = o.value) == null ? void 0 : f.methods.getCenter();
1805
+ var w;
1806
+ return (w = o.value) == null ? void 0 : w.methods.getCenter();
1802
1807
  },
1803
1808
  layer: {
1804
1809
  setGreenTileVisible: (t) => {
@@ -1883,9 +1888,9 @@ const getShipDirectPath = (e) => {
1883
1888
  var r;
1884
1889
  return (r = o.value) == null ? void 0 : r.methods.carTrack.setCenter(...t);
1885
1890
  },
1886
- closeTrack: (...t) => {
1887
- var r;
1888
- return (r = o.value) == null ? void 0 : r.methods.carTrack.closeTrack(...t);
1891
+ closeTrack: () => {
1892
+ var t;
1893
+ return (t = o.value) == null ? void 0 : t.methods.carTrack.closeTrack();
1889
1894
  },
1890
1895
  playTrack: (...t) => {
1891
1896
  var r;
@@ -1962,17 +1967,17 @@ const getShipDirectPath = (e) => {
1962
1967
  },
1963
1968
  // 子模块
1964
1969
  utils: {
1965
- getCalculateExtent: () => {
1966
- var t;
1967
- return (t = o.value) == null ? void 0 : t.methods.utils.getCalculateExtent();
1970
+ getCalculateExtent: (...t) => {
1971
+ var r;
1972
+ return (r = o.value) == null ? void 0 : r.methods.utils.getCalculateExtent(...t);
1968
1973
  },
1969
- convertSixHundredThousandToLatLng: () => {
1970
- var t;
1971
- return (t = o.value) == null ? void 0 : t.methods.utils.convertSixHundredThousandToLatLng();
1974
+ convertSixHundredThousandToLatLng: (...t) => {
1975
+ var r;
1976
+ return (r = o.value) == null ? void 0 : r.methods.utils.convertSixHundredThousandToLatLng(...t);
1972
1977
  },
1973
- calculateCirclePoints: () => {
1974
- var t;
1975
- return (t = o.value) == null ? void 0 : t.methods.utils.calculateCirclePoints();
1978
+ calculateCirclePoints: (t, r) => {
1979
+ var w;
1980
+ return (w = o.value) == null ? void 0 : w.methods.utils.calculateCirclePoints(t, r);
1976
1981
  }
1977
1982
  }
1978
1983
  }), (t, r) => (openBlock(), createElementBlock("div", _hoisted_1, [
@@ -1984,7 +1989,7 @@ const getShipDirectPath = (e) => {
1984
1989
  }, null, 512),
1985
1990
  createVNode(ScaleLine, {
1986
1991
  ref_key: "scaleLineRef",
1987
- ref: s
1992
+ ref: n
1988
1993
  }, null, 512),
1989
1994
  createVNode(ZoomControl, {
1990
1995
  ref: "zoomControlRef",
@@ -1992,7 +1997,7 @@ const getShipDirectPath = (e) => {
1992
1997
  }, null, 8, ["map-instance"])
1993
1998
  ]));
1994
1999
  }
1995
- }), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-9b3c0151"]]), ZhMap = withInstall(Map$1);
2000
+ }), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-117d7b5a"]]), ZhMap = withInstall(Map$1);
1996
2001
  export {
1997
2002
  ZhMap as Z
1998
2003
  };