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