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