zhihao-ui 1.3.22 → 1.3.24

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