zhihao-ui 1.3.23 → 1.3.25

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.
@@ -0,0 +1,2135 @@
1
+ import { defineComponent, openBlock, createElementBlock, createElementVNode, ref, computed, h, createVNode, render, reactive, onMounted, onUnmounted } from "vue";
2
+ import { S as ScaleLine$1, M as Map$2, T as TileLayer, X as XYZ, p as fromLonLat, V as View, q as defaults, t as toLonLat, h as hooks, r as getLength, s as transformExtent, u as Text, F as Fill, v as Style, O as Overlay, P as Point, w as transform, x as debounce, L as LineString, y as buffer, z as Polyline, A as Feature, B as VectorLayer, C as VectorSource, D as Stroke, i as cloneDeep, G as CircleStyle, H as getVectorContext, I as Icon, J as VectorImageLayer, K as Circle, N as DoubleClickZoom, Q as Draw, R as unByKey, U as getUid, W as getArea, Y as getCenter, Z as MultiPoint } from "./vendor-D2mv9LHk.js";
3
+ import { _ as _export_sfc } from "./Button-CGndQwez.js";
4
+ import { w as withInstall } from "./utils-D2wHR1YB.js";
5
+ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
6
+ __name: "scaleLine",
7
+ setup(e, { expose: i }) {
8
+ return i({
9
+ setScaleLine: (l, a) => {
10
+ a || (a = "metric");
11
+ const o = new ScaleLine$1({
12
+ units: a
13
+ }), f = document.getElementById("scale-line-container");
14
+ f && (o.setTarget(f), l.addControl(o));
15
+ }
16
+ }), (l, a) => (openBlock(), createElementBlock("div", _hoisted_1$2));
17
+ }
18
+ }), ScaleLine = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2bc5dee8"]]), _hoisted_1$1 = { class: "zoom" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
19
+ __name: "zoomControl",
20
+ props: {
21
+ mapInstance: {
22
+ type: Object,
23
+ default: () => null
24
+ }
25
+ },
26
+ setup(e) {
27
+ const i = e;
28
+ console.log("props", i);
29
+ const n = () => {
30
+ console.log("props");
31
+ const { setZoom: a, getZoom: o, getInstall: f } = i.mapInstance.methods;
32
+ if (!f()) return;
33
+ const t = o();
34
+ t && a(t + 1);
35
+ }, l = () => {
36
+ const { setZoom: a, getZoom: o, getInstall: f } = i.mapInstance.methods;
37
+ if (!f()) return;
38
+ const t = o();
39
+ t && a(t - 1);
40
+ };
41
+ return (a, o) => (openBlock(), createElementBlock("div", _hoisted_1$1, [
42
+ createElementVNode("div", {
43
+ class: "button big-button",
44
+ onClick: n
45
+ }, " + "),
46
+ createElementVNode("div", {
47
+ class: "button small-button",
48
+ onClick: l
49
+ }, " - ")
50
+ ]));
51
+ }
52
+ }), ZoomControl = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-c39c3075"]]), TIAN_DI_TU_KEY = "a6e8f78974f2581f2ca00485b40c948f", MAP_ZOOM = {
53
+ // 地图默认层级
54
+ default: 13,
55
+ // 地图缩放最小层级
56
+ min: 3,
57
+ // 地图缩放最大层级
58
+ max: 18,
59
+ // 船形图标最小渲染层级
60
+ shipModelMin: 13,
61
+ // 船形图标最小渲染层级
62
+ shipTriggleMin: 16,
63
+ // 船形图标最大渲染层级
64
+ shipModelMax: 18,
65
+ //根据原系统canvas图片转换svg长宽比例计算缩放值
66
+ scaleNum: 0.555
67
+ }, projection = {
68
+ // 经纬度 源数据 地理坐标 WGS84
69
+ data: "EPSG:4326",
70
+ // 墨卡托投影坐标 渲染坐标
71
+ mercator: "EPSG:3857"
72
+ }, MAP_DEFAULT_CENTER = [114.84, 30.52], CDN_URL = "https://static.zhihaoscm.cn/", equatorialCircumference = 2003750834e-2;
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
+ function useMapInitializer() {
75
+ const e = ref(), i = () => e.value, n = () => i().getView(), l = () => {
76
+ var m;
77
+ return (m = n()) == null ? void 0 : m.getZoom();
78
+ }, a = (m) => {
79
+ var F;
80
+ (F = n()) == null || F.setZoom(m);
81
+ }, o = (m, F) => {
82
+ var O;
83
+ (O = n()) == null || O.setCenter(fromLonLat([m, F]));
84
+ }, f = () => {
85
+ var F;
86
+ const m = (F = n()) == null ? void 0 : F.getCenter();
87
+ return toLonLat(m);
88
+ }, p = () => {
89
+ var m;
90
+ return (m = i()) == null ? void 0 : m.getSize();
91
+ }, t = new Map$2(), r = (m, F) => {
92
+ L(F);
93
+ const O = {
94
+ zoom: F.zoom,
95
+ center: fromLonLat(F.center),
96
+ minZoom: MAP_ZOOM.min,
97
+ maxZoom: MAP_ZOOM.max,
98
+ constrainResolution: !0,
99
+ enableRotation: !1,
100
+ multiWorld: !0
101
+ }, v = new Map$2({
102
+ target: m,
103
+ controls: defaults({
104
+ zoom: !1
105
+ }),
106
+ layers: [
107
+ t.get("vectorTile"),
108
+ t.get("vectorTileMark"),
109
+ t.get("satelliteImgTile"),
110
+ t.get("satelliteImgTileMark")
111
+ ],
112
+ view: new View(O)
113
+ });
114
+ e.value = v;
115
+ }, L = (m) => {
116
+ t.set("vectorTile", new TileLayer({
117
+ source: new XYZ({ url: BASE_MAP_LINK.vectorTile }),
118
+ visible: m.layerType === "vector",
119
+ zIndex: 0,
120
+ preload: 1,
121
+ className: "vector"
122
+ })), t.set("vectorTileMark", new TileLayer({
123
+ source: new XYZ({ url: BASE_MAP_LINK.vectorTileMark }),
124
+ visible: m.layerType === "vector",
125
+ zIndex: 1,
126
+ preload: 1,
127
+ className: "vector"
128
+ })), t.set("satelliteImgTile", new TileLayer({
129
+ source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTile }),
130
+ visible: m.layerType === "satellite",
131
+ zIndex: 0,
132
+ preload: 1,
133
+ className: "satellite"
134
+ })), t.set("satelliteImgTileMark", new TileLayer({
135
+ source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTileMark }),
136
+ visible: m.layerType === "satellite",
137
+ zIndex: 1,
138
+ preload: 1,
139
+ className: "satellite"
140
+ })), t.set("greenMark", new TileLayer({
141
+ source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
142
+ visible: m.showGreenLayer,
143
+ zIndex: 2,
144
+ className: "greenTile"
145
+ }));
146
+ };
147
+ return {
148
+ getInstall: i,
149
+ getView: n,
150
+ getZoom: l,
151
+ setZoom: a,
152
+ setCenter: o,
153
+ getCenter: f,
154
+ getSize: p,
155
+ initMap: r,
156
+ setBaseLayerMap: L
157
+ };
158
+ }
159
+ const convertSixHundredThousandToLatLng = function(e, i) {
160
+ const n = Number(i) / 6e5;
161
+ return [Number(e) / 6e5, n];
162
+ }, calculateCirclePoints = (e, i) => {
163
+ const n = fromLonLat(e), l = i * 1e3, a = [
164
+ n[0] - l,
165
+ n[1] - l,
166
+ n[0] + l,
167
+ n[1] + l
168
+ ], o = transformExtent(a, projection.mercator, projection.data);
169
+ return {
170
+ leftTopPoint: { lng: o[0], lat: o[3] },
171
+ rightTopPoint: { lng: o[2], lat: o[3] },
172
+ rightBottomPoint: { lng: o[2], lat: o[1] },
173
+ leftBottomPoint: { lng: o[0], lat: o[1] }
174
+ };
175
+ }, formatLength = function(e, i) {
176
+ const l = getLength(e);
177
+ let a = "";
178
+ switch (console.log(i, LENGTH_UNIT), i) {
179
+ case LENGTH_UNIT.M:
180
+ a = Math.round(l * 100) / 100 + " m";
181
+ break;
182
+ case LENGTH_UNIT.KM:
183
+ a = Math.round(l / 1e3 * 100) / 100 + " km";
184
+ break;
185
+ case LENGTH_UNIT.NM:
186
+ a = (Math.round(l / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
187
+ break;
188
+ }
189
+ return a;
190
+ };
191
+ function lonLatToMercator(e) {
192
+ const i = e[0] * equatorialCircumference / 180;
193
+ let n = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
194
+ return n = n * equatorialCircumference / 180, [i, n];
195
+ }
196
+ function getIconFont(unicode = "") {
197
+ return unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), unicode.indexOf("&amp") !== -1 && (unicode = unicode.replace("&amp", "&")), eval('("' + unicode.replace("&#x", "\\u").replace(";", "") + '")');
198
+ }
199
+ const getIconStyle = (e) => {
200
+ const i = new Text({
201
+ font: "Normal 14px map-iconfont",
202
+ text: getIconFont(e),
203
+ fill: new Fill({ color: "#fff" }),
204
+ offsetY: -14
205
+ });
206
+ return new Style({
207
+ text: i,
208
+ zIndex: 100
209
+ });
210
+ }, mercatorToLonLat = (e, i = "lonlat") => {
211
+ const n = { lon: 0, lat: 0 }, l = e[0] / equatorialCircumference * 180;
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), n.lon = l, n.lat = a, i === "lonlat" ? n : [l, a];
214
+ }, formatMinutesToDDHHMM = (e) => {
215
+ const i = hooks.duration(e, "minutes"), n = Math.floor(i.asDays()), l = i.hours(), a = i.minutes();
216
+ let o = `${String(a).padStart(2, "0")}分`;
217
+ return l !== 0 && (o = `${String(l).padStart(2, "0")}时${o}`), n !== 0 && (o = `${String(n).padStart(2, "0")}天${o}`), o;
218
+ }, useCarTrackManager = (e, i) => {
219
+ let n = null;
220
+ const l = async (L) => {
221
+ if (!e || (console.log("vehicleInfo", L), !(L != null && L.lon && (L != null && L.lat)))) return;
222
+ const m = Math.abs(Number(L.lon)) > 180 ? convertSixHundredThousandToLatLng(L.lon, L.lat) : [L.lon, L.lat];
223
+ a(L, fromLonLat(m));
224
+ const F = e == null ? void 0 : e.getView(), O = new Point(m);
225
+ F.setCenter(transform(O.getCoordinates(), projection.data, projection.mercator));
226
+ }, a = (L, m) => {
227
+ const F = `${CDN_URL}map/car-icon.gif`;
228
+ n || (n = new Overlay({
229
+ element: document.createElement("div"),
230
+ positioning: "center-center",
231
+ stopEvent: !1
232
+ // 允许交互事件穿透
233
+ }), e.addOverlay(n));
234
+ const O = n.getElement();
235
+ O.style.backgroundImage = `url(${F})`, O.style.width = "80px", O.style.height = "80px";
236
+ const v = (L == null ? void 0 : L.drc) || "";
237
+ O.style.transform = `rotate(${v}deg)`, O.style.backgroundSize = "cover", n == null || n.setPosition(m);
238
+ };
239
+ return {
240
+ location: l,
241
+ remove: () => {
242
+ const L = n == null ? void 0 : n.getElement();
243
+ L && (L.innerHTML = "");
244
+ },
245
+ renderTrack: (L, m, F) => {
246
+ i.render(L, m, F, "truck", 1e3);
247
+ },
248
+ setCenter: (L) => {
249
+ i.setCenter(L);
250
+ },
251
+ closeTrack: () => {
252
+ i.close();
253
+ },
254
+ playTrack: (L, m) => {
255
+ i.play(L, m);
256
+ }
257
+ };
258
+ };
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
+ const useTrackManager = (e) => {
261
+ const i = /* @__PURE__ */ new Map(), n = {};
262
+ let l = null;
263
+ const a = "--";
264
+ let o = null;
265
+ const f = document.createElement("div"), p = new Overlay({
266
+ element: f,
267
+ positioning: "top-left",
268
+ stopEvent: !1,
269
+ className: "track-label-popup"
270
+ });
271
+ let t, r, L, m, F, O = !1, v = Date.now(), w, C = 0, k = null, x = 20, Z = !1;
272
+ const B = 5, Y = [], j = (s) => {
273
+ var d;
274
+ for (Y.unshift(s); Y.length > B; ) {
275
+ const g = Y.pop(), M = i.get(g);
276
+ M && ((d = M.getSource()) == null || d.clear(), e == null || e.removeLayer(M), i.delete(g), delete n[g]);
277
+ }
278
+ };
279
+ let D = "";
280
+ const z = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], c = debounce(() => {
281
+ if (l && n[l] && i.get(l).getVisible() && Z) {
282
+ console.log("reRenderTrackLine------------");
283
+ const s = cloneDeep(u(l, n[l]));
284
+ le(l, s);
285
+ }
286
+ }, 300), u = (s, d) => {
287
+ let g = [];
288
+ const M = Math.max(1, Math.floor(d.length / x));
289
+ return g = d.filter((S, R) => R % M === 0).map((S, R) => {
290
+ if (Number(S.lon) > 180 || Number(S.lat) > 180) {
291
+ const [V, G] = convertSixHundredThousandToLatLng(S.lon, S.lat);
292
+ S.lon = V, S.lat = G;
293
+ }
294
+ return S.center = [S.lon, S.lat], S.centerPoint = lonLatToMercator(S.center), S.time = hooks(S.createdAt).format("YYYY-MM-DD HH:mm:ss"), S.id = s, S.index = R, S;
295
+ }), g;
296
+ }, y = async (s, d, g, M = "ship", E = 200) => {
297
+ if (console.log("renderTrackLine--------", s, d, g), !e || JSON.stringify(n[s]) === JSON.stringify(d) && l === s || (d = d == null ? void 0 : d.reverse(), p && M === "ship" && (e != null && e.getOverlays().getArray().includes(p) || e.addOverlay(p)), (d == null ? void 0 : d.length) < 2))
298
+ return;
299
+ j(s), l = s, n[s] = d, x = E;
300
+ const S = Object.keys(n).findIndex((R) => R === s) || 0;
301
+ D = g || z[S > 10 ? 10 : S], Z = !0, await N(), await ae(l);
302
+ }, T = (s) => {
303
+ const d = new VectorSource();
304
+ return new VectorLayer({
305
+ source: d,
306
+ visible: !1,
307
+ // 默认隐藏
308
+ className: `track-layer-${s}`,
309
+ renderBuffer: 1024
310
+ // 增大渲染缓冲区
311
+ });
312
+ }, b = (s) => {
313
+ i.forEach((d, g) => {
314
+ var E;
315
+ const M = g === s;
316
+ d.getVisible() !== M && (d.setVisible(M), e.getLayers().getArray().includes(d) || e.addLayer(d), M || (E = d.getSource()) == null || E.clear());
317
+ }), l = s;
318
+ }, N = async () => {
319
+ const s = l;
320
+ if (!i.has(s)) {
321
+ const S = T(s);
322
+ i.set(s, S);
323
+ }
324
+ await b(s);
325
+ const d = D || "", g = n[s] || [];
326
+ if (!(g && g.length > 1)) return [];
327
+ let M = [];
328
+ M = u(s, g);
329
+ const E = M.map((S) => S.centerPoint);
330
+ M.length >= 2 && await $(s, E, d);
331
+ }, $ = (s, d, g) => {
332
+ const M = new LineString(d), E = i.get(s).getSource(), S = E.getFeatureById(s);
333
+ if (S)
334
+ S.setGeometry(M), S.setId(s), S.setStyle(A(g)), k = S;
335
+ else {
336
+ const R = new Feature({ geometry: M });
337
+ R.setId(s), R.set("type", "line"), R.setStyle(A(g)), E.addFeature(R), k = R;
338
+ }
339
+ return k;
340
+ }, A = (s) => new Style({
341
+ stroke: new Stroke({
342
+ color: s,
343
+ width: 2
344
+ })
345
+ }), _ = (s, d, g) => {
346
+ const M = s == null ? void 0 : s.get("trackId");
347
+ if (s && M && d === "hover") {
348
+ e.getTargetElement().style.cursor = M ? "pointer" : "";
349
+ const E = s.get("data"), S = J(E), R = g == null ? void 0 : g.coordinate;
350
+ R && (f.querySelector(".popup-content"), f.innerHTML = S, p == null || p.setPosition(R));
351
+ } else
352
+ p && p.setPosition(void 0);
353
+ }, J = (s) => {
354
+ if (!(s != null && s.time)) return;
355
+ let d = "";
356
+ return s != null && s.stayTime && (d = `
357
+ <div class="item w-100">
358
+ <div class="item-label">停泊时间约</div>
359
+ <div class="item-item">${formatMinutesToDDHHMM(Number(s.stayTime))}</div>
360
+ </div>
361
+ `), `
362
+ <div class="track-point-popup">
363
+ <div class="item">
364
+ <div class="item-label">状态</div>
365
+ <div class="item-item">${s != null && s.sailStatus ? SHIP_SAIL_STATUS[s.sailStatus] : a}</div>
366
+ </div>
367
+ <div class="item">
368
+ <div class="item-label">航速</div>
369
+ <div class="item-item">${s.speed || a}</div>
370
+ </div>
371
+ <div class="item">
372
+ <div class="item-label">艏向</div>
373
+ <div class="item-item">${s.hdg || a}</div>
374
+ </div>
375
+ <div class="item">
376
+ <div class="item-label">航向</div>
377
+ <div class="item-item">${s.cog || a}</div>
378
+ </div>
379
+ <div class="item">
380
+ <div class="item-label">经度</div>
381
+ <div class="item-item">${s.lon || a}</div>
382
+ </div>
383
+ <div class="item">
384
+ <div class="item-label">纬度</div>
385
+ <div class="item-item">${s.lat || a}</div>
386
+ </div>
387
+ <div class="item w-100">
388
+ <div class="item-label">时间</div>
389
+ <div class="item-item">${s.time}</div>
390
+ </div>
391
+ ${d ?? d}
392
+ </div>`;
393
+ }, Q = (s) => {
394
+ const g = s.map((V) => {
395
+ const G = e.getPixelFromCoordinate(fromLonLat(V.center));
396
+ return {
397
+ ...V,
398
+ original: V,
399
+ pixel: G,
400
+ distance: 0
401
+ // 先初始化,后续计算
402
+ };
403
+ });
404
+ let M = 0;
405
+ g[0].distance = 0;
406
+ for (let V = 1; V < g.length; V++) {
407
+ const G = g[V - 1].pixel, W = g[V].pixel, q = W[0] - G[0], P = W[1] - G[1];
408
+ M += Math.sqrt(q * q + P * P), g[V].distance = M;
409
+ }
410
+ const E = g.filter(
411
+ (V, G) => G === 0 || G === g.length - 1
412
+ ), S = [];
413
+ for (let V = 0; V < E.length; V++) {
414
+ const G = E[V];
415
+ if (S.push(G), V < E.length - 1) {
416
+ const W = E[V + 1], q = W.distance - G.distance, P = Math.floor(q / 100);
417
+ for (let H = 1; H <= P; H++) {
418
+ const X = G.distance + H * 100;
419
+ if (X >= W.distance) break;
420
+ const K = U(
421
+ g,
422
+ X
423
+ );
424
+ K && S.push(K);
425
+ }
426
+ }
427
+ }
428
+ return Array.from(
429
+ new Map(S.map((V) => [V.distance.toFixed(2), V])).values()
430
+ ).map((V) => ({
431
+ ...V.original,
432
+ // 优先保留原始数据
433
+ ...V,
434
+ // 覆盖坐标等计算属性
435
+ coord: V.coord,
436
+ // 确保使用插值后的坐标
437
+ pixel: V.pixel,
438
+ distance: V.distance
439
+ }));
440
+ };
441
+ function U(s, d) {
442
+ for (let g = 1; g < s.length; g++) {
443
+ const M = s[g - 1], E = s[g];
444
+ if (d >= M.distance && d <= E.distance) {
445
+ const S = (d - M.distance) / (E.distance - M.distance), R = M.pixel[0] + S * (E.pixel[0] - M.pixel[0]), V = M.pixel[1] + S * (E.pixel[1] - M.pixel[1]), G = e == null ? void 0 : e.getCoordinateFromPixel([R, V]);
446
+ return {
447
+ ...M,
448
+ // 继承前一个点的属性(可调整)
449
+ coord: G,
450
+ pixel: [R, V],
451
+ distance: d,
452
+ original: void 0
453
+ // 明确标记为插值生成点
454
+ };
455
+ }
456
+ }
457
+ return null;
458
+ }
459
+ const le = async (s, d) => {
460
+ await ce(), await ge(s);
461
+ const g = Q(d), M = g.map((S) => I(S));
462
+ i.get(s).getSource().addFeatures(M), he(s, g, d, D), g.forEach((S) => {
463
+ const R = ee(s, D, S);
464
+ e.addOverlay(R);
465
+ });
466
+ }, I = (s) => {
467
+ const d = new Feature({
468
+ geometry: new Point(s.centerPoint),
469
+ data: s
470
+ });
471
+ d.set("type", "track_point"), d.set("trackId", s.id), d.set("data", s);
472
+ let g = [
473
+ ...fe(s, D)
474
+ ];
475
+ return (s.index === 0 || s.index === n[s.id].length - 1) && (g = [...ve(s)], d.set("type", "track_begin")), s.state !== void 0 && s.state !== null && (g = [...ye(s)], d.set("type", "track_icon")), d.setStyle(g), d;
476
+ }, ee = (s, d, g) => {
477
+ const M = document.createElement("div");
478
+ M.className = "track-overlay-label", M.style.position = "relative", M.style.backgroundColor = "rgba(255,255,255,0.8)", M.style.border = `1px solid ${d}`, M.style.fontSize = "12px", M.innerHTML = `
479
+ <span>${g.time}</span>
480
+ <svg
481
+ style="position: absolute;left: -20px;top: 0;"
482
+ viewBox="0 0 20 20"
483
+ xmlns="http://www.w3.org/2000/svg"
484
+ width="20"
485
+ height="20">
486
+ <line x1="0" y1="20"
487
+ x2="20" y2="0"
488
+ stroke="${d}"
489
+ stroke-width="1" />
490
+ `;
491
+ const E = new Overlay({
492
+ element: M,
493
+ position: fromLonLat(g.center),
494
+ positioning: "top-left",
495
+ offset: [20, -20],
496
+ stopEvent: !1,
497
+ className: "track-label-time-overlay"
498
+ });
499
+ return E.set("class", "track-label-overlay"), E.set("trackId", s), E;
500
+ }, ce = () => {
501
+ const s = e == null ? void 0 : e.getOverlays().getArray(), d = s == null ? void 0 : s.filter((g) => g.get("class") === "track-label-overlay");
502
+ d && d.length > 0 && d.forEach((g) => {
503
+ g.setPosition(void 0), g.dispose();
504
+ });
505
+ }, ge = (s) => {
506
+ const d = i.get(s).getSource();
507
+ d.forEachFeature((g) => {
508
+ g.get("type") !== "line" && d.removeFeature(g);
509
+ });
510
+ }, fe = (s, d) => (`${s.time}`, [
511
+ new Style({
512
+ // 扩大交互热区
513
+ image: new CircleStyle({
514
+ stroke: new Stroke({ color: "rgba(0, 0, 0, 0.01)", width: 20 }),
515
+ radius: 3
516
+ })
517
+ }),
518
+ // 轨迹点样式
519
+ new Style({
520
+ image: new CircleStyle({
521
+ fill: new Fill({ color: d }),
522
+ stroke: new Stroke({ color: "#fff", width: 2 }),
523
+ radius: 3
524
+ })
525
+ })
526
+ // textStyle,
527
+ ]), ye = (s) => {
528
+ const d = "#E31818", g = "#1890FF", M = "&#xe6d2", E = new Style({
529
+ text: new Text({
530
+ font: "Normal 22px map-iconfont",
531
+ text: getIconFont(M),
532
+ offsetY: -10,
533
+ fill: new Fill({
534
+ color: Number(s.state) === 0 ? d : Number(s.state) === 1 ? g : ""
535
+ })
536
+ }),
537
+ zIndex: 99
538
+ }), R = getIconStyle("&#xe6e2;"), G = getIconStyle("&#xe703;"), W = [];
539
+ return Number(s.state) === 0 ? W.push(R) : Number(s.state) === 1 && W.push(G), W.push(E), W;
540
+ }, he = (s, d, g, M) => {
541
+ const E = d || [], S = d.length;
542
+ S || (E.push(g[0]), E.push(g[g.length - 1]));
543
+ const R = [];
544
+ for (let G = 0; G < S - 1; G++) {
545
+ let W;
546
+ const q = d[G], P = (d[G + 1].index + q.index) / 2;
547
+ if (P % 2 === 0)
548
+ W = g[P].centerPoint;
549
+ else {
550
+ const H = g[Math.floor(P)], X = g[Math.ceil(P)];
551
+ if (H && X) {
552
+ const [K, oe] = H.centerPoint, [re, ne] = X.centerPoint;
553
+ W = [(K + re) / 2, (oe + ne) / 2];
554
+ }
555
+ }
556
+ if (W) {
557
+ const H = new Feature({
558
+ geometry: new Point(W)
559
+ });
560
+ H.set("type", "track_arrow"), H.setStyle(
561
+ new Style({
562
+ text: new Text({
563
+ font: "700 12px map-iconfont",
564
+ text: getIconFont("&#xe6bc;"),
565
+ fill: new Fill({ color: M }),
566
+ // 设置箭头旋转 角度转为弧度
567
+ rotation: de(
568
+ d[G].center,
569
+ d[G + 1].center
570
+ ) * (Math.PI / 180)
571
+ })
572
+ })
573
+ ), R.push(H);
574
+ }
575
+ }
576
+ const V = i.get(s).getSource();
577
+ V == null || V.addFeatures(R);
578
+ }, ae = (s) => {
579
+ var S, R;
580
+ const d = e.getView(), g = (S = i == null ? void 0 : i.get(s)) == null ? void 0 : S.getSource(), M = k || (s ? g == null ? void 0 : g.getFeatureById(s) : null);
581
+ if (!M) return;
582
+ const E = (R = M == null ? void 0 : M.getGeometry()) == null ? void 0 : R.getExtent();
583
+ if (E != null && E.length)
584
+ try {
585
+ const V = buffer(E, Math.max(E[2] - E[0], E[3] - E[1]) * 0.02);
586
+ d.fit(V);
587
+ } catch (V) {
588
+ console.log(V);
589
+ }
590
+ }, ve = (s) => {
591
+ const d = "&#xe69b;", E = s.index === 0 ? "#fcdc3f" : "#ff0000";
592
+ return [new Style({
593
+ text: new Text({
594
+ font: "Normal 14px map-iconfont",
595
+ text: getIconFont(d),
596
+ fill: new Fill({ color: E })
597
+ }),
598
+ zIndex: 101
599
+ })];
600
+ }, me = () => {
601
+ console.log("清除所有的轨迹-----"), te(), i.forEach((d) => {
602
+ var g;
603
+ (g = d.getSource()) == null || g.clear(), e == null || e.removeLayer(d);
604
+ }), Object.keys(n).forEach((d) => {
605
+ i.delete(d), delete n[d];
606
+ }), Z = !1, ce();
607
+ }, we = (s) => {
608
+ const d = i.get(s || l);
609
+ d == null || d.setVisible(!1);
610
+ const g = e.getOverlays().getArray();
611
+ for (let M = 0; M < g.length; ) {
612
+ const E = g[M];
613
+ E.get("class") === "track-label-overlay" ? (E.setPosition(void 0), e.removeOverlay(E)) : M++;
614
+ }
615
+ te();
616
+ }, Le = (s, d = LENGTH_UNIT.NM) => {
617
+ const g = {
618
+ id: s,
619
+ length: "--"
620
+ }, E = (n[s] || []).map(
621
+ (R) => transform([R.lon, R.lat], projection.data, projection.mercator)
622
+ ), S = new LineString(E);
623
+ return g.length = formatLength(S, d) || "--", g;
624
+ }, xe = (s, d) => {
625
+ pe(String(s), d);
626
+ }, pe = (s, d) => {
627
+ const g = n[String(s)], M = g == null ? void 0 : g.map((E) => [E.lon, E.lat]);
628
+ M && ke(M, d);
629
+ }, ie = new Style({
630
+ text: new Text({
631
+ font: "700 20px map-iconfont",
632
+ text: getIconFont("&#xe657;"),
633
+ fill: new Fill({ color: "#ff0000" }),
634
+ rotation: 0
635
+ // 初始旋转角度
636
+ })
637
+ }), be = (s, d) => {
638
+ var P, H;
639
+ const g = Number(50 * d), M = ((P = s.frameState) == null ? void 0 : P.time) ?? Date.now(), E = M - v;
640
+ if (C = (C + g * E / 1e6) % 2, v = M, C >= 1) {
641
+ te();
642
+ return;
643
+ }
644
+ const S = r.getCoordinateAt(
645
+ C > 1 ? 2 - C : C
646
+ ), R = r.getCoordinateAt(
647
+ C > 1 ? C - 0.01 : C
648
+ ), V = r.getCoordinateAt(
649
+ C > 1 ? 2 - C : C + 0.01
650
+ ), W = de(
651
+ mercatorToLonLat(R, "array"),
652
+ mercatorToLonLat(V, "array")
653
+ ) * Math.PI / 180;
654
+ (H = ie.getText()) == null || H.setRotation(W), m.setCoordinates(S);
655
+ const q = getVectorContext(s);
656
+ q.setStyle(ie), q.drawGeometry(m), e == null || e.render();
657
+ }, Me = () => {
658
+ var s;
659
+ O = !0, v = Date.now(), C = 0, m = ((s = L.getGeometry()) == null ? void 0 : s.clone()) || new Point([0, 0]), o && (w == null || w.on("postrender", o)), F == null || F.setGeometry(void 0);
660
+ }, te = () => {
661
+ O && (O = !1, F == null || F.setGeometry(void 0), o && w && w.un("postrender", o), w && (e == null || e.removeLayer(w)), w = null, F = null);
662
+ }, ke = (s, d) => {
663
+ O && te(), t = new Polyline({
664
+ factor: 1e6
665
+ }).writeGeometry(new LineString(s)), r = new Polyline({
666
+ factor: 1e6
667
+ }).readGeometry(t, {
668
+ dataProjection: projection.data,
669
+ featureProjection: projection.mercator
670
+ }), L = new Feature({
671
+ type: "icon",
672
+ geometry: new Point(r.getFirstCoordinate())
673
+ });
674
+ const g = L.getGeometry();
675
+ m = g ? g.clone() : new Point([0, 0]), F = new Feature({
676
+ type: "geoMarker",
677
+ style: ie,
678
+ geometry: m
679
+ }), w = new VectorLayer({
680
+ source: new VectorSource({
681
+ features: [F]
682
+ })
683
+ }), e == null || e.addLayer(w), o = (M) => be(M, d), Me();
684
+ }, de = (s, d, g) => {
685
+ function M(P) {
686
+ return 180 * (P % (2 * Math.PI)) / Math.PI;
687
+ }
688
+ function E(P) {
689
+ return P % 360 * Math.PI / 180;
690
+ }
691
+ function S(P) {
692
+ var H;
693
+ if (!P) throw new Error("Coordinate is required");
694
+ if (!Array.isArray(P)) {
695
+ if ((P == null ? void 0 : P.type) === "Feature" && (P == null ? void 0 : P.geometry) !== null && ((H = P == null ? void 0 : P.geometry) == null ? void 0 : H.type) === "Point")
696
+ return P == null ? void 0 : P.geometry.coordinates;
697
+ if (P.type === "Point") return (P == null ? void 0 : P.coordinates) || [];
698
+ }
699
+ if (Array.isArray(P) && P.length >= 2 && !Array.isArray(P[0]) && !Array.isArray(P[1]))
700
+ return P;
701
+ throw new Error(
702
+ "Coordinate must be GeoJSON Point or an Array of numbers"
703
+ );
704
+ }
705
+ function R(P, H, X = {}) {
706
+ if (X.final)
707
+ return function(Te, Se) {
708
+ return (R(Se, Te) + 180) % 360;
709
+ }(P, H);
710
+ const K = S(P), oe = S(H), re = E(K[0]), ne = E(oe[0]), ue = E(K[1]), se = E(oe[1]), Ce = Math.sin(ne - re) * Math.cos(se), Ee = Math.cos(ue) * Math.sin(se) - Math.sin(ue) * Math.cos(se) * Math.cos(ne - re);
711
+ return M(Math.atan2(Ce, Ee));
712
+ }
713
+ function V(P) {
714
+ return !isNaN(P) && P !== null && !Array.isArray(P);
715
+ }
716
+ function G(P, H = {}, X = {}) {
717
+ return P || console.log("Coordinates are required"), Array.isArray(P) || console.log("Coordinates must be an Array"), P.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!V(P[0]) || !V(P[1])) && console.log("Coordinates must contain numbers"), W({ type: "Point", coordinates: P }, H, X);
718
+ }
719
+ function W(P, H = {}, X = {}) {
720
+ const K = {
721
+ type: "Feature",
722
+ id: "",
723
+ properties: {},
724
+ bbox: {},
725
+ geometry: {}
726
+ };
727
+ return X.id !== void 0 && (K.id = X.id), X.bbox && (K.bbox = X.bbox), K.properties = H, K.geometry = P, K;
728
+ }
729
+ const q = R(G(s), G(d), g);
730
+ return q < 0 ? 360 + q : q;
731
+ };
732
+ return {
733
+ render: y,
734
+ remove: me,
735
+ play: xe,
736
+ setCenter: ae,
737
+ close: we,
738
+ getLength: Le,
739
+ handleTrackMapEvent: _,
740
+ reRenderTrackLine: c
741
+ };
742
+ };
743
+ function useShipOverlay(e) {
744
+ console.log("useShipOverlay", e);
745
+ const i = ref(null), n = computed(() => ({
746
+ "--overlay-color": "#FFF",
747
+ "--bg-color1": e.colors && e.colors[0] ? e.colors[0] : "#ffffff",
748
+ // 默认第一个颜色
749
+ "--bg-color2": e.colors && e.colors[1] ? e.colors[1] : "#ffffff",
750
+ "--bg-color": "#ffffff",
751
+ position: "relative",
752
+ "pointer-events": "none"
753
+ })), l = computed(() => {
754
+ var f;
755
+ return {
756
+ position: "relative",
757
+ "border-radius": "1px",
758
+ "background-color": "var(--content-bg)",
759
+ color: "#000",
760
+ padding: "2px 5px 2px 0px",
761
+ font: "500 Normal 12px",
762
+ "font-size": "12px",
763
+ "box-shadow": "0 2px 10px rgba(0, 0, 0, 0.2)",
764
+ "white-space": "nowrap",
765
+ border: "1px solid #FFF",
766
+ "pointer-events": "auto",
767
+ // 'transition': 'background-color 0.5s ease, border 0.5s ease',
768
+ "z-index": "1",
769
+ display: "flex",
770
+ "align-items": "center",
771
+ animation: e.selected ? e.colors && ((f = e.colors) == null ? void 0 : f.length) >= 2 ? "blink-dual 2s ease-in-out infinite" : "blink-single 1.5s ease-in-out infinite" : "none"
772
+ // "animation": props.selected ? 'blink 1.5s ease-in-out infinite' : 'none', // 动画开关
773
+ };
774
+ }), a = computed(() => ({
775
+ width: "14px",
776
+ height: "14px",
777
+ margin: "1px 5px 1px 1px",
778
+ "background-color": "var(--attention-bg)"
779
+ })), o = computed(() => ({
780
+ position: "absolute",
781
+ top: "0px",
782
+ color: "var(--overlay-color)",
783
+ "pointer-events": "none",
784
+ transform: "translateY(-1px)",
785
+ "z-index": "0",
786
+ width: "20px",
787
+ height: "20px",
788
+ overflow: "visible",
789
+ left: "-20px"
790
+ }));
791
+ return () => h("div", {
792
+ ref: i,
793
+ class: "ship-overlay-container",
794
+ style: n.value
795
+ }, [
796
+ h(
797
+ "div",
798
+ {
799
+ class: "ship-overlay-content",
800
+ style: l.value
801
+ },
802
+ [
803
+ h("div", {
804
+ style: e.selected ? a.value : {}
805
+ }, ""),
806
+ h("div", {
807
+ class: "text",
808
+ style: {
809
+ fontSize: "12px",
810
+ fontWeight: 500,
811
+ fontFamily: "Arial"
812
+ }
813
+ }, e.name || "未命名船舶"),
814
+ h("div", {
815
+ class: "icons",
816
+ style: {
817
+ color: "#3370ff"
818
+ }
819
+ }, [
820
+ e.existDevice ? h("i", {
821
+ class: "map-iconfont icon-camera",
822
+ style: {
823
+ fontSize: "12px"
824
+ }
825
+ }) : "",
826
+ e.existMobile ? h("i", {
827
+ class: "map-iconfont icon-tele",
828
+ style: {
829
+ fontSize: "12px"
830
+ }
831
+ }) : "",
832
+ e.existWaterGauge ? h("i", {
833
+ class: "map-iconfont icon-ruler",
834
+ style: {
835
+ fontSize: "12px"
836
+ }
837
+ }) : ""
838
+ ])
839
+ ]
840
+ ),
841
+ h("svg", {
842
+ class: "ship-overlay-line",
843
+ style: o.value,
844
+ viewBox: "0 0 20 20",
845
+ xmlns: "http://www.w3.org/2000/svg"
846
+ }, [
847
+ h("line", {
848
+ x1: "0",
849
+ y1: "20",
850
+ x2: "20",
851
+ y2: "4",
852
+ stroke: "white",
853
+ "stroke-width": "1"
854
+ })
855
+ ])
856
+ ]);
857
+ }
858
+ ref([]);
859
+ function addOverlay(e, i, n, l) {
860
+ if (i) {
861
+ const a = new Overlay({
862
+ element: n,
863
+ positioning: "top-left",
864
+ id: "label-" + (l == null ? void 0 : l.id),
865
+ offset: [20, -20],
866
+ autoPan: !1,
867
+ position: i,
868
+ className: l.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
869
+ });
870
+ a.set("class", "zh-map-ship-overlay"), e.addOverlay(a);
871
+ }
872
+ }
873
+ const getShipDirectPath = (e) => {
874
+ const { spd: i, hdg: n, cog: l } = e;
875
+ return i ? n !== null && +n != 511 && l !== null ? l - +n >= 3 ? SHIP_DIRECT.right : l - +n <= -3 ? SHIP_DIRECT.left : SHIP_DIRECT.front : SHIP_DIRECT.front : "";
876
+ }, createShipStyle = (e, i) => {
877
+ const { shipData: n } = i.getProperties(), l = getShipType(e), a = getShipScale(e, n, l);
878
+ return initShipStyle(i, a, l);
879
+ }, getShipType = (e) => {
880
+ const i = e == null ? void 0 : e.getView().getZoom();
881
+ return i <= MAP_ZOOM.shipModelMax && i >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
882
+ }, getShipScale = (e, i, n) => {
883
+ if (n === "ship") {
884
+ const { len: l, wid: a } = i, o = 97, f = 20, t = 1 / (e == null ? void 0 : e.getView().getResolution()), r = l * t / o, L = a * t / f, m = Math.min(r, L);
885
+ return m < 0.2 ? 0.2 : m > 2 ? 2 : m;
886
+ }
887
+ return MAP_ZOOM.scaleNum;
888
+ }, initShipStyle = (e, i, n) => {
889
+ const { color: l, direct: a, isHighlight: o, shipData: f } = e.getProperties(), p = ((f == null ? void 0 : f.cog) - 90 + 360) % 360;
890
+ return new Style({
891
+ image: new Icon({
892
+ src: t(),
893
+ scale: i || MAP_ZOOM.scaleNum,
894
+ anchor: [0.5, 0.5],
895
+ rotation: p * Math.PI / 180,
896
+ rotateWithView: !1
897
+ })
898
+ });
899
+ function t() {
900
+ return `data:image/svg+xml;utf8,${encodeURIComponent(r())}`;
901
+ }
902
+ function r() {
903
+ switch (n) {
904
+ case "triangle":
905
+ return `<svg width="41" height="24" viewBox="0 0 41 24" fill="none" xmlns="http://www.w3.org/2000/svg">
906
+ <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"
907
+ fill="${l}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "2" : "0.578947"}" />
908
+ <!--path船航向左边或者向前-->
909
+ ${a === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${o ? "#FF2424" : "black"}" stroke-width="2"/>`}
910
+ <!--path船航向右边-->
911
+ ${a === SHIP_DIRECT.right && `<path d="M30 12L40 12L40 16" stroke="${o ? "#FF2424" : "black"}" stroke-width="2"/>`}
912
+ <!--path黑线无左右-->
913
+ ${a === SHIP_DIRECT.front && `<path d="M30 12L40 12" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
914
+ </svg>
915
+ `;
916
+ case "ship":
917
+ return `<svg width="97" height="20" viewBox="0 0 97 20" fill="none" xmlns="http://www.w3.org/2000/svg">
918
+ <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"
919
+ fill="${l}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "4" : "0.578947"}"/>
920
+ ${a === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
921
+ ${a === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
922
+ ${a === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
923
+ </svg>
924
+ `;
925
+ default:
926
+ return "";
927
+ }
928
+ }
929
+ }, selectedShipStyle = (e, i) => {
930
+ const n = selectedShipElement(e, i), l = i.id, { lon: a, lat: o } = i, f = new Overlay({
931
+ element: n,
932
+ position: fromLonLat([a, o]),
933
+ id: "selected-" + l,
934
+ positioning: "center-center",
935
+ offset: [0, 5],
936
+ className: "ship-selected-overlay"
937
+ });
938
+ return f.set("class", "ship-overlay-selected"), f;
939
+ }, selectedShipElement = (e, i) => {
940
+ const n = getShipType(e), l = getShipScale(e, i, n), a = n === "ship" ? 109 : 49, o = `
941
+ <svg style="transform:scale(${l});" xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 49 49" fill="none">
942
+ <path d="M1.99982 46.9998L1.99982 1.99982L46.9998 1.99982L46.9998 46.9998L1.99982 46.9998Z" fill="#FF2424" fill-opacity="0.2"/>
943
+ <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"/>
944
+ </svg>
945
+ `, f = document.createElement("div");
946
+ return f.className = "ship-overlay-selected", f.innerHTML = o, f;
947
+ }, createLabelStyle = (e, i) => {
948
+ const { lon: n, lat: l, blinking: a } = i, o = createLabelElement(i);
949
+ n && l && addOverlay(e, fromLonLat([n, l]), o, { ...i, blinking: a });
950
+ }, createLabelElement = (e) => {
951
+ const i = document.createElement("div");
952
+ i.className = "ship-overlay-box", i.style.position = "relative";
953
+ const { lon: n, lat: l, blinking: a, blinkingColors: o, name: f } = e, p = createVNode({
954
+ setup() {
955
+ return useShipOverlay({
956
+ position: [n + 2e-3, l + 2e-3],
957
+ selected: a,
958
+ name: f,
959
+ colors: o || [],
960
+ existDevice: e == null ? void 0 : e.existDevice,
961
+ existMobile: e == null ? void 0 : e.existMobile,
962
+ existWaterGauge: e == null ? void 0 : e.existWaterGauge
963
+ });
964
+ }
965
+ });
966
+ return render(p, i), i;
967
+ }, getRightIcons = (e) => {
968
+ const i = [];
969
+ return e.existDevice && i.push("&#xe687;"), e.existMobile && i.push("&#xe688;"), e.existWaterGauge && i.push("&#xe686;"), i;
970
+ };
971
+ function getRandomLineDirection() {
972
+ const e = [
973
+ "left-top",
974
+ "left-middle",
975
+ "left-bottom",
976
+ "right-top",
977
+ "right-middle",
978
+ "right-bottom"
979
+ ];
980
+ return e[Math.floor(Math.random() * e.length)];
981
+ }
982
+ const devicePixelRatio = window.devicePixelRatio || 1;
983
+ function generateBase64Icon(e, i, n = "left-bottom", l = 2) {
984
+ const a = document.createElement("canvas"), o = a.getContext("2d");
985
+ if (!o) return "";
986
+ const f = 2, p = 8, t = 16, r = window.devicePixelRatio || 1, L = "500 12px Arial", m = "14px map-iconfont";
987
+ o.font = L;
988
+ const O = o.measureText(e).width;
989
+ o.font = m;
990
+ const v = i.map((b) => ({ width: o.measureText(getIconFont(b)).width, height: 14 })), w = v.reduce((b, N) => b + N.width, 0), C = (i.length - 1) * l, k = p + O + w + C + p, x = f + 14 + f * 2;
991
+ let Z, B, Y = 0, j = 0, D = 0, z = 0, c = 0, u = 0;
992
+ switch (Z = t + k, n) {
993
+ case "right-top":
994
+ B = t + x, Y = 0, j = t + x, D = t, z = 0, c = t, u = 0;
995
+ break;
996
+ case "right-middle":
997
+ B = x, Y = 0, j = x / 2, D = t, z = x / 2, c = t, u = 0;
998
+ break;
999
+ case "right-bottom":
1000
+ B = t + x, Y = 0, j = 0, D = t, z = t, c = t, u = t;
1001
+ break;
1002
+ case "left-top":
1003
+ B = t + x, Y = k, j = t, D = k + t, z = x + t, c = 0, u = 0;
1004
+ break;
1005
+ case "left-middle":
1006
+ B = x, Y = k, j = x / 2, D = k + t, z = x / 2, c = 0, u = 0;
1007
+ break;
1008
+ case "left-bottom":
1009
+ B = t + x, Y = k, j = x, D = k + t, z = 0, c = 0, u = t;
1010
+ break;
1011
+ }
1012
+ a.width = Math.round(Z * r), a.height = Math.round(B * r), o.scale(r, r), o.clearRect(0, 0, Z, B), o.beginPath(), o.moveTo(Y, j), o.lineTo(D, z), o.strokeStyle = "#FFF", o.lineWidth = 1, o.stroke(), o.fillStyle = "#FFF", o.fillRect(c, u, k, x), o.font = L, o.textBaseline = "middle";
1013
+ const y = u + f + x / 2;
1014
+ o.strokeStyle = "#ffffff", o.lineWidth = 1, o.strokeText(e, c + p, y), o.fillStyle = "#000000", o.fillText(e, c + p, y), o.font = m, o.fillStyle = "#3370ff";
1015
+ let T = c + p + O + l;
1016
+ return i.length > 0 && i.forEach((b, N) => {
1017
+ const $ = u + f + x / 2;
1018
+ o.fillText(getIconFont(b), T, $), T += v[N].width + l;
1019
+ }), a.toDataURL("image/png");
1020
+ }
1021
+ const createLabelFeatureStyle = (e) => {
1022
+ const { name: i, rightIcons: n, selected: l } = e.getProperties(), a = getRandomLineDirection(), o = generateBase64Icon(i, n, a);
1023
+ let f = [0, 0];
1024
+ switch (a) {
1025
+ case "right-top":
1026
+ f = [0, 1];
1027
+ break;
1028
+ case "right-middle":
1029
+ f = [0, 0.5];
1030
+ break;
1031
+ case "right-bottom":
1032
+ f = [0, 0];
1033
+ break;
1034
+ case "left-top":
1035
+ f = [1, 1];
1036
+ break;
1037
+ case "left-middle":
1038
+ f = [1, 0.5];
1039
+ break;
1040
+ case "left-bottom":
1041
+ f = [1, 0];
1042
+ break;
1043
+ }
1044
+ return new Style({
1045
+ image: new Icon({
1046
+ src: o,
1047
+ anchor: f,
1048
+ displacement: [0, 0],
1049
+ scale: 1 / devicePixelRatio,
1050
+ anchorXUnits: "fraction",
1051
+ anchorYUnits: "fraction"
1052
+ }),
1053
+ zIndex: l ? 100 : 10
1054
+ });
1055
+ }, useShipManager = (e) => {
1056
+ let i = null, n = null;
1057
+ const l = new VectorSource(), a = new VectorImageLayer({
1058
+ source: l,
1059
+ className: "zh-map--ship-layer",
1060
+ renderBuffer: 300,
1061
+ zIndex: 101
1062
+ }), o = new VectorSource(), f = new VectorLayer({
1063
+ source: o,
1064
+ className: "zh-map--ship-label-layer",
1065
+ zIndex: 102,
1066
+ updateWhileInteracting: !1,
1067
+ updateWhileAnimating: !1,
1068
+ declutter: !0
1069
+ });
1070
+ e == null || e.addLayer(a), e == null || e.addLayer(f);
1071
+ let p = null, t = "", r = {}, L = {};
1072
+ const m = (c) => {
1073
+ if (!c || !e) return;
1074
+ const u = (n == null ? void 0 : n.id) || (i == null ? void 0 : i.get("id"));
1075
+ if (n) {
1076
+ const y = c.filter((T) => T.id === u);
1077
+ y.length === 0 ? c.push(n) : n = y[0];
1078
+ }
1079
+ w(), C(!0), z(c), O();
1080
+ }, F = (c) => {
1081
+ var _;
1082
+ const u = (n == null ? void 0 : n.id) || (i == null ? void 0 : i.get("id")), y = fromLonLat([c == null ? void 0 : c.lon, c == null ? void 0 : c.lat]), T = ((_ = L[c.id]) == null ? void 0 : _.blinkColors) || [], N = T[T.length - 1] || c.fill || "#04C900", $ = getShipDirectPath(c), A = new Feature({
1083
+ geometry: new Point(y),
1084
+ // 船舶数据
1085
+ shipData: c,
1086
+ id: c.id,
1087
+ name: c.cnname || c.enname || c.id || "未命名船舶",
1088
+ selected: c.id === u,
1089
+ // 图标
1090
+ rightIcons: getRightIcons(c),
1091
+ // 是否闪烁
1092
+ // blinking: attentionShips[ship.id] || false,
1093
+ // // 闪烁颜色
1094
+ // blinkingColor: attentionShipsColor[ship.id].blinkColors || '',
1095
+ // 船舶颜色
1096
+ color: N,
1097
+ // 船艏向的方向
1098
+ direct: $,
1099
+ // 高亮
1100
+ isHighlight: !1
1101
+ });
1102
+ return A.set("clickGeometry", new Circle(y)), A;
1103
+ }, O = async () => {
1104
+ if (!n || !e) return;
1105
+ let u = e.getOverlays().getArray().find((y) => y.get("class") == "ship-overlay-selected");
1106
+ if (u) {
1107
+ const y = selectedShipElement(e, n);
1108
+ await u.setElement(y), await u.setPosition(fromLonLat([n.lon, n.lat]));
1109
+ } else
1110
+ u = selectedShipStyle(e, n), u && e.addOverlay(u);
1111
+ setTimeout(() => {
1112
+ var y;
1113
+ u && ((y = u.get("element")) != null && y.parentElement) && (u.get("element").parentElement.style.display = "block");
1114
+ }, 20);
1115
+ }, v = (c) => {
1116
+ if (c === "start") {
1117
+ const u = () => {
1118
+ l.getFeatures().forEach((b) => {
1119
+ b.setStyle(createShipStyle(e, b));
1120
+ });
1121
+ const T = (e == null ? void 0 : e.getOverlays().getArray()).find((b) => b.get("class") == "ship-overlay-selected");
1122
+ if (T) {
1123
+ const b = T.getElement(), N = getShipScale(e, n, "ship");
1124
+ console.log("scaleFactor", N), b.style.transform = `scale(${N})`;
1125
+ }
1126
+ p = requestAnimationFrame(u);
1127
+ };
1128
+ u();
1129
+ } else
1130
+ p && (cancelAnimationFrame(p), p = null);
1131
+ }, w = () => {
1132
+ e && l && (l.clear(), o.clear(), C());
1133
+ }, C = (c) => {
1134
+ const u = e.getOverlays().getArray().filter((y) => y.get("class") == "zh-map-ship-overlay");
1135
+ if (u && u.length > 0) {
1136
+ for (let y = 0; y < u.length; y++)
1137
+ if (!c && u[y].get("class") !== "ship-overlay-selected") {
1138
+ const T = u[y];
1139
+ T.setPosition(void 0), e.removeOverlay(T), T.dispose();
1140
+ }
1141
+ }
1142
+ }, k = (c, u) => {
1143
+ r = c, L = u, console.log("attentionShips", r, "attentionShipsColor", u);
1144
+ const y = e.getOverlays().getArray(), T = l.getFeatures();
1145
+ for (const b in r) {
1146
+ const N = r[b], $ = y.find((_) => _.getId() === "label-" + b), A = T.find((_) => b === _.get("id"));
1147
+ if ($ && A) {
1148
+ const _ = u[b].blinkColors || [], { shipData: J, name: Q, color: U } = A == null ? void 0 : A.getProperties();
1149
+ A.set("blinking", N), _[(_ == null ? void 0 : _.length) - 1] && U !== _[(_ == null ? void 0 : _.length) - 1] && (A.set("color", _[(_ == null ? void 0 : _.length) - 1] || ""), A.setStyle(createShipStyle(e, A)));
1150
+ const le = {
1151
+ ...J,
1152
+ blinking: N,
1153
+ blinkingColors: _ || [],
1154
+ name: Q + "(" + u[b].shipState + ")"
1155
+ }, I = $.getElement(), ee = createLabelElement(le);
1156
+ I && I !== ee && $.setElement(ee);
1157
+ }
1158
+ }
1159
+ }, x = (c) => {
1160
+ if (!e) return;
1161
+ const u = l.getFeatures(), y = o.getFeatures(), T = i ? i.get("id") : "", b = u.filter((_) => _.get("id") !== T), N = y == null ? void 0 : y.filter((_) => _.get("id") !== T), $ = /* @__PURE__ */ new Map();
1162
+ c.forEach((_) => {
1163
+ $.set(_.id, !0);
1164
+ });
1165
+ const A = e.getOverlays().getArray();
1166
+ b.forEach((_) => {
1167
+ const J = _.get("id");
1168
+ if (!$.has(J))
1169
+ _.setStyle([]);
1170
+ else {
1171
+ const U = _.getStyle();
1172
+ (U == null ? void 0 : U.length) == 0 && _.setStyle(createShipStyle(e, _));
1173
+ }
1174
+ const Q = A.find((U) => U.getId() === "label-" + J);
1175
+ Q && Q.setPosition(void 0);
1176
+ }), console.log(N), N.forEach((_) => {
1177
+ const J = _.get("id");
1178
+ if (!$.has(J))
1179
+ _.setStyle([]);
1180
+ else {
1181
+ const Q = _.getStyle();
1182
+ (Q == null ? void 0 : Q.length) == 0 && _.setStyle(createLabelFeatureStyle(_));
1183
+ }
1184
+ });
1185
+ }, Z = (c) => {
1186
+ if (c) {
1187
+ console.log("选中", c);
1188
+ const u = l.getFeatures().find((T) => T.get("id") === c.id), y = o.getFeatures().find((T) => T.get("id") === c.id);
1189
+ u && (i = u), y && y.set("selected", !0), n = c, O();
1190
+ } else
1191
+ console.log("取消选中"), n = null, i = null, j();
1192
+ }, B = debounce((c, u, y) => {
1193
+ if (c) {
1194
+ const T = c.get("shipData"), b = c.get("id");
1195
+ if (e.getTargetElement().style.cursor = b ? "pointer" : "", u === "click" && (Z(T), y && y(b)), u === "hover") {
1196
+ t && t !== b && Y(), t = b;
1197
+ const N = l.getFeatures().find(($) => $.get("id") === t);
1198
+ N == null || N.set("isHighlight", !0), N == null || N.setStyle(createShipStyle(e, N));
1199
+ }
1200
+ } else
1201
+ e.getTargetElement().style.cursor = "", Y();
1202
+ }, 10), Y = () => {
1203
+ const c = t ? l.getFeatures().find((u) => u.get("id") === t) : null;
1204
+ t = null, c == null || c.set("isHighlight", !1), c == null || c.setStyle(createShipStyle(e, c));
1205
+ }, j = () => {
1206
+ try {
1207
+ const u = e.getOverlays().getArray().find((y) => y.get("class") == "ship-overlay-selected");
1208
+ u && u.setPosition(void 0);
1209
+ } catch (c) {
1210
+ console.log(c);
1211
+ }
1212
+ }, D = (c) => {
1213
+ const u = fromLonLat([c == null ? void 0 : c.lon, c == null ? void 0 : c.lat]), y = new Feature({
1214
+ geometry: new Point(u),
1215
+ name: c.cnname || c.enname || c.id || "未命名船舶",
1216
+ // 图标
1217
+ rightIcons: getRightIcons(c),
1218
+ selected: (c == null ? void 0 : c.id) === (n == null ? void 0 : n.id),
1219
+ shipData: c
1220
+ });
1221
+ y.set("id", c.id);
1222
+ const T = createLabelFeatureStyle(y);
1223
+ return y.setStyle(T), y;
1224
+ }, z = (c) => {
1225
+ const u = e.getView().getZoom();
1226
+ c.forEach((y) => {
1227
+ const T = F(y);
1228
+ if (T.setStyle(createShipStyle(e, T)), l.addFeature(T), (n == null ? void 0 : n.id) == y.id || u >= MAP_ZOOM.shipModelMin)
1229
+ if (r[y.id]) {
1230
+ if (y.id && L[y == null ? void 0 : y.id]) {
1231
+ const b = L[y == null ? void 0 : y.id] || {}, N = (b == null ? void 0 : b.blinkColors) || [], $ = (b == null ? void 0 : b.shipState) || "", A = (y.cnname || y.enname || y.id || "未命名船舶") + "(" + $ + ")", _ = {
1232
+ ...y,
1233
+ name: A,
1234
+ blinking: r[y.id],
1235
+ blinkingColors: N || []
1236
+ };
1237
+ createLabelStyle(e, _);
1238
+ }
1239
+ } else {
1240
+ const b = D(y);
1241
+ o.addFeature(b);
1242
+ }
1243
+ });
1244
+ };
1245
+ return {
1246
+ render: m,
1247
+ selected: Z,
1248
+ filter: x,
1249
+ blinking: k,
1250
+ clear: w,
1251
+ handleShipMapEvent: B,
1252
+ changeShipScale: v
1253
+ };
1254
+ }, useLayerManager = (e) => {
1255
+ const i = () => e == null ? void 0 : e.getLayers(), n = ref("vector"), l = () => n.value, a = (t) => {
1256
+ n.value = t;
1257
+ const r = i();
1258
+ r && (r == null || r.getArray().forEach((L) => {
1259
+ (L.className_ === "vector" || L.className_ === "satellite") && L.setVisible(L.className_ === t);
1260
+ }));
1261
+ }, o = ref(!1);
1262
+ return {
1263
+ getLayers: i,
1264
+ getGreenTileVisible: () => o.value,
1265
+ setGreenTileVisible: (t) => {
1266
+ if (t !== o.value) {
1267
+ if (t) {
1268
+ const r = i();
1269
+ if (!r.getArray().find((m) => m.className_ === "greenTile")) {
1270
+ const m = new TileLayer({
1271
+ source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
1272
+ visible: t,
1273
+ zIndex: 2,
1274
+ className: "greenTile"
1275
+ });
1276
+ r.push(m);
1277
+ }
1278
+ } else {
1279
+ const r = i(), L = r.getArray().find((m) => m.className_ === "greenTile");
1280
+ L && r.remove(L);
1281
+ }
1282
+ o.value = t;
1283
+ }
1284
+ },
1285
+ getShowLayerType: l,
1286
+ setShowLayerType: a
1287
+ };
1288
+ }, usePropsManager = () => {
1289
+ const e = ref();
1290
+ return {
1291
+ setProps: (l) => {
1292
+ e.value = l;
1293
+ },
1294
+ getProps: () => e.value
1295
+ };
1296
+ }, usePositionManager = (e) => {
1297
+ const i = "zh-map-location-layer";
1298
+ let n, l, a = null, o = null;
1299
+ const f = (v) => {
1300
+ if (!(!v || v.length === 0)) {
1301
+ if (l || (l = new VectorSource()), l.clear(), o) {
1302
+ const w = v.find((C) => C.id === o.id);
1303
+ w ? o = w : v.push(o);
1304
+ }
1305
+ v.forEach((w) => {
1306
+ p(w);
1307
+ }), n || (n = new VectorLayer({
1308
+ className: i,
1309
+ source: l,
1310
+ zIndex: 100
1311
+ }), e == null || e.addLayer(n));
1312
+ }
1313
+ }, p = (v) => {
1314
+ const w = e == null ? void 0 : e.getView().getZoom(), [C, k] = v.latLon.split(","), x = new Feature({
1315
+ geometry: new Point(fromLonLat([Number(C), Number(k)]))
1316
+ });
1317
+ x.setStyle(t(v, w, v.id === (o == null ? void 0 : o.id))), x.set("loactionData", v), l.addFeature(x);
1318
+ }, t = (v, w, C) => {
1319
+ const k = {
1320
+ image: new Icon({
1321
+ src: C && v.selectedPath || v.defaultPath,
1322
+ scale: 0.5 * w / 10
1323
+ })
1324
+ };
1325
+ return v.name && (k.text = new Text({
1326
+ text: v.name,
1327
+ font: "12px sans-serif",
1328
+ fill: new Fill({
1329
+ color: "#000000"
1330
+ }),
1331
+ backgroundFill: new Fill({
1332
+ color: "#FFFFFF"
1333
+ }),
1334
+ offsetY: 30
1335
+ })), new Style(k);
1336
+ }, r = () => {
1337
+ if (a) {
1338
+ const v = a.get("loactionData").id;
1339
+ l.getFeatures().forEach((w) => {
1340
+ w.get("loactionData").id !== v && l.removeFeature(w);
1341
+ });
1342
+ } else
1343
+ l.clear();
1344
+ }, L = () => {
1345
+ var k;
1346
+ const v = a.get("loactionData"), w = (k = e == null ? void 0 : e.getView()) == null ? void 0 : k.getZoom();
1347
+ l.getFeatures().forEach((x) => {
1348
+ x.get("loactionData").id === v.id && (x == null || x.setStyle(t(v, w, !1)));
1349
+ }), o = null, a = null;
1350
+ }, m = (v) => {
1351
+ v ? (F(), O(v)) : clearSelectedPort();
1352
+ }, F = () => {
1353
+ var v;
1354
+ if (a) {
1355
+ const w = a.get("loactionData"), C = (v = e == null ? void 0 : e.getView()) == null ? void 0 : v.getZoom();
1356
+ a.setStyle(t(w, C, !1));
1357
+ }
1358
+ }, O = (v) => {
1359
+ const w = l.getFeatures();
1360
+ o = v, a = w.find((C) => C.get("loactionData").id === v.id);
1361
+ };
1362
+ return {
1363
+ render: f,
1364
+ selected: m,
1365
+ clearSelected: L,
1366
+ clear: r
1367
+ };
1368
+ }, disableDoubleClickZoom = (e) => {
1369
+ e.getInteractions().forEach((i) => {
1370
+ i instanceof DoubleClickZoom && i.setActive(!1);
1371
+ });
1372
+ }, enableDoubleClickZoom = (e) => {
1373
+ e.getInteractions().forEach((i) => {
1374
+ i instanceof DoubleClickZoom && i.setActive(!0);
1375
+ });
1376
+ }, changeCursor = (e, i) => {
1377
+ const n = e.getViewport();
1378
+ n && (n.style.cursor = i);
1379
+ }, useDrawLineManager = (e, i) => {
1380
+ const n = ref([]), l = ref("km"), a = (c) => {
1381
+ l.value = c;
1382
+ };
1383
+ let o;
1384
+ const f = ref(!1), p = () => {
1385
+ changeCursor(e, "crosshair"), L(), disableDoubleClickZoom(e), e.on("pointermove", O), e.getViewport().addEventListener("mouseout", () => {
1386
+ o && o.classList.add("hidden");
1387
+ }), w(), f.value = !0;
1388
+ };
1389
+ let t, r;
1390
+ const L = () => {
1391
+ t = new VectorSource(), r = new VectorLayer({
1392
+ source: t,
1393
+ zIndex: 1e3,
1394
+ style: {
1395
+ "fill-color": "rgba(255, 255, 255, 0.2)",
1396
+ "stroke-color": "#ffcc33",
1397
+ "stroke-width": 2,
1398
+ "circle-radius": 7,
1399
+ "circle-fill-color": "#ffcc33"
1400
+ }
1401
+ }), e == null || e.addLayer(r);
1402
+ };
1403
+ let m, F;
1404
+ const O = (c) => {
1405
+ if (c.dragging)
1406
+ return;
1407
+ let u = "点击选择起点";
1408
+ m && (u = "单击继续,双击结束"), o && (o.innerHTML = u, F.setPosition(c.coordinate), o.classList.remove("hidden"));
1409
+ };
1410
+ let v;
1411
+ const w = () => {
1412
+ v = new Draw({
1413
+ source: t,
1414
+ type: "LineString",
1415
+ style: new Style({
1416
+ fill: new Fill({
1417
+ color: "rgba(255, 255, 255, 0.2)"
1418
+ }),
1419
+ stroke: new Stroke({
1420
+ color: "rgba(255,204,51)",
1421
+ lineDash: [10, 10],
1422
+ width: 2
1423
+ }),
1424
+ image: new CircleStyle({
1425
+ radius: 5,
1426
+ stroke: new Stroke({
1427
+ color: "rgba(0, 0, 0, 0.7)"
1428
+ }),
1429
+ fill: new Fill({
1430
+ color: "rgba(255, 255, 255, 0.2)"
1431
+ })
1432
+ })
1433
+ }),
1434
+ // 添加条件函数,判断是否应该出发点绘制
1435
+ condition: (u) => u.originalEvent.target.tagName !== "DIV"
1436
+ }), e == null || e.addInteraction(v), Z(), B();
1437
+ let c;
1438
+ v.on("drawstart", function(u) {
1439
+ var T;
1440
+ m = u.feature, m.set("randomId", C());
1441
+ let y;
1442
+ c = (T = m.getGeometry()) == null ? void 0 : T.on("change", function(b) {
1443
+ const N = b.target, $ = computedDistance(N, l.value);
1444
+ y = N.getLastCoordinate(), k && $ && (k.innerHTML = $), x.setPosition(y);
1445
+ });
1446
+ }), v.on("drawend", function() {
1447
+ var u, y, T;
1448
+ if (k && (k.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), k != null && k.innerHTML) {
1449
+ const b = (m == null ? void 0 : m.get("randomId")) || C();
1450
+ n.value.push({ id: b, value: k == null ? void 0 : k.innerHTML }), k.innerHTML = `${k.innerHTML}<div class="ol-tooltip-delete-button" data-id="${b}"><i class="map-iconfont icon-delete"></i></div>`;
1451
+ }
1452
+ (u = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || u.addEventListener("click", (b) => {
1453
+ var $;
1454
+ b.preventDefault(), b.stopPropagation();
1455
+ const N = ($ = b.target) == null ? void 0 : $.getAttribute("data-id");
1456
+ N && j(N);
1457
+ }), x.setOffset([0, -7]), m = null, k = null, Z(), c && unByKey(c), (T = (y = i.getProps()) == null ? void 0 : y.lineDrawEnd) == null || T.call(y, n.value);
1458
+ });
1459
+ }, C = () => Math.random().toString(36).substring(2, 9);
1460
+ let k, x;
1461
+ const Z = () => {
1462
+ k != null && k.parentNode && k.parentNode.removeChild(k), k = document.createElement("div"), k.className = "ol-tooltip ol-tooltip-measure", x = new Overlay({
1463
+ element: k,
1464
+ offset: [0, -15],
1465
+ positioning: "bottom-center",
1466
+ stopEvent: !1,
1467
+ insertFirst: !1
1468
+ }), e == null || e.addOverlay(x);
1469
+ }, B = () => {
1470
+ o != null && o.parentNode && o.parentNode.removeChild(o), o = document.createElement("div"), o.className = "ol-tooltip hidden", F = new Overlay({
1471
+ element: o,
1472
+ offset: [15, 0],
1473
+ positioning: "center-left"
1474
+ }), e == null || e.addOverlay(F);
1475
+ }, Y = () => {
1476
+ n.value.forEach((c, u) => {
1477
+ var b, N;
1478
+ const y = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1479
+ y[u] && ((N = (b = y[u]) == null ? void 0 : b.parentNode) == null || N.removeChild(y[u]));
1480
+ const T = t.getFeatures();
1481
+ T[u] && t.removeFeature(T[u]);
1482
+ }), D(), enableDoubleClickZoom(e), f.value = !1, changeCursor(e, "pointer");
1483
+ }, j = (c) => {
1484
+ var y, T, b, N;
1485
+ const u = n.value.findIndex(($) => $.id === c);
1486
+ if (u !== -1) {
1487
+ n.value.splice(u, 1);
1488
+ const $ = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
1489
+ $[u] && ((T = (y = $[u]) == null ? void 0 : y.parentNode) == null || T.removeChild($[u]));
1490
+ const A = t.getFeatures();
1491
+ A[u] && t.removeFeature(A[u]);
1492
+ }
1493
+ (N = (b = i.getProps()) == null ? void 0 : b.lineDrawEnd) == null || N.call(b, n.value);
1494
+ }, D = () => {
1495
+ if (n.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((c) => {
1496
+ var u;
1497
+ (u = c == null ? void 0 : c.parentNode) == null || u.removeChild(c);
1498
+ }), t.clear(), v) {
1499
+ const c = e.getInteractions().getArray().find((u) => getUid(u) === getUid(v));
1500
+ c && e.removeInteraction(c);
1501
+ }
1502
+ e.removeLayer(r), o != null && o.parentNode && o.parentNode.removeChild(o), k != null && k.parentNode && k.parentNode.removeChild(k);
1503
+ };
1504
+ return {
1505
+ open: p,
1506
+ close: Y,
1507
+ deleteLine: j,
1508
+ setUnit: a,
1509
+ getState: () => f.value
1510
+ };
1511
+ }, computedDistance = (e, i) => {
1512
+ const l = getLength(e);
1513
+ let a = "";
1514
+ switch (i) {
1515
+ case "m":
1516
+ a = `${Math.round(l * 100) / 100} m`;
1517
+ break;
1518
+ case "km":
1519
+ a = `${Math.round(l / 1e3 * 100) / 100} km`;
1520
+ break;
1521
+ case "nm":
1522
+ a = (Math.round(l / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
1523
+ break;
1524
+ }
1525
+ return a;
1526
+ }, useDrawPolygonManager = (e, i) => {
1527
+ let n, l;
1528
+ const a = () => {
1529
+ o(), changeCursor(e, "crosshair");
1530
+ }, o = () => {
1531
+ t(), k(), B(), O();
1532
+ };
1533
+ let f = null, p = null;
1534
+ const t = () => {
1535
+ if (f && p) return;
1536
+ const D = new VectorSource(), z = new VectorLayer({
1537
+ source: D,
1538
+ style: new Style({
1539
+ stroke: new Stroke({
1540
+ color: "#fbcc33",
1541
+ width: 2
1542
+ })
1543
+ })
1544
+ });
1545
+ f = z, p = D, e.on("pointermove", L), e.addLayer(z), e.on(["dblclick"], function(c) {
1546
+ m && (c.stopPropagation(), c.preventDefault());
1547
+ });
1548
+ };
1549
+ let r;
1550
+ const L = (D) => {
1551
+ if (D.dragging) return;
1552
+ const z = r ? "单击继续,双击结束" : "点击选择起点";
1553
+ x && (x.innerHTML = z, Z.setPosition(D.coordinate));
1554
+ };
1555
+ let m, F = !1;
1556
+ const O = () => {
1557
+ if (n) {
1558
+ x != null && x.parentNode && x.parentNode.removeChild(x);
1559
+ const D = n.getGeometry();
1560
+ if (!D) return;
1561
+ const z = v(D, "nm");
1562
+ w && (w.innerHTML = `
1563
+ <span class="text">面积:${z}${F ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
1564
+ `), w && (w.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
1565
+ const c = D.getCoordinates(), u = c[0][c[0].length - 2];
1566
+ if (C.setPosition(u), f) {
1567
+ const T = f.getSource();
1568
+ T && n && (T.clear(), T.addFeature(n));
1569
+ }
1570
+ setTimeout(() => {
1571
+ var T;
1572
+ (T = document.querySelector(".delete-icon")) == null || T.addEventListener("click", () => {
1573
+ var b, N;
1574
+ console.log("delete"), Y(), (N = (b = i.getProps()) == null ? void 0 : b.areaDrawEnd) == null || N.call(b, []);
1575
+ });
1576
+ }, 0);
1577
+ const y = getCenter(n.getGeometry().getExtent());
1578
+ e == null || e.getView().setCenter(y);
1579
+ return;
1580
+ }
1581
+ m = new Draw({
1582
+ type: "Polygon",
1583
+ source: p,
1584
+ trace: !0,
1585
+ style: [new Style({
1586
+ stroke: new Stroke({
1587
+ color: "rgba(255, 255, 255, 1)",
1588
+ width: 1.5,
1589
+ lineDash: [10, 10]
1590
+ }),
1591
+ fill: new Fill({
1592
+ color: "rgba(255, 255, 255, 0.25)"
1593
+ })
1594
+ }), new Style({
1595
+ image: new CircleStyle({
1596
+ radius: 5,
1597
+ fill: new Fill({
1598
+ color: "rgb(51,112,255, 1)"
1599
+ })
1600
+ }),
1601
+ geometry: function(D) {
1602
+ const z = D.getGeometry().getCoordinates();
1603
+ return new MultiPoint(z);
1604
+ }
1605
+ })]
1606
+ }), e == null || e.addInteraction(m), m.on("drawstart", (D) => {
1607
+ var z;
1608
+ r = D.feature, l = (z = r.getGeometry()) == null ? void 0 : z.on("change", (c) => {
1609
+ const u = c.target, y = v(u, "nm"), b = u.getCoordinates()[0], N = new LineString([b[b.length - 2], b[b.length - 1]]), $ = computedDistance(N, "nm");
1610
+ if (F = Number(getLength(N) / 1e3) > 150, !y) return;
1611
+ const A = '<span class="error pl-4">超出可以绘画的距离</span>';
1612
+ w && (w.innerHTML = `
1613
+ <div class="text">
1614
+ 面积:${y}
1615
+ ${F ? A : ""}
1616
+ </div>
1617
+ `), x && (x.innerHTML = `
1618
+ <div class="text">
1619
+ 面积:${y}
1620
+ </div>
1621
+ <div class="text ${F ? "error" : ""}">
1622
+ 线段 ${b.length - 2}: ${$}
1623
+ ${F ? A : ""}
1624
+
1625
+ </div>
1626
+ <div>
1627
+ <span class="text">单击继续,双击结束</span>
1628
+ </div>
1629
+ `);
1630
+ });
1631
+ }), m.on("drawend", (D) => {
1632
+ var y, T, b, N;
1633
+ if (!D.feature.getGeometry()) return;
1634
+ n = D.feature, w && (w.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), C.setOffset([10, 0]);
1635
+ const c = D.feature.getGeometry().getCoordinates(), u = c[0][c[0].length - 2];
1636
+ if (C.setPosition(u), x != null && x.parentNode && x.parentNode.removeChild(x), (y = i.getProps()) != null && y.areaDrawEnd) {
1637
+ const $ = c[0].map((A) => transform(A, projection.mercator, projection.data));
1638
+ (b = (T = i.getProps()) == null ? void 0 : T.areaDrawEnd) == null || b.call(T, $);
1639
+ }
1640
+ m && (m.setActive(!1), e == null || e.removeInteraction(m), (e == null ? void 0 : e.getInteractions()).forEach((A) => {
1641
+ A instanceof Draw && (A.setActive(!1), e == null || e.removeInteraction(A));
1642
+ })), l && unByKey(l), (N = document.querySelector(".delete-icon")) == null || N.addEventListener("click", () => {
1643
+ var $, A;
1644
+ Y(), (A = ($ = i.getProps()) == null ? void 0 : $.areaDrawEnd) == null || A.call($, []);
1645
+ });
1646
+ });
1647
+ }, v = (D, z) => {
1648
+ const c = getArea(D);
1649
+ switch (z) {
1650
+ case "km":
1651
+ return c > 1e4 ? Math.round(c / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(c * 100) / 100 + " m<sup>2</sup>";
1652
+ case "nm":
1653
+ return c > 1e4 ? Math.round(c / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(c * 100) / 100 + " m<sup>2</sup>";
1654
+ }
1655
+ };
1656
+ let w, C;
1657
+ const k = () => {
1658
+ w != null && w.parentNode && w.parentNode.removeChild(w), w = document.createElement("div"), w.style.display = "flex", w.className = "ol-tooltip ol-tooltip-draw-polygon", C = new Overlay({
1659
+ element: w,
1660
+ offset: [0, -15],
1661
+ positioning: "bottom-center",
1662
+ stopEvent: !1,
1663
+ insertFirst: !1
1664
+ }), e == null || e.addOverlay(C);
1665
+ };
1666
+ let x, Z;
1667
+ const B = () => {
1668
+ x != null && x.parentNode && x.parentNode.removeChild(x), x = document.createElement("div"), x.className = "ol-tooltip ol-help-tooltip", Z = new Overlay({
1669
+ element: x,
1670
+ offset: [15, 0],
1671
+ positioning: "center-left"
1672
+ }), e == null || e.addOverlay(Z);
1673
+ }, Y = () => {
1674
+ p == null || p.clear(), n = null, k(), B(), O();
1675
+ };
1676
+ return {
1677
+ open: a,
1678
+ close: () => {
1679
+ p == null || p.clear(), p = null, f && (e.removeLayer(f), f = null), r = null, m && (m.setActive(!1), (e == null ? void 0 : e.getInteractions()).forEach((z) => {
1680
+ z instanceof Draw && (z.setActive(!1), e == null || e.removeInteraction(z));
1681
+ }), m = null), l && unByKey(l), x != null && x.parentElement && x.parentElement.removeChild(x), w != null && w.parentElement && w.parentElement.removeChild(w), Z && e.removeOverlay(Z), C && e.removeOverlay(C), changeCursor(e, "pointer");
1682
+ },
1683
+ reset: Y
1684
+ };
1685
+ }, PORT_LAYER_CLASS_NAME = "zh-map-port-layer", usePortManager = (e) => {
1686
+ const i = e.getInstall();
1687
+ let n, l, a = null, o = null;
1688
+ const f = (v, w = !0) => {
1689
+ if (!(!v || v.length === 0)) {
1690
+ if (l || (l = new VectorSource()), l.clear(), o) {
1691
+ const C = v.find((k) => k.id === o.id);
1692
+ C ? o = C : v.push(o);
1693
+ }
1694
+ v.forEach((C) => {
1695
+ p(C, w);
1696
+ }), n || (n = new VectorLayer({
1697
+ className: PORT_LAYER_CLASS_NAME,
1698
+ source: l,
1699
+ zIndex: 100
1700
+ }), i.addLayer(n));
1701
+ }
1702
+ }, p = (v, w = !0) => {
1703
+ const C = e.getZoom(), [k, x] = v.latLon.split(","), Z = new Feature({
1704
+ geometry: new Point(fromLonLat([Number(k), Number(x)]))
1705
+ });
1706
+ Z.setStyle(t(v, C, v.id === (o == null ? void 0 : o.id), w)), Z.set("portData", v), l.addFeature(Z);
1707
+ }, t = (v, w, C, k = !0) => {
1708
+ const x = (B) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
1709
+ <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="${B}"/>
1710
+ <g clip-path="url(#clip0_10059_122082)">
1711
+ <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"/>
1712
+ </g>
1713
+ <defs>
1714
+ <clipPath id="clip0_10059_122082">
1715
+ <rect width="26" height="26" fill="white" transform="translate(10 8)"/>
1716
+ </clipPath>
1717
+ </defs>
1718
+ </svg>
1719
+ `, Z = () => `data:image/svg+xml;utf8,${encodeURIComponent(x(C ? "#FF5733" : "#3370FF"))}`;
1720
+ return !k && !C ? new Style({
1721
+ image: new Icon({
1722
+ src: Z(),
1723
+ scale: 0.5 * w / 10
1724
+ }),
1725
+ zIndex: C ? 110 : 100
1726
+ }) : (console.log("showTitle", v.shortName, C), new Style({
1727
+ text: new Text({
1728
+ text: v.shortName,
1729
+ font: "12px sans-serif",
1730
+ fill: new Fill({
1731
+ color: C ? "#ffffff" : "#000000"
1732
+ }),
1733
+ backgroundFill: new Fill({
1734
+ color: C ? "#FF5733" : "#FFFFFF"
1735
+ }),
1736
+ offsetY: 30
1737
+ }),
1738
+ image: new Icon({
1739
+ src: Z(),
1740
+ scale: 0.5 * w / 10
1741
+ }),
1742
+ zIndex: C ? 110 : 100
1743
+ }));
1744
+ }, r = () => {
1745
+ if (l)
1746
+ if (a) {
1747
+ console.log("清除非选中的港口");
1748
+ const v = a.get("portData").id;
1749
+ l.getFeatures().forEach((w) => {
1750
+ w.get("portData").id !== v && l.removeFeature(w);
1751
+ });
1752
+ } else
1753
+ console.log("清除所有港口", l), l == null || l.clear();
1754
+ }, L = (v) => {
1755
+ if (l) {
1756
+ if (!v)
1757
+ return m();
1758
+ (a == null ? void 0 : a.get("portData").id) !== v.id && (m(), F(v));
1759
+ }
1760
+ }, m = () => {
1761
+ if (a) {
1762
+ const v = a == null ? void 0 : a.get("portData"), w = e.getZoom();
1763
+ l.getFeatures().forEach((k) => {
1764
+ k.get("portData").id === v.id && (k.setStyle(t(k.get("portData"), w, !1)), a = null);
1765
+ });
1766
+ }
1767
+ }, F = (v) => {
1768
+ if (!l) return;
1769
+ const w = l.getFeatures();
1770
+ o = v, a = w.find((C) => C.get("portData").id === v.id), a == null || a.setStyle(t(v, e.getZoom(), !0));
1771
+ };
1772
+ return {
1773
+ render: f,
1774
+ clear: r,
1775
+ selected: L,
1776
+ handlePortHover: (v) => {
1777
+ const w = i == null ? void 0 : i.getTargetElement();
1778
+ v && v.get("portData") && w && (w.style.cursor = "pointer");
1779
+ }
1780
+ };
1781
+ }, useEventManager = (e, i, n, l, a, o) => {
1782
+ const f = e.getInstall();
1783
+ f.on("moveend", () => {
1784
+ var p, t;
1785
+ try {
1786
+ const r = e.getZoom();
1787
+ (t = (p = i.getProps()).mapMoveEnd) == null || t.call(p, r), n.reRenderTrackLine(), r <= MAP_ZOOM.shipModelMax && r >= MAP_ZOOM.shipTriggleMin && l.changeShipScale("end");
1788
+ } catch (r) {
1789
+ console.log("moveend---catch", r);
1790
+ }
1791
+ }), f.on("pointermove", (p) => {
1792
+ try {
1793
+ const t = f.getEventPixel(p.originalEvent), r = f == null ? void 0 : f.forEachFeatureAtPixel(t, (L) => L);
1794
+ l == null || l.handleShipMapEvent(r, "hover"), n == null || n.handleTrackMapEvent(r, "hover", p), r && a.handlePortHover(r);
1795
+ } catch (t) {
1796
+ console.log("pointermove---catch", t);
1797
+ }
1798
+ }), f.on("movestart", () => {
1799
+ try {
1800
+ const p = f == null ? void 0 : f.getView().getZoom();
1801
+ p && p <= MAP_ZOOM.shipModelMax && p >= MAP_ZOOM.shipTriggleMin && l.changeShipScale("start");
1802
+ } catch (p) {
1803
+ console.log("movestart---catch", p);
1804
+ }
1805
+ }), f.on("click", debounce((p) => {
1806
+ var t, r, L;
1807
+ try {
1808
+ if (console.log("1", o.getState()), o.getState()) return;
1809
+ const m = f.getEventPixel(p.originalEvent), F = f.forEachFeatureAtPixel(
1810
+ m,
1811
+ (O) => {
1812
+ if (O != null && O.get("shipData") || O != null && O.get("portData"))
1813
+ return O;
1814
+ }
1815
+ );
1816
+ if (console.log("2", F), !F) return;
1817
+ if (F.get("shipData"))
1818
+ l.handleShipMapEvent(F, "click", (t = i.getProps()) == null ? void 0 : t.selectShip);
1819
+ else if (F.get("portData")) {
1820
+ const O = F.get("portData");
1821
+ a.selected(O), (L = (r = i.getProps()) == null ? void 0 : r.selectPort) == null || L.call(r, O);
1822
+ }
1823
+ p.preventDefault(), p.stopPropagation();
1824
+ } catch (m) {
1825
+ console.log("click---catch", m);
1826
+ }
1827
+ }, 150));
1828
+ }, useMapController = () => {
1829
+ const e = reactive([]);
1830
+ return {
1831
+ createInstance: (l, a) => {
1832
+ const o = useMapInitializer();
1833
+ o.initMap(l, a);
1834
+ const f = o.getInstall(), p = useLayerManager(f), t = usePropsManager();
1835
+ t.setProps(a), p.setShowLayerType(a.layerType), p.setGreenTileVisible(a.showGreenLayer);
1836
+ const r = useTrackManager(f), L = useCarTrackManager(f, r), m = useShipManager(f), F = usePositionManager(f), O = useDrawLineManager(f, t), v = useDrawPolygonManager(f, t), w = usePortManager(o);
1837
+ useEventManager(o, t, r, m, w, O);
1838
+ const C = () => {
1839
+ const x = f.getView().calculateExtent(o.getSize()), Z = transform([x[0], x[1]], projection.mercator, projection.data), B = transform([x[2], x[3]], projection.mercator, projection.data);
1840
+ return [Z[0], Z[1], B[0], B[1]];
1841
+ }, k = {
1842
+ id: Symbol("map-instance"),
1843
+ innerMap: null,
1844
+ map: o.getInstall(),
1845
+ destroy: () => {
1846
+ e.splice(e.indexOf(k), 1);
1847
+ },
1848
+ methods: {
1849
+ ...o,
1850
+ layer: p,
1851
+ ship: m,
1852
+ track: r,
1853
+ carTrack: L,
1854
+ port: {
1855
+ render: w.render,
1856
+ clear: w.clear,
1857
+ selected: w.selected
1858
+ },
1859
+ position: F,
1860
+ drawLine: O,
1861
+ drawPolygon: v,
1862
+ // 子模块
1863
+ utils: {
1864
+ getCalculateExtent: C,
1865
+ convertSixHundredThousandToLatLng,
1866
+ calculateCirclePoints
1867
+ }
1868
+ }
1869
+ };
1870
+ return e.push(k), k;
1871
+ },
1872
+ destroyInstance: (l) => {
1873
+ const a = e.findIndex((o) => o.id === l);
1874
+ a > -1 && (e[a].destroy(), e.splice(a, 1));
1875
+ },
1876
+ destroyAll: () => {
1877
+ e.forEach((l) => l.destroy()), e.splice(0, e.length);
1878
+ },
1879
+ getAllInstances: () => [...e]
1880
+ };
1881
+ }, _hoisted_1 = { class: "zh-map-box" }, _sfc_main = /* @__PURE__ */ defineComponent({
1882
+ __name: "Map",
1883
+ props: {
1884
+ zoom: { default: MAP_ZOOM.default },
1885
+ center: { default: MAP_DEFAULT_CENTER },
1886
+ layerType: { default: "vector" },
1887
+ showGreenLayer: { type: Boolean, default: !1 },
1888
+ showScale: { type: Boolean, default: !0 },
1889
+ scaleLineUnit: { default: "metric" },
1890
+ mapMoveEnd: { type: Function, default: () => {
1891
+ } },
1892
+ lineDrawEnd: {},
1893
+ areaDrawEnd: { type: Function, default: () => {
1894
+ } },
1895
+ selectShip: { type: Function, default: () => {
1896
+ } },
1897
+ selectPort: { type: Function, default: () => {
1898
+ } }
1899
+ },
1900
+ setup(e, { expose: i }) {
1901
+ const n = ref(), l = ref(), a = useMapController(), o = ref(), f = e, p = ref({
1902
+ getInstall() {
1903
+ }
1904
+ });
1905
+ return onMounted(() => {
1906
+ var t;
1907
+ o.value = a.createInstance(n.value, f), p.value = o.value.methods, (t = l.value) == null || t.setScaleLine(o.value.map, f.scaleLineUnit);
1908
+ }), onUnmounted(() => {
1909
+ var t, r;
1910
+ a.destroyInstance((t = o == null ? void 0 : o.value) == null ? void 0 : t.id), (r = o.value) == null || r.destroy();
1911
+ }), i({
1912
+ getZoom: () => {
1913
+ var t;
1914
+ return (t = o.value) == null ? void 0 : t.methods.getZoom();
1915
+ },
1916
+ setZoom: (t) => {
1917
+ var r;
1918
+ return (r = o.value) == null ? void 0 : r.methods.setZoom(t);
1919
+ },
1920
+ getInstall: () => {
1921
+ var t;
1922
+ return (t = o.value) == null ? void 0 : t.methods.getInstall();
1923
+ },
1924
+ getView: () => {
1925
+ var t;
1926
+ return (t = o.value) == null ? void 0 : t.methods.getView();
1927
+ },
1928
+ setCenter: (t, r) => {
1929
+ var L;
1930
+ return (L = o.value) == null ? void 0 : L.methods.setCenter(t, r);
1931
+ },
1932
+ getSize: () => {
1933
+ var t;
1934
+ return (t = o.value) == null ? void 0 : t.methods.getSize();
1935
+ },
1936
+ getCenter: (t, r) => {
1937
+ var L;
1938
+ return (L = o.value) == null ? void 0 : L.methods.getCenter();
1939
+ },
1940
+ layer: {
1941
+ setGreenTileVisible: (t) => {
1942
+ var r;
1943
+ return (r = o.value) == null ? void 0 : r.methods.layer.setGreenTileVisible(t);
1944
+ },
1945
+ getGreenTileVisible: () => {
1946
+ var t;
1947
+ return (t = o.value) == null ? void 0 : t.methods.layer.getGreenTileVisible();
1948
+ },
1949
+ getShowLayerType: () => {
1950
+ var t;
1951
+ return (t = o.value) == null ? void 0 : t.methods.layer.getShowLayerType();
1952
+ },
1953
+ setShowLayerType: (t) => {
1954
+ var r;
1955
+ return (r = o.value) == null ? void 0 : r.methods.layer.setShowLayerType(t);
1956
+ }
1957
+ },
1958
+ ship: {
1959
+ render: (...t) => {
1960
+ var r;
1961
+ return (r = o.value) == null ? void 0 : r.methods.ship.render(...t);
1962
+ },
1963
+ selected: (...t) => {
1964
+ var r;
1965
+ return (r = o.value) == null ? void 0 : r.methods.ship.selected(...t);
1966
+ },
1967
+ filter: (...t) => {
1968
+ var r;
1969
+ return (r = o.value) == null ? void 0 : r.methods.ship.filter(...t);
1970
+ },
1971
+ blinking: (...t) => {
1972
+ var r;
1973
+ return (r = o.value) == null ? void 0 : r.methods.ship.blinking(...t);
1974
+ },
1975
+ clear: () => {
1976
+ var t;
1977
+ return (t = o.value) == null ? void 0 : t.methods.ship.clear();
1978
+ }
1979
+ },
1980
+ track: {
1981
+ render: (...t) => {
1982
+ var r;
1983
+ return (r = o.value) == null ? void 0 : r.methods.track.render(...t);
1984
+ },
1985
+ remove: (...t) => {
1986
+ var r;
1987
+ return (r = o.value) == null ? void 0 : r.methods.track.remove(...t);
1988
+ },
1989
+ play: (...t) => {
1990
+ var r;
1991
+ return (r = o.value) == null ? void 0 : r.methods.track.play(...t);
1992
+ },
1993
+ setCenter: (...t) => {
1994
+ var r;
1995
+ return (r = o.value) == null ? void 0 : r.methods.track.setCenter(...t);
1996
+ },
1997
+ close: (...t) => {
1998
+ var r;
1999
+ return (r = o.value) == null ? void 0 : r.methods.track.close(...t);
2000
+ },
2001
+ getLength: (...t) => {
2002
+ var r;
2003
+ return (r = o.value) == null ? void 0 : r.methods.track.getLength(...t);
2004
+ }
2005
+ },
2006
+ carTrack: {
2007
+ location: (...t) => {
2008
+ var r;
2009
+ return (r = o.value) == null ? void 0 : r.methods.carTrack.location(...t);
2010
+ },
2011
+ remove: (...t) => {
2012
+ var r;
2013
+ return (r = o.value) == null ? void 0 : r.methods.carTrack.remove(...t);
2014
+ },
2015
+ renderTrack: (...t) => {
2016
+ var r;
2017
+ return (r = o.value) == null ? void 0 : r.methods.carTrack.renderTrack(...t);
2018
+ },
2019
+ setCenter: (...t) => {
2020
+ var r;
2021
+ return (r = o.value) == null ? void 0 : r.methods.carTrack.setCenter(...t);
2022
+ },
2023
+ closeTrack: () => {
2024
+ var t;
2025
+ return (t = o.value) == null ? void 0 : t.methods.carTrack.closeTrack();
2026
+ },
2027
+ playTrack: (...t) => {
2028
+ var r;
2029
+ return (r = o.value) == null ? void 0 : r.methods.carTrack.playTrack(...t);
2030
+ }
2031
+ },
2032
+ port: {
2033
+ render: (t, r) => {
2034
+ var L;
2035
+ return (L = o.value) == null ? void 0 : L.methods.port.render(t, r);
2036
+ },
2037
+ clear: () => {
2038
+ var t;
2039
+ return (t = o.value) == null ? void 0 : t.methods.port.clear();
2040
+ },
2041
+ selected: (t) => {
2042
+ var r;
2043
+ return (r = o.value) == null ? void 0 : r.methods.port.selected(t);
2044
+ }
2045
+ },
2046
+ position: {
2047
+ render: (...t) => {
2048
+ var r;
2049
+ return (r = o.value) == null ? void 0 : r.methods.position.render(...t);
2050
+ },
2051
+ selected: (...t) => {
2052
+ var r;
2053
+ return (r = o.value) == null ? void 0 : r.methods.position.selected(...t);
2054
+ },
2055
+ clearSelected: (...t) => {
2056
+ var r;
2057
+ return (r = o.value) == null ? void 0 : r.methods.position.clearSelected(...t);
2058
+ },
2059
+ clear: () => {
2060
+ var t;
2061
+ return (t = o.value) == null ? void 0 : t.methods.position.clear();
2062
+ }
2063
+ },
2064
+ drawLine: {
2065
+ open: () => {
2066
+ var t;
2067
+ return (t = o.value) == null ? void 0 : t.methods.drawLine.open();
2068
+ },
2069
+ close: () => {
2070
+ var t;
2071
+ return (t = o.value) == null ? void 0 : t.methods.drawLine.close();
2072
+ },
2073
+ deleteLine: (t) => {
2074
+ var r;
2075
+ return (r = o.value) == null ? void 0 : r.methods.drawLine.deleteLine(t);
2076
+ },
2077
+ setUnit: (t) => {
2078
+ var r;
2079
+ return (r = o.value) == null ? void 0 : r.methods.drawLine.setUnit(t);
2080
+ },
2081
+ getState: () => {
2082
+ var t;
2083
+ return (t = o.value) == null ? void 0 : t.methods.drawLine.getState();
2084
+ }
2085
+ },
2086
+ drawPolygon: {
2087
+ open: () => {
2088
+ var t;
2089
+ return (t = o.value) == null ? void 0 : t.methods.drawPolygon.open();
2090
+ },
2091
+ close: () => {
2092
+ var t;
2093
+ return (t = o.value) == null ? void 0 : t.methods.drawPolygon.close();
2094
+ },
2095
+ reset: () => {
2096
+ var t;
2097
+ return (t = o.value) == null ? void 0 : t.methods.drawPolygon.reset();
2098
+ }
2099
+ },
2100
+ // 子模块
2101
+ utils: {
2102
+ getCalculateExtent: (...t) => {
2103
+ var r;
2104
+ return (r = o.value) == null ? void 0 : r.methods.utils.getCalculateExtent(...t);
2105
+ },
2106
+ convertSixHundredThousandToLatLng: (...t) => {
2107
+ var r;
2108
+ return (r = o.value) == null ? void 0 : r.methods.utils.convertSixHundredThousandToLatLng(...t);
2109
+ },
2110
+ calculateCirclePoints: (t, r) => {
2111
+ var L;
2112
+ return (L = o.value) == null ? void 0 : L.methods.utils.calculateCirclePoints(t, r);
2113
+ }
2114
+ }
2115
+ }), (t, r) => (openBlock(), createElementBlock("div", _hoisted_1, [
2116
+ createElementVNode("div", {
2117
+ id: "map",
2118
+ ref_key: "zhMapRef",
2119
+ ref: n,
2120
+ class: "zh-map"
2121
+ }, null, 512),
2122
+ createVNode(ScaleLine, {
2123
+ ref_key: "scaleLineRef",
2124
+ ref: l
2125
+ }, null, 512),
2126
+ createVNode(ZoomControl, {
2127
+ ref: "zoomControlRef",
2128
+ "map-instance": o.value
2129
+ }, null, 8, ["map-instance"])
2130
+ ]));
2131
+ }
2132
+ }), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5724a05d"]]), ZhMap = withInstall(Map$1);
2133
+ export {
2134
+ ZhMap as Z
2135
+ };