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