zhihao-ui 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/{BaseInfo-DP7wB6Hy.js → BaseInfo-CqPKfZM2.js} +1 -1
- package/dist/es/{BaseItem-zKXAWw6X.js → BaseItem-XXH5e7db.js} +3 -3
- package/dist/es/{Button-D71UFKe2.js → Button-DLAiqJPu.js} +2 -2
- package/dist/es/{DatePicker-ByaPDV8a.js → DatePicker-DNED5PYV.js} +3 -3
- package/dist/es/{DetailHeader-BvwqbiHO.js → DetailHeader-BCF-X9k8.js} +3 -3
- package/dist/es/{DetailSubTitle-Brh4lgY7.js → DetailSubTitle-Booxy4wf.js} +2 -2
- package/dist/es/{Dialog-Dfj9XSbZ.js → Dialog-gDiUEFNF.js} +3 -3
- package/dist/es/{DiyDataTable-CyinC7X9.js → DiyDataTable-CPFSQBiW.js} +4 -4
- package/dist/es/{EditInfoPair-Bh8ExT4y.js → EditInfoPair-BeQ_RjRC.js} +3 -3
- package/dist/es/{FileWrapper-Cr7F-CIS.js → FileWrapper-CyQAOj8M.js} +4 -4
- package/dist/es/{Grid-CzmdTj41.js → Grid-DAZ59W8l.js} +2 -2
- package/dist/es/{InfoPair-wZg9g-ul.js → InfoPair-D2gWOKNY.js} +3 -3
- package/dist/es/{Input-DRtonb3d.js → Input-DCs9DGvN.js} +3 -3
- package/dist/es/{Loading-CujO-NlL.js → Loading-tblIiyvu.js} +2 -2
- package/dist/es/Map-CWehCrKQ.js +1610 -0
- package/dist/es/{MessageBox-CRUoKQsc.js → MessageBox-Bwv1ICSl.js} +2 -2
- package/dist/es/{MoneyInput-D1u6lU9a.js → MoneyInput-BUho-aKW.js} +7 -7
- package/dist/es/{PageHeadPanel-COhIV995.js → PageHeadPanel-BBzYKasW.js} +2 -2
- package/dist/es/{Table-BFbxIF3i.js → Table-m_nv-2IU.js} +41 -41
- package/dist/es/{ToolTips-DNojIdT8.js → ToolTips-BrpfWKhV.js} +5 -5
- package/dist/es/index.js +22 -22
- package/dist/es/{utils-CVU4so-2.js → utils-sJ-t5B4u.js} +1 -1
- package/dist/es/{vendor-Cx2Ws2_l.js → vendor-BUg4XLGS.js} +2787 -2789
- package/dist/index.css +1 -1
- package/dist/types/components/Map/Map.vue.d.ts +112 -0
- package/dist/types/components/Map/config/global.d.ts +1 -0
- package/dist/types/components/Map/config/index.d.ts +2 -28
- package/dist/types/components/Map/config/map.d.ts +25 -0
- package/dist/types/components/Map/function/carTrack.d.ts +1 -1
- package/dist/types/components/Map/function/drawLine.d.ts +2 -9
- package/dist/types/components/Map/function/drawPolygon.d.ts +0 -7
- package/dist/types/components/Map/function/map.d.ts +4 -0
- package/dist/types/components/Map/function/props.d.ts +4 -0
- package/dist/types/components/Map/function/ship/style.d.ts +4 -2
- package/dist/types/components/Map/function/shipTrack.d.ts +1 -1
- package/dist/types/components/Map/index.d.ts +364 -0
- package/dist/types/components/Map/interface/index.d.ts +0 -1
- package/dist/types/components/Map/interface/mapProps.d.ts +1 -0
- package/dist/types/components/Map/utils/overlay.d.ts +4 -0
- package/dist/umd/index.css +1 -1
- package/dist/umd/index.umd.cjs +60 -66
- package/package.json +1 -1
- package/dist/es/Map-mRzxeRp6.js +0 -1877
|
@@ -0,0 +1,1610 @@
|
|
|
1
|
+
import { ref, computed, watch, onMounted, onBeforeUnmount, h, nextTick, createVNode, render, defineComponent, openBlock, createElementBlock, inject, createElementVNode, Fragment } from "vue";
|
|
2
|
+
import { T as Text, F as Fill, S as Style, p as getLength, R as RBush$1, q as fromLonLat, O as Overlay, I as Icon, V as VectorSource, r as VectorLayer, s as debounce, i as cloneDeep, t as Feature, P as Point, h as hooks, L as LineString, u as Stroke, C as CircleStyle, v as Polyline, w as buffer, x as transform, y as getVectorContext, D as DoubleClickZoom, z as Draw, A as unByKey, B as getUid, M as Map$2, G as TileLayer, X as XYZ, H as View, J as toLonLat, K as ScaleLine$1, N as MultiPoint, Q as getArea } from "./vendor-BUg4XLGS.js";
|
|
3
|
+
import { _ as _export_sfc } from "./Button-DLAiqJPu.js";
|
|
4
|
+
import { w as withInstall } from "./utils-sJ-t5B4u.js";
|
|
5
|
+
const TIAN_DI_TU_KEY = "a6e8f78974f2581f2ca00485b40c948f", MAP_ZOOM = {
|
|
6
|
+
// 地图默认层级
|
|
7
|
+
default: 13,
|
|
8
|
+
// 地图缩放最小层级
|
|
9
|
+
min: 3,
|
|
10
|
+
// 地图缩放最大层级
|
|
11
|
+
max: 18,
|
|
12
|
+
// 船形图标最小渲染层级
|
|
13
|
+
shipTriggleMin: 16,
|
|
14
|
+
// 船形图标最大渲染层级
|
|
15
|
+
shipModelMax: 18,
|
|
16
|
+
//根据原系统canvas图片转换svg长宽比例计算缩放值
|
|
17
|
+
scaleNum: 0.555
|
|
18
|
+
}, projection = {
|
|
19
|
+
// 经纬度 源数据 地理坐标 WGS84
|
|
20
|
+
data: "EPSG:4326",
|
|
21
|
+
// 墨卡托投影坐标 渲染坐标
|
|
22
|
+
mercator: "EPSG:3857"
|
|
23
|
+
}, MAP_DEFAULT_CENTER = [114.84, 30.52], CDN_URL = "https://static.zhihaoscm.cn/", formatLength = function(e, t) {
|
|
24
|
+
const n = getLength(e);
|
|
25
|
+
let r = "";
|
|
26
|
+
switch (t) {
|
|
27
|
+
case LENGTH_UNIT.M:
|
|
28
|
+
r = Math.round(n * 100) / 100 + " m";
|
|
29
|
+
break;
|
|
30
|
+
case LENGTH_UNIT.KM:
|
|
31
|
+
r = Math.round(n / 1e3 * 100) / 100 + " km";
|
|
32
|
+
break;
|
|
33
|
+
case LENGTH_UNIT.NM:
|
|
34
|
+
r = (Math.round(n / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return r;
|
|
38
|
+
}, equatorialCircumference = 2003750834e-2;
|
|
39
|
+
function lonLatToMercator(e) {
|
|
40
|
+
const t = e[0] * equatorialCircumference / 180;
|
|
41
|
+
let o = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
|
|
42
|
+
return o = o * equatorialCircumference / 180, [t, o];
|
|
43
|
+
}
|
|
44
|
+
function getIconFont(unicode = "") {
|
|
45
|
+
return unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), eval('("' + unicode.replace("&#x", "\\u").replace(";", "") + '")');
|
|
46
|
+
}
|
|
47
|
+
const getIconStyle = (e) => {
|
|
48
|
+
const t = new Text({
|
|
49
|
+
font: "Normal 14px map-iconfont",
|
|
50
|
+
text: getIconFont(e),
|
|
51
|
+
fill: new Fill({ color: "#fff" }),
|
|
52
|
+
offsetY: -14
|
|
53
|
+
});
|
|
54
|
+
return new Style({
|
|
55
|
+
text: t,
|
|
56
|
+
zIndex: 100
|
|
57
|
+
});
|
|
58
|
+
}, adjustBounds = (e, t) => t.length === 2 ? [e[0] - t[0], e[1] - t[1], e[2] + t[0], e[3] + t[1]] : [e[0] + t[0], e[1] + t[1], e[2] + t[2], e[3] + t[3]], isOverlapping$1 = (e, t) => e[0] <= t[2] && e[2] >= t[0] && e[1] <= t[3] && e[3] >= t[1], mercatorToLonLat = (e, t = "lonlat") => {
|
|
59
|
+
const o = { lon: 0, lat: 0 }, n = e[0] / equatorialCircumference * 180;
|
|
60
|
+
let r = e[1] / equatorialCircumference * 180;
|
|
61
|
+
return r = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2), o.lon = n, o.lat = r, t === "lonlat" ? o : [n, r];
|
|
62
|
+
};
|
|
63
|
+
var BASE_MAP_LINK = ((e) => (e.vectorTile = `https://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.vectorTileMark = `https://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.satelliteImgTile = `https://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.satelliteImgTileMark = `https://t0.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${TIAN_DI_TU_KEY}`, e.greenTile = `${CDN_URL}/map/tile/{z}/{x}/{y}.png`, e))(BASE_MAP_LINK || {}), LENGTH_UNIT = /* @__PURE__ */ ((e) => (e[e.M = 1] = "M", e[e.KM = 2] = "KM", e[e.NM = 3] = "NM", e))(LENGTH_UNIT || {});
|
|
64
|
+
const getRightIcons = (e) => {
|
|
65
|
+
const t = [];
|
|
66
|
+
return e.existDevice && t.push(""), e.existMobile && t.push(""), e.existWaterGauge && t.push(""), t;
|
|
67
|
+
};
|
|
68
|
+
new RBush$1();
|
|
69
|
+
var SHIP_SAIL_STATUS = /* @__PURE__ */ ((e) => (e[e.发动机使用中 = 0] = "发动机使用中", e[e.锚泊 = 1] = "锚泊", e[e.未操作 = 2] = "未操作", e[e.操纵能力受限 = 3] = "操纵能力受限", e[e.吃水受限 = 4] = "吃水受限", e[e.系泊 = 5] = "系泊", e[e.搁浅 = 6] = "搁浅", e[e.从事捕捞 = 7] = "从事捕捞", e[e.航行中 = 8] = "航行中", e[e.留作将来修正导航状态 = 9] = "留作将来修正导航状态", e[e.高速船留用 = 10] = "高速船留用", e[e.机动船尾推作业 = 11] = "机动船尾推作业", e[e.机动船顶推或侧推作业 = 12] = "机动船顶推或侧推作业", e[e.飞翼船留用 = 13] = "飞翼船留用", e[e.现行的 = 14] = "现行的", e[e.未定义 = 15] = "未定义", e))(SHIP_SAIL_STATUS || {}), SHIP_DIRECT = /* @__PURE__ */ ((e) => (e.left = "left", e.right = "right", e.front = "front", e.up = "up", e.down = "down", e.back = "back", e))(SHIP_DIRECT || {});
|
|
70
|
+
function useShipOverlay(e) {
|
|
71
|
+
const t = ref(null), o = ref(null), n = computed(() => ({
|
|
72
|
+
"--overlay-color": e.color,
|
|
73
|
+
"--bg-color": e.selected ? e.color : "#ffffff",
|
|
74
|
+
position: "relative",
|
|
75
|
+
"pointer-events": "none"
|
|
76
|
+
})), r = computed(() => ({
|
|
77
|
+
position: "relative",
|
|
78
|
+
"border-radius": "1px",
|
|
79
|
+
"background-color": "var(--bg-color)",
|
|
80
|
+
color: "#000",
|
|
81
|
+
"padding-right": "5px",
|
|
82
|
+
"box-shadow": "0 2px 10px rgba(0, 0, 0, 0.2)",
|
|
83
|
+
"font-size": "10px",
|
|
84
|
+
"white-space": "nowrap",
|
|
85
|
+
border: "1px solid #FFF",
|
|
86
|
+
"pointer-events": "auto",
|
|
87
|
+
transition: "background-color 0.5s ease, border 0.5s ease",
|
|
88
|
+
"z-index": "1",
|
|
89
|
+
display: "flex",
|
|
90
|
+
"align-items": "center"
|
|
91
|
+
})), a = computed(() => ({
|
|
92
|
+
width: "14px",
|
|
93
|
+
height: "14px",
|
|
94
|
+
margin: "1px 5px 1px 1px",
|
|
95
|
+
"background-color": "var(--bg-color)"
|
|
96
|
+
})), l = computed(() => ({
|
|
97
|
+
// 'position': 'absolute',
|
|
98
|
+
// 'background': '#FFF',
|
|
99
|
+
// 'height': '1px',
|
|
100
|
+
// 'color': 'var(--overlay-color)',
|
|
101
|
+
// .connection-line::before {
|
|
102
|
+
// content: '';
|
|
103
|
+
// position: absolute;
|
|
104
|
+
// width: var(--length);
|
|
105
|
+
// height: 100%;
|
|
106
|
+
// transform: rotate(var(--angle));
|
|
107
|
+
// transform-origin: left center;
|
|
108
|
+
// left: var(--start-x);
|
|
109
|
+
// top: var(--start-y);
|
|
110
|
+
// }
|
|
111
|
+
position: "absolute",
|
|
112
|
+
top: "0px",
|
|
113
|
+
color: "var(--overlay-color)",
|
|
114
|
+
"pointer-events": "none",
|
|
115
|
+
transform: "translateY(-1px)",
|
|
116
|
+
"z-index": "0",
|
|
117
|
+
width: "20px",
|
|
118
|
+
height: "20px",
|
|
119
|
+
overflow: "visible"
|
|
120
|
+
}));
|
|
121
|
+
let i = null;
|
|
122
|
+
const c = () => {
|
|
123
|
+
d(), i = window.setInterval(() => {
|
|
124
|
+
if (t.value) {
|
|
125
|
+
const s = t.value.querySelector(".ship-overlay-content");
|
|
126
|
+
s && s.style && (s.style.backgroundColor = e.color, s.style.color = "#FFF", setTimeout(() => {
|
|
127
|
+
s && s.style && (s.style.backgroundColor = "#ffffff", s.style.color = "#000");
|
|
128
|
+
}, 500));
|
|
129
|
+
}
|
|
130
|
+
}, 1e3);
|
|
131
|
+
}, d = () => {
|
|
132
|
+
i && (clearInterval(i), i = null);
|
|
133
|
+
}, u = () => {
|
|
134
|
+
o.value && o.value.setPosition(fromLonLat(e.position));
|
|
135
|
+
};
|
|
136
|
+
return watch(() => e.selected, (s) => {
|
|
137
|
+
s ? c() : d();
|
|
138
|
+
}, { immediate: !0 }), watch(() => e.position, () => {
|
|
139
|
+
u();
|
|
140
|
+
}, { deep: !0 }), onMounted(() => {
|
|
141
|
+
}), onBeforeUnmount(() => {
|
|
142
|
+
d();
|
|
143
|
+
}), () => h("div", {
|
|
144
|
+
ref: t,
|
|
145
|
+
class: "ship-overlay-container",
|
|
146
|
+
style: n.value
|
|
147
|
+
}, [
|
|
148
|
+
h(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
class: "ship-overlay-content",
|
|
152
|
+
style: r.value
|
|
153
|
+
},
|
|
154
|
+
[
|
|
155
|
+
h("div", {
|
|
156
|
+
style: e.selected ? a.value : {}
|
|
157
|
+
}, ""),
|
|
158
|
+
h("div", {
|
|
159
|
+
class: "text"
|
|
160
|
+
}, e.name || "未命名船舶"),
|
|
161
|
+
h("div", {
|
|
162
|
+
class: "icons",
|
|
163
|
+
style: {
|
|
164
|
+
color: "#3370ff"
|
|
165
|
+
}
|
|
166
|
+
}, [
|
|
167
|
+
e.existDevice ? h("i", {
|
|
168
|
+
class: "iconfont icon-Frame-19",
|
|
169
|
+
style: {
|
|
170
|
+
fontSize: "12px"
|
|
171
|
+
}
|
|
172
|
+
}) : "",
|
|
173
|
+
e.existMobile ? h("i", {
|
|
174
|
+
class: "iconfont icon-Frame13",
|
|
175
|
+
style: {
|
|
176
|
+
fontSize: "12px"
|
|
177
|
+
}
|
|
178
|
+
}) : "",
|
|
179
|
+
e.existWaterGauge ? h("i", {
|
|
180
|
+
class: "iconfont icon-a-Frame7",
|
|
181
|
+
style: {
|
|
182
|
+
fontSize: "12px"
|
|
183
|
+
}
|
|
184
|
+
}) : ""
|
|
185
|
+
])
|
|
186
|
+
]
|
|
187
|
+
),
|
|
188
|
+
// h('div',{
|
|
189
|
+
// class: 'ship-overlay-line',
|
|
190
|
+
// style: lineStyle.value,
|
|
191
|
+
// })
|
|
192
|
+
h("svg", {
|
|
193
|
+
class: "ship-overlay-line",
|
|
194
|
+
style: l.value,
|
|
195
|
+
viewBox: "0 0 20 20",
|
|
196
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
197
|
+
}, [
|
|
198
|
+
h("line", {
|
|
199
|
+
x1: "0",
|
|
200
|
+
y1: "0",
|
|
201
|
+
x2: "0",
|
|
202
|
+
y2: "0",
|
|
203
|
+
stroke: "white",
|
|
204
|
+
"stroke-width": "1"
|
|
205
|
+
})
|
|
206
|
+
])
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
209
|
+
const POSITION_PRIORITY = [
|
|
210
|
+
{
|
|
211
|
+
positioning: "top-left",
|
|
212
|
+
offset: [20, -20],
|
|
213
|
+
line: { x1: "0", y1: "20", x2: "20", y2: "4" }
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
positioning: "top-right",
|
|
217
|
+
offset: [-20, -20],
|
|
218
|
+
line: { x1: "0", y1: "4", x2: "20", y2: "20" }
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
positioning: "top-left",
|
|
222
|
+
offset: [20, 0],
|
|
223
|
+
line: { x1: "0", y1: "0", x2: "20", y2: "4" }
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
positioning: "top-right",
|
|
227
|
+
offset: [-20, 0],
|
|
228
|
+
line: { x1: "0", y1: "4", x2: "20", y2: "0" }
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
positioning: "top-left",
|
|
232
|
+
offset: [20, 20],
|
|
233
|
+
line: { x1: "20", y1: "4", x2: "0", y2: "-20" }
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
positioning: "top-right",
|
|
237
|
+
offset: [-20, 20],
|
|
238
|
+
line: { x1: "0", y1: "4", x2: "20", y2: "-20" }
|
|
239
|
+
}
|
|
240
|
+
], existingOverlays = ref([]);
|
|
241
|
+
function isOverlapping(e, t) {
|
|
242
|
+
return !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom);
|
|
243
|
+
}
|
|
244
|
+
function calculateBestPosition(e, t) {
|
|
245
|
+
const o = existingOverlays.value.filter((n) => n !== e).map((n) => {
|
|
246
|
+
var r;
|
|
247
|
+
return (r = n.getElement()) == null ? void 0 : r.getBoundingClientRect();
|
|
248
|
+
}).filter((n) => n !== void 0);
|
|
249
|
+
for (const n of POSITION_PRIORITY) {
|
|
250
|
+
e.setPositioning(n.positioning), e.setOffset(n.offset), e.setPosition(t);
|
|
251
|
+
const r = e.getElement();
|
|
252
|
+
if (!r) continue;
|
|
253
|
+
r.offsetHeight;
|
|
254
|
+
const a = r.getBoundingClientRect();
|
|
255
|
+
if (!o.some(
|
|
256
|
+
(i) => isOverlapping(a, i)
|
|
257
|
+
))
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function addOverlay(e, t, o, n) {
|
|
262
|
+
const r = new Overlay({
|
|
263
|
+
element: o,
|
|
264
|
+
positioning: "top-left",
|
|
265
|
+
id: "label-" + n,
|
|
266
|
+
offset: [0, 0],
|
|
267
|
+
autoPan: !1,
|
|
268
|
+
className: "ship-label-overlay"
|
|
269
|
+
});
|
|
270
|
+
r.set("class", "zh-map-ship-overlay"), e.addOverlay(r), existingOverlays.value.push(r), nextTick(async () => {
|
|
271
|
+
await calculateBestPosition(r, t), setLinePath(r);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function setLinePath(e) {
|
|
275
|
+
const t = e.getElement(), o = t == null ? void 0 : t.querySelector(".ship-overlay-line"), n = e.getPositioning(), r = e.getOffset();
|
|
276
|
+
o && n === "top-right" && (o.style.right = "-20px"), o && n === "top-left" && (o.style.left = "-20px");
|
|
277
|
+
const a = POSITION_PRIORITY.filter((i) => i.positioning === n && i.offset === r), l = t == null ? void 0 : t.querySelector(".ship-overlay-line line");
|
|
278
|
+
if (a.length > 0) {
|
|
279
|
+
const { x1: i, y1: c, x2: d, y2: u } = a[0].line;
|
|
280
|
+
l && (l.setAttribute("x1", i), l.setAttribute("y1", c), l.setAttribute("x2", d), l.setAttribute("y2", u));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function removeLabelOverlay(e) {
|
|
284
|
+
existingOverlays.value = [], e.getOverlays().getArray().filter((n) => n.get("class") === "zh-map-ship-overlay").forEach((n) => {
|
|
285
|
+
n.setPosition(void 0), n.setElement(void 0), e.removeOverlay(n), n.dispose();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
const getShipDirectPath = (e) => {
|
|
289
|
+
const { spd: t, hdg: o, cog: n } = e;
|
|
290
|
+
return t ? o !== null && +o != 511 && n !== null ? n - +o >= 3 ? SHIP_DIRECT.right : n - +o <= -3 ? SHIP_DIRECT.left : SHIP_DIRECT.front : SHIP_DIRECT.front : "";
|
|
291
|
+
}, createShipStyle = (e) => {
|
|
292
|
+
const { shipData: t } = e.getProperties(), o = getShipType(), n = getShipScale(t, o);
|
|
293
|
+
return initShipStyle(e, n, o);
|
|
294
|
+
}, getShipType = () => {
|
|
295
|
+
const e = getZoom();
|
|
296
|
+
return e <= MAP_ZOOM.shipModelMax && e >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
|
|
297
|
+
}, getShipScale = (e, t) => {
|
|
298
|
+
if (t === "ship") {
|
|
299
|
+
const { len: o, wid: n } = e, r = 97, a = 20, i = 1 / getView().getResolution(), c = o * i / r, d = n * i / a;
|
|
300
|
+
return Math.max(c, d);
|
|
301
|
+
}
|
|
302
|
+
return MAP_ZOOM.scaleNum;
|
|
303
|
+
}, initShipStyle = (e, t, o) => {
|
|
304
|
+
const { color: n, direct: r, isHighlight: a, shipData: l } = e.getProperties(), i = (l.cog - 90 + 360) % 360;
|
|
305
|
+
return new Style({
|
|
306
|
+
image: new Icon({
|
|
307
|
+
src: c(),
|
|
308
|
+
scale: t || MAP_ZOOM.scaleNum,
|
|
309
|
+
anchor: [0.5, 0.5],
|
|
310
|
+
rotation: i * Math.PI / 180,
|
|
311
|
+
rotateWithView: !1
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
function c() {
|
|
315
|
+
return `data:image/svg+xml;utf8,${encodeURIComponent(d())}`;
|
|
316
|
+
}
|
|
317
|
+
function d() {
|
|
318
|
+
switch (o) {
|
|
319
|
+
case "triangle":
|
|
320
|
+
return `<svg width="41" height="24" viewBox="0 0 41 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
321
|
+
<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"
|
|
322
|
+
fill="${n}" stroke="${a ? "#FF2424" : "black"}" stroke-width="${a ? "2" : "0.578947"}" />
|
|
323
|
+
<!--path船航向左边或者向前-->
|
|
324
|
+
${r === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${a ? "#FF2424" : "black"}" stroke-width="2"/>`}
|
|
325
|
+
<!--path船航向右边-->
|
|
326
|
+
${r === SHIP_DIRECT.right && `<path d="M30 12L40 12L40 16" stroke="${a ? "#FF2424" : "black"}" stroke-width="2"/>`}
|
|
327
|
+
<!--path黑线无左右-->
|
|
328
|
+
${r === SHIP_DIRECT.front && `<path d="M30 12L40 12" stroke="${a ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
329
|
+
</svg>
|
|
330
|
+
`;
|
|
331
|
+
case "ship":
|
|
332
|
+
return `<svg width="97" height="20" viewBox="0 0 97 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
333
|
+
<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"
|
|
334
|
+
fill="${n}" stroke="${a ? "#FF2424" : "black"}" stroke-width="${a ? "4" : "0.578947"}"/>
|
|
335
|
+
${r === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${a ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
336
|
+
${r === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${a ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
337
|
+
${r === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${a ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
338
|
+
</svg>
|
|
339
|
+
`;
|
|
340
|
+
default:
|
|
341
|
+
return "";
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}, selectedShipStyle = (e) => {
|
|
345
|
+
const t = getShipType(), o = getShipScale(e, t), n = e.id, r = t === "ship" ? 109 : 49, a = `
|
|
346
|
+
<svg style="transform:scale(${o});" xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 49 49" fill="none">
|
|
347
|
+
<path d="M1.99982 46.9998L1.99982 1.99982L46.9998 1.99982L46.9998 46.9998L1.99982 46.9998Z" fill="#FF2424" fill-opacity="0.2"/>
|
|
348
|
+
<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"/>
|
|
349
|
+
</svg>
|
|
350
|
+
`, l = document.createElement("div");
|
|
351
|
+
l.className = "ship-overlay-selected", l.innerHTML = a;
|
|
352
|
+
const { lon: i, lat: c } = e, d = new Overlay({
|
|
353
|
+
element: l,
|
|
354
|
+
position: fromLonLat([i, c]),
|
|
355
|
+
id: "selected-" + n,
|
|
356
|
+
positioning: "center-center",
|
|
357
|
+
offset: [0, 5],
|
|
358
|
+
className: "ship-selected-overlay"
|
|
359
|
+
});
|
|
360
|
+
return d.set("class", "ship-overlay-selected"), d;
|
|
361
|
+
}, createLabelStyle = (e) => {
|
|
362
|
+
const t = getInstall(), o = document.createElement("div");
|
|
363
|
+
o.className = "ship-overlay-box", o.style.zIndex = "9", o.style.position = "relative";
|
|
364
|
+
const n = e.getProperties(), { shipData: r, blinking: a, blinkingColor: l, name: i } = n, { lon: c, lat: d } = r, u = createVNode({
|
|
365
|
+
setup() {
|
|
366
|
+
return useShipOverlay({
|
|
367
|
+
position: [c + 2e-3, d + 2e-3],
|
|
368
|
+
selected: a,
|
|
369
|
+
name: i,
|
|
370
|
+
color: l,
|
|
371
|
+
existDevice: r == null ? void 0 : r.existDevice,
|
|
372
|
+
existMobile: r == null ? void 0 : r.existMobile,
|
|
373
|
+
existWaterGauge: r == null ? void 0 : r.existWaterGauge
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
render(u, o), addOverlay(t, fromLonLat([c, d]), o, r.id);
|
|
378
|
+
};
|
|
379
|
+
let selectedShipFeature = null, selectedShip = null;
|
|
380
|
+
const shipsSource = new VectorSource(), shipsLayer = new VectorLayer({
|
|
381
|
+
source: shipsSource,
|
|
382
|
+
className: "zh-map--ship-layer",
|
|
383
|
+
updateWhileInteracting: !1,
|
|
384
|
+
updateWhileAnimating: !1,
|
|
385
|
+
renderBuffer: 300,
|
|
386
|
+
zIndex: 101
|
|
387
|
+
});
|
|
388
|
+
let hoveredShipId = "", attentionShips = {}, attentionShipsColor = {};
|
|
389
|
+
const renderShipList = (e) => {
|
|
390
|
+
console.log("renderShipList", e);
|
|
391
|
+
const t = getInstall();
|
|
392
|
+
if (!t) return;
|
|
393
|
+
t.getLayers().getArray().includes(shipsLayer) || t.addLayer(shipsLayer);
|
|
394
|
+
const o = (selectedShip == null ? void 0 : selectedShip.id) || (selectedShipFeature == null ? void 0 : selectedShipFeature.get("id"));
|
|
395
|
+
removeLabelOverlay(t), removeSelectedOverlay(), shipsSource && shipsSource.clear();
|
|
396
|
+
const n = [];
|
|
397
|
+
if (selectedShip) {
|
|
398
|
+
const r = e.filter((a) => a.id === o);
|
|
399
|
+
r.length === 0 ? e.push(selectedShip) : selectedShip = r[0];
|
|
400
|
+
}
|
|
401
|
+
e.forEach((r) => {
|
|
402
|
+
const a = fromLonLat([r.lon, r.lat]), l = new Feature({
|
|
403
|
+
geometry: new Point(a),
|
|
404
|
+
// 船舶数据
|
|
405
|
+
shipData: r,
|
|
406
|
+
id: r.id,
|
|
407
|
+
name: r.cnname || "未命名船舶",
|
|
408
|
+
selected: r.id === o,
|
|
409
|
+
// 图标
|
|
410
|
+
rightIcons: getRightIcons(r),
|
|
411
|
+
// 是否闪烁
|
|
412
|
+
blinking: attentionShips[r.id] || !1,
|
|
413
|
+
// 闪烁颜色
|
|
414
|
+
blinkingColor: attentionShipsColor[r.id] || "",
|
|
415
|
+
// 船舶颜色
|
|
416
|
+
color: r.fill || "#04C900",
|
|
417
|
+
// 船艏向的方向
|
|
418
|
+
direct: getShipDirectPath(r),
|
|
419
|
+
// 高亮
|
|
420
|
+
isHighlight: !1
|
|
421
|
+
});
|
|
422
|
+
l.setStyle(createShipStyle(l)), n.push(l), createLabelStyle(l);
|
|
423
|
+
}), shipsSource.addFeatures(n), setTimeout(() => {
|
|
424
|
+
if (selectedShip) {
|
|
425
|
+
const r = selectedShipStyle(selectedShip);
|
|
426
|
+
t.addOverlay(r);
|
|
427
|
+
}
|
|
428
|
+
}, 500);
|
|
429
|
+
}, clearShipList = () => {
|
|
430
|
+
const e = getInstall();
|
|
431
|
+
if (!e || !shipsSource) return;
|
|
432
|
+
const t = (selectedShip == null ? void 0 : selectedShip.id) || "";
|
|
433
|
+
shipsSource.getFeatures().forEach((n) => {
|
|
434
|
+
n.get("shipData").shipId !== t && shipsSource.removeFeature(n);
|
|
435
|
+
});
|
|
436
|
+
const o = e.getOverlays().getArray();
|
|
437
|
+
cloneDeep(o).map((n) => {
|
|
438
|
+
(n.getId() !== "label-" + t || n.getId() !== "selected-" + t) && (n.setPosition(void 0), n.setElement(void 0), e.removeOverlay(n), n.dispose());
|
|
439
|
+
});
|
|
440
|
+
}, renderShipBlink = (e, t) => {
|
|
441
|
+
attentionShips = e, attentionShipsColor = t;
|
|
442
|
+
}, filterShipShow = (e) => {
|
|
443
|
+
if (!getInstall()) return;
|
|
444
|
+
const o = shipsSource.getFeatures(), n = selectedShipFeature ? selectedShipFeature.get("id") : "", r = o.filter((l) => l.getId() !== n), a = /* @__PURE__ */ new Map();
|
|
445
|
+
e.forEach((l) => {
|
|
446
|
+
a.set(l.id, !0);
|
|
447
|
+
}), r.forEach((l) => {
|
|
448
|
+
const i = l.get("id");
|
|
449
|
+
if (!a.has(i))
|
|
450
|
+
l.setStyle([]);
|
|
451
|
+
else {
|
|
452
|
+
const c = l.getStyle();
|
|
453
|
+
(c == null ? void 0 : c.length) == 0 && l.setStyle(createShipStyle(l));
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}, renderShipSelected = (e) => {
|
|
457
|
+
if (e) {
|
|
458
|
+
console.log("选中", e);
|
|
459
|
+
const t = shipsSource.getFeatures().find((o) => o.get("id") === e.id);
|
|
460
|
+
t && (selectedShipFeature = t), selectedShip = e;
|
|
461
|
+
} else
|
|
462
|
+
console.log("取消选中"), removeSelectedOverlay();
|
|
463
|
+
}, handleShipMapEvent = debounce((e, t, o) => {
|
|
464
|
+
const n = getInstall();
|
|
465
|
+
if (e) {
|
|
466
|
+
const r = e.get("shipData"), a = e.get("id");
|
|
467
|
+
if (n.getTargetElement().style.cursor = a ? "pointer" : "", t === "click" && (renderShipSelected(r), o && o(a)), t === "hover") {
|
|
468
|
+
hoveredShipId && hoveredShipId !== a && clearHoverHight(), hoveredShipId = a;
|
|
469
|
+
const l = shipsSource.getFeatures().find((i) => i.get("id") === hoveredShipId);
|
|
470
|
+
l == null || l.set("isHighlight", !0), l == null || l.setStyle(createShipStyle(l));
|
|
471
|
+
}
|
|
472
|
+
} else
|
|
473
|
+
n.getTargetElement().style.cursor = "", clearHoverHight();
|
|
474
|
+
}, 10), clearHoverHight = () => {
|
|
475
|
+
const e = hoveredShipId ? shipsSource.getFeatures().find((t) => t.get("id") === hoveredShipId) : null;
|
|
476
|
+
hoveredShipId = null, e == null || e.set("isHighlight", !1), e == null || e.setStyle(createShipStyle(e));
|
|
477
|
+
}, removeSelectedOverlay = () => {
|
|
478
|
+
const e = getInstall();
|
|
479
|
+
e.getOverlays().getArray().filter((n) => n.get("class") == "ship-overlay-selected").forEach((n) => {
|
|
480
|
+
n.setPosition(void 0), n.setElement(void 0), e.removeOverlay(n), n.dispose();
|
|
481
|
+
});
|
|
482
|
+
}, convertSixHundredThousandToLatLng = function(e, t) {
|
|
483
|
+
const o = Number(t) / 6e5;
|
|
484
|
+
return [Number(e) / 6e5, o];
|
|
485
|
+
}, stopIcon = "", stopColor = "#E31818", slowIcon = "", slowColor = "#1890FF", dropletsIcon = "", DEFAULT_VALUE = "--";
|
|
486
|
+
let moveFeatureHandler = null;
|
|
487
|
+
const stopIconStyle = getIconStyle(stopIcon), slowIconStyle = getIconStyle(slowIcon), popupEle = document.createElement("div"), popupOverlay = new Overlay({
|
|
488
|
+
element: popupEle,
|
|
489
|
+
positioning: "top-left",
|
|
490
|
+
stopEvent: !1,
|
|
491
|
+
className: "track-label-overlay"
|
|
492
|
+
});
|
|
493
|
+
let polyline, linePath, startMarker, position, geoMarker, trackAnimating = !1, lastTime = Date.now(), vectorLayer$3, distance = 0, thresholdNum = 20;
|
|
494
|
+
const routesSource = new VectorSource(), routeLayer = new VectorLayer({
|
|
495
|
+
source: routesSource,
|
|
496
|
+
className: "zh-map--track-layer",
|
|
497
|
+
zIndex: 102
|
|
498
|
+
});
|
|
499
|
+
let routeFeatures = [], showTracks = [], allTracks = {}, trackId = "", trackColor = "", trackList = [], mapInstance$1 = null;
|
|
500
|
+
const reRenderTrackLine = () => {
|
|
501
|
+
mapInstance$1 = getInstall(), handlerRenderLine();
|
|
502
|
+
}, renderTrackLine = async (e, t, o, n = LENGTH_UNIT.NM, r = "ship", a = 200) => {
|
|
503
|
+
if (mapInstance$1 = getInstall(), !mapInstance$1) return;
|
|
504
|
+
if (routeLayer == null || routeLayer.setVisible(!0), t = t == null ? void 0 : t.reverse(), popupOverlay && r === "ship" && (mapInstance$1 != null && mapInstance$1.getOverlays().getArray().includes(popupOverlay) || mapInstance$1.addOverlay(popupOverlay)), clearShipList(), (t == null ? void 0 : t.length) < 2) {
|
|
505
|
+
(showTracks == null ? void 0 : showTracks.findIndex((s) => s.id === e)) < 0 && showTracks.push({ id: e, length: "" });
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const l = {};
|
|
509
|
+
t.forEach((s) => {
|
|
510
|
+
s.state ? s.state = Number(s.state) : delete s.state;
|
|
511
|
+
}), trackId = e, l[e] = t, trackList = t;
|
|
512
|
+
const i = l[e].map(
|
|
513
|
+
(s) => transform([s.lon, s.lat], projection.data, projection.mercator)
|
|
514
|
+
), c = new LineString(i), d = formatLength(c, n) || "--", u = showTracks == null ? void 0 : showTracks.findIndex((s) => s.id === e);
|
|
515
|
+
u < 0 ? showTracks.push({ id: e, length: d }) : showTracks[u].length = d, allTracks[e] = t, trackList = [], trackColor = o, thresholdNum = a, await handlerRenderLine(), await setTrackViewCenter(trackId);
|
|
516
|
+
}, handlerRenderLine = async () => {
|
|
517
|
+
const e = trackColor || "", t = trackId, o = allTracks[trackId] || [], n = thresholdNum || 200, r = Math.max(1, Math.floor(o.length / n));
|
|
518
|
+
trackList = o.filter((i, c) => c % r === 0).map((i, c) => {
|
|
519
|
+
if (Number(i.lon) > 180 || Number(i.lat) > 180) {
|
|
520
|
+
const [d, u] = convertSixHundredThousandToLatLng(i.lon, i.lat);
|
|
521
|
+
i.lon = d, i.lat = u;
|
|
522
|
+
}
|
|
523
|
+
return i.center = [i.lon, i.lat], i.centerPoint = lonLatToMercator(i.center), i.id = t, i.index = c, i.time = hooks(i.createdAt).format("YYYY-MM-DD HH:mm:ss"), i;
|
|
524
|
+
});
|
|
525
|
+
const l = trackList.map((i) => i.centerPoint);
|
|
526
|
+
l.length >= 2 && (mapInstance$1 == null || mapInstance$1.addLayer(routeLayer), await createTrackLineFeature(t, l, e));
|
|
527
|
+
}, createTrackLineFeature = (e, t, o) => {
|
|
528
|
+
var l;
|
|
529
|
+
const n = new LineString(t), r = new Feature({ geometry: n });
|
|
530
|
+
r.setStyle(createTrackLineStyle(o)), r.setId(e), r.set("type", "line"), (l = routeLayer == null ? void 0 : routeLayer.getSource()) == null || l.clear(), removeAllLabel(), routeFeatures = [];
|
|
531
|
+
const a = routeFeatures.findIndex((i) => i.getId() === e);
|
|
532
|
+
a >= 0 ? routeFeatures[a] = r : routeFeatures.push(r), routesSource.addFeatures([...routeFeatures]), createPointFeature(o);
|
|
533
|
+
}, createTrackLineStyle = (e) => new Style({
|
|
534
|
+
stroke: new Stroke({
|
|
535
|
+
color: e,
|
|
536
|
+
width: 2
|
|
537
|
+
})
|
|
538
|
+
}), handleTrackMapEvent = (e, t, o) => {
|
|
539
|
+
const n = e == null ? void 0 : e.get("trackId");
|
|
540
|
+
if (e && n && t === "hover") {
|
|
541
|
+
mapInstance$1.getTargetElement().style.cursor = n ? "pointer" : "";
|
|
542
|
+
const r = e.get("data"), a = renderTrackPointHtml(r), l = o == null ? void 0 : o.coordinate;
|
|
543
|
+
l && (popupEle.querySelector(".popup-content"), popupEle.innerHTML = a, popupOverlay == null || popupOverlay.setPosition(l));
|
|
544
|
+
} else
|
|
545
|
+
popupOverlay && popupOverlay.setPosition(void 0);
|
|
546
|
+
}, formatMinutesToDDHHMM = (e) => {
|
|
547
|
+
const t = hooks.duration(e, "minutes"), o = Math.floor(t.asDays()), n = t.hours(), r = t.minutes();
|
|
548
|
+
let a = `${String(r).padStart(2, "0")}分`;
|
|
549
|
+
return n !== 0 && (a = `${String(n).padStart(2, "0")}时${a}`), o !== 0 && (a = `${String(o).padStart(2, "0")}天${a}`), a;
|
|
550
|
+
}, renderTrackPointHtml = (e) => {
|
|
551
|
+
if (!(e != null && e.time)) return;
|
|
552
|
+
let t = "";
|
|
553
|
+
return e != null && e.stayTime && (t = `
|
|
554
|
+
<div class="item w-100">
|
|
555
|
+
<div class="item-label">停泊时间约</div>
|
|
556
|
+
<div class="item-item">${formatMinutesToDDHHMM(Number(e.stayTime))}</div>
|
|
557
|
+
</div>
|
|
558
|
+
`), `
|
|
559
|
+
<div class="track-point-popup">
|
|
560
|
+
<div class="item">
|
|
561
|
+
<div class="item-label">状态</div>
|
|
562
|
+
<div class="item-item">${e != null && e.sailStatus ? SHIP_SAIL_STATUS[e.sailStatus] : DEFAULT_VALUE}</div>
|
|
563
|
+
</div>
|
|
564
|
+
<div class="item">
|
|
565
|
+
<div class="item-label">航速</div>
|
|
566
|
+
<div class="item-item">${e.speed || DEFAULT_VALUE}</div>
|
|
567
|
+
</div>
|
|
568
|
+
<div class="item">
|
|
569
|
+
<div class="item-label">艏向</div>
|
|
570
|
+
<div class="item-item">${e.hdg || DEFAULT_VALUE}</div>
|
|
571
|
+
</div>
|
|
572
|
+
<div class="item">
|
|
573
|
+
<div class="item-label">航向</div>
|
|
574
|
+
<div class="item-item">${e.cog || DEFAULT_VALUE}</div>
|
|
575
|
+
</div>
|
|
576
|
+
<div class="item">
|
|
577
|
+
<div class="item-label">经度</div>
|
|
578
|
+
<div class="item-item">${e.lon || DEFAULT_VALUE}</div>
|
|
579
|
+
</div>
|
|
580
|
+
<div class="item">
|
|
581
|
+
<div class="item-label">纬度</div>
|
|
582
|
+
<div class="item-item">${e.lat || DEFAULT_VALUE}</div>
|
|
583
|
+
</div>
|
|
584
|
+
<div class="item w-100">
|
|
585
|
+
<div class="item-label">时间</div>
|
|
586
|
+
<div class="item-item">${e.time}</div>
|
|
587
|
+
</div>
|
|
588
|
+
${t ?? t}
|
|
589
|
+
</div>`;
|
|
590
|
+
}, createPointFeature = (e) => {
|
|
591
|
+
const t = trackList || [];
|
|
592
|
+
if (!(t && t.length > 1)) return [];
|
|
593
|
+
const o = { 16: 24, 17: 15, default: 4 }, n = [], r = t.length;
|
|
594
|
+
for (let l = 0; l < r; l++) {
|
|
595
|
+
t[l].index = l;
|
|
596
|
+
const i = mapInstance$1 == null ? void 0 : mapInstance$1.getPixelFromCoordinate(t[l].centerPoint);
|
|
597
|
+
if (i) {
|
|
598
|
+
let c = i.concat(i);
|
|
599
|
+
c = adjustBounds(c, [20, 20]);
|
|
600
|
+
const d = mapInstance$1 == null ? void 0 : mapInstance$1.getView().getZoom();
|
|
601
|
+
if (!d) return;
|
|
602
|
+
if (d > 15) {
|
|
603
|
+
const s = o[d] || o.default;
|
|
604
|
+
c = adjustBounds(c, [s, s]);
|
|
605
|
+
}
|
|
606
|
+
let u = !0;
|
|
607
|
+
if (t[l].state !== "0") {
|
|
608
|
+
for (let s = 0; s < n.length; s++)
|
|
609
|
+
if (isOverlapping$1(c, n[s].bounds)) {
|
|
610
|
+
u = !1;
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
u && (t[l].bounds = c, n.push(t[l]));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
const a = [];
|
|
618
|
+
n.forEach((l) => {
|
|
619
|
+
const i = new Feature({
|
|
620
|
+
geometry: new Point(l.centerPoint),
|
|
621
|
+
time: l.time
|
|
622
|
+
});
|
|
623
|
+
i.set("type", "track_point"), i.set("trackId", l.id), i.set("data", l), i.setStyle(createPointStyle(e)), a.push(i), typeof l == "object" && Object.prototype.hasOwnProperty.call(l, "state") && createIconFeature(l);
|
|
624
|
+
}), routesSource.addFeatures(a), a.forEach((l) => {
|
|
625
|
+
const i = l.getProperties().data, c = createPointLabelOverlay(e, i);
|
|
626
|
+
mapInstance$1 == null || mapInstance$1.addOverlay(c);
|
|
627
|
+
}), createArrowFetaure(n, e), createIconPointFeature();
|
|
628
|
+
}, createPointLabelOverlay = (e, t) => {
|
|
629
|
+
const o = document.createElement("div");
|
|
630
|
+
o.className = "track-overlay-label", o.style.position = "relative", o.style.backgroundColor = "rgba(255,255,255,0.8)", o.style.border = `1px solid ${e}`, o.style.fontSize = "12px", o.innerHTML = `
|
|
631
|
+
<span>${t.time}</span>
|
|
632
|
+
<svg
|
|
633
|
+
style="position: absolute;left: -20px;top: 0;"
|
|
634
|
+
viewBox="0 0 20 20"
|
|
635
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
636
|
+
width="20"
|
|
637
|
+
height="20">
|
|
638
|
+
<line x1="0" y1="20"
|
|
639
|
+
x2="20" y2="0"
|
|
640
|
+
stroke="${e}"
|
|
641
|
+
stroke-width="1" />
|
|
642
|
+
`;
|
|
643
|
+
const n = new Overlay({
|
|
644
|
+
element: o,
|
|
645
|
+
position: fromLonLat(t.center),
|
|
646
|
+
positioning: "top-left",
|
|
647
|
+
offset: [20, -20],
|
|
648
|
+
className: "track-label-time-overlay"
|
|
649
|
+
});
|
|
650
|
+
return n.set("class", "track-label-overlay"), n;
|
|
651
|
+
}, removeAllLabel = () => {
|
|
652
|
+
const e = mapInstance$1 == null ? void 0 : mapInstance$1.getOverlays().getArray(), t = e == null ? void 0 : e.filter((o) => o.get("class") === "track-label-overlay");
|
|
653
|
+
t && t.length > 0 && t.forEach((o) => {
|
|
654
|
+
o.setPosition(void 0), o.setElement(void 0), mapInstance$1 == null || mapInstance$1.removeOverlay(o), o.dispose();
|
|
655
|
+
});
|
|
656
|
+
}, createPointStyle = (e) => [
|
|
657
|
+
new Style({
|
|
658
|
+
// 扩大交互热区
|
|
659
|
+
image: new CircleStyle({
|
|
660
|
+
stroke: new Stroke({ color: "rgba(0, 0, 0, 0.01)", width: 20 }),
|
|
661
|
+
radius: 3
|
|
662
|
+
})
|
|
663
|
+
}),
|
|
664
|
+
// 轨迹点样式
|
|
665
|
+
new Style({
|
|
666
|
+
image: new CircleStyle({
|
|
667
|
+
fill: new Fill({ color: e }),
|
|
668
|
+
stroke: new Stroke({ color: "#fff", width: 2 }),
|
|
669
|
+
radius: 3
|
|
670
|
+
})
|
|
671
|
+
})
|
|
672
|
+
//
|
|
673
|
+
// //文本框样式
|
|
674
|
+
// new Style({
|
|
675
|
+
// text: new Text({
|
|
676
|
+
// text: point.time,
|
|
677
|
+
// font: `500 ${labelConfig.fontSize}px ${labelConfig.fontFamily}`,
|
|
678
|
+
// textAlign: 'left',
|
|
679
|
+
// textBaseline: 'middle',
|
|
680
|
+
// fill: new Fill({ color: labelConfig.textColor }),
|
|
681
|
+
// backgroundFill: new Fill({
|
|
682
|
+
// color: labelConfig.bgColor,
|
|
683
|
+
// }),
|
|
684
|
+
// backgroundStroke: new Stroke({
|
|
685
|
+
// color: trackColor,
|
|
686
|
+
// width: 0.5
|
|
687
|
+
// }),
|
|
688
|
+
// padding: labelConfig.padding,
|
|
689
|
+
// offsetX: textX - boxTopLeft[0], // 转换为相对偏移
|
|
690
|
+
// offsetY: textY - boxTopLeft[1],
|
|
691
|
+
// }),
|
|
692
|
+
// zIndex:99,
|
|
693
|
+
// }),
|
|
694
|
+
// 连接线样式
|
|
695
|
+
// new Style({
|
|
696
|
+
// geometry: lineGeom, // 明确指定几何图形
|
|
697
|
+
// stroke: new Stroke({
|
|
698
|
+
// color: trackColor,
|
|
699
|
+
// width: Math.max(1, 1 / resolution),
|
|
700
|
+
// width: 1
|
|
701
|
+
// }),
|
|
702
|
+
// zIndex: 1 // 确保在点和信息框之间
|
|
703
|
+
// }),
|
|
704
|
+
//
|
|
705
|
+
// // 信息框背景
|
|
706
|
+
// new Style({
|
|
707
|
+
// geometry: boxGeom,
|
|
708
|
+
// fill: new Fill({
|
|
709
|
+
// color: labelConfig.bgColor
|
|
710
|
+
// }),
|
|
711
|
+
// stroke: new Stroke({
|
|
712
|
+
// color: trackColor,
|
|
713
|
+
// width: Math.max(0.5, 0.5 / resolution)
|
|
714
|
+
// }),
|
|
715
|
+
// zIndex: 2
|
|
716
|
+
// }),
|
|
717
|
+
// 文本样式
|
|
718
|
+
// new Style({
|
|
719
|
+
// geometry: new Point([textX, textY]),
|
|
720
|
+
// text: new Text({
|
|
721
|
+
// text: timeText,
|
|
722
|
+
// font: `${labelConfig.fontSize}px ${labelConfig.fontFamily}`,
|
|
723
|
+
// fill: new Fill({ color: labelConfig.textColor }),
|
|
724
|
+
// textAlign: 'left',
|
|
725
|
+
// textBaseline: 'middle',
|
|
726
|
+
// offsetX: 0,
|
|
727
|
+
// offsetY: 0,
|
|
728
|
+
// scale: Math.max(1, 1 / resolution),
|
|
729
|
+
// // backgroundFill: new Fill({
|
|
730
|
+
// // color: labelConfig.bgColor,
|
|
731
|
+
// // }),
|
|
732
|
+
// // backgroundStroke: new Stroke({
|
|
733
|
+
// // color: trackColor,
|
|
734
|
+
// // width: 0.5
|
|
735
|
+
// // }),
|
|
736
|
+
// padding: labelConfig.padding,
|
|
737
|
+
// }),
|
|
738
|
+
// zIndex: 3
|
|
739
|
+
// })
|
|
740
|
+
// new Style({
|
|
741
|
+
// geometry: lineGeom,
|
|
742
|
+
// stroke: new Stroke({
|
|
743
|
+
// color: trackColor,
|
|
744
|
+
// width: 1
|
|
745
|
+
// })
|
|
746
|
+
// }),
|
|
747
|
+
// 信息框样式(使用固定像素值的Text样式)
|
|
748
|
+
// new Style({
|
|
749
|
+
// text: new Text({
|
|
750
|
+
// text: timeText,
|
|
751
|
+
// font: `${FONT_SIZE}px Arial`,
|
|
752
|
+
// fill: new Fill({ color: '#333' }),
|
|
753
|
+
// backgroundFill: new Fill({
|
|
754
|
+
// color: 'rgba(255, 255, 255, 0.9)'
|
|
755
|
+
// }),
|
|
756
|
+
// backgroundStroke: new Stroke({
|
|
757
|
+
// color: 'rgba(0, 0, 0, 0.5)',
|
|
758
|
+
// width: 1
|
|
759
|
+
// }),
|
|
760
|
+
// padding: BOX_PADDING,
|
|
761
|
+
// offsetX: BOX_LEFT_OFFSET, // 固定30像素右偏移
|
|
762
|
+
// offsetY: -boxHeight, // 固定向上偏移框高度
|
|
763
|
+
// textAlign: 'left',
|
|
764
|
+
// textBaseline: 'top'
|
|
765
|
+
// })
|
|
766
|
+
// })
|
|
767
|
+
], createIconFeature = (e) => {
|
|
768
|
+
const t = new Feature({
|
|
769
|
+
//point.centerPoint
|
|
770
|
+
geometry: new Point([e.lon, e.lat]),
|
|
771
|
+
time: e.time
|
|
772
|
+
});
|
|
773
|
+
t.set("type", "track_icon");
|
|
774
|
+
const o = new Style({
|
|
775
|
+
text: new Text({
|
|
776
|
+
font: "Normal 22px map-iconfont",
|
|
777
|
+
text: getIconFont(dropletsIcon),
|
|
778
|
+
offsetY: -10,
|
|
779
|
+
fill: new Fill({
|
|
780
|
+
color: Number(e.state) === 0 ? stopColor : Number(e.state) === 1 ? slowColor : ""
|
|
781
|
+
})
|
|
782
|
+
}),
|
|
783
|
+
zIndex: 99
|
|
784
|
+
}), n = [];
|
|
785
|
+
Number(e.state) === 0 ? n.push(stopIconStyle) : Number(e.state) === 1 && n.push(slowIconStyle), n.push(o), t.setStyle(n), routesSource.addFeature(t);
|
|
786
|
+
}, createArrowFetaure = (e, t) => {
|
|
787
|
+
const o = e || [], n = e.length;
|
|
788
|
+
n || (o.push(trackList[0]), o.push(trackList[trackList.length - 1]));
|
|
789
|
+
for (let r = 0; r < n - 1; r++) {
|
|
790
|
+
let a;
|
|
791
|
+
const l = e[r], i = (e[r + 1].index + l.index) / 2;
|
|
792
|
+
if (i % 2 === 0)
|
|
793
|
+
a = trackList[i].centerPoint;
|
|
794
|
+
else {
|
|
795
|
+
const c = trackList[Math.floor(i)], d = trackList[Math.ceil(i)];
|
|
796
|
+
if (c && d) {
|
|
797
|
+
const [u, s] = c.centerPoint, [p, m] = d.centerPoint;
|
|
798
|
+
a = [(u + p) / 2, (s + m) / 2];
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if (a) {
|
|
802
|
+
const c = new Feature({
|
|
803
|
+
geometry: new Point(a)
|
|
804
|
+
});
|
|
805
|
+
c.set("type", "track_arrow"), c.setStyle(
|
|
806
|
+
new Style({
|
|
807
|
+
text: new Text({
|
|
808
|
+
font: "700 14px map-iconfont",
|
|
809
|
+
text: getIconFont(""),
|
|
810
|
+
fill: new Fill({ color: t }),
|
|
811
|
+
// 设置箭头旋转 角度转为弧度
|
|
812
|
+
rotation: getRotation(
|
|
813
|
+
e[r].center,
|
|
814
|
+
e[r + 1].center
|
|
815
|
+
) * (Math.PI / 180)
|
|
816
|
+
})
|
|
817
|
+
})
|
|
818
|
+
), routesSource == null || routesSource.addFeature(c);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}, setTrackViewCenter = (e) => {
|
|
822
|
+
var r;
|
|
823
|
+
const t = mapInstance$1.getView(), o = e ? routeFeatures.find((a) => a.getId() === e) : routeFeatures[0];
|
|
824
|
+
if (!o) return;
|
|
825
|
+
const n = (r = o == null ? void 0 : o.getGeometry()) == null ? void 0 : r.getExtent();
|
|
826
|
+
if (n != null && n.length)
|
|
827
|
+
try {
|
|
828
|
+
const a = buffer(n, Math.max(n[2] - n[0], n[3] - n[1]) * 0.02);
|
|
829
|
+
t.fit(a);
|
|
830
|
+
} catch (a) {
|
|
831
|
+
console.log(a);
|
|
832
|
+
}
|
|
833
|
+
}, createIconPointFeature = () => {
|
|
834
|
+
const e = "", t = "#fcdc3f", o = "#ff0000";
|
|
835
|
+
(trackList.length < 2 ? [trackList[0]] : [trackList[0], trackList[trackList.length - 1]]).forEach((r) => {
|
|
836
|
+
const a = new Feature({
|
|
837
|
+
geometry: new Point(r.centerPoint)
|
|
838
|
+
});
|
|
839
|
+
a.set("type", "track_begin"), a.set("data", r);
|
|
840
|
+
const l = r.index === 0 && trackList.length >= 2 ? t : o;
|
|
841
|
+
a.setStyle(
|
|
842
|
+
new Style({
|
|
843
|
+
text: new Text({
|
|
844
|
+
font: "Normal 14px map-iconfont",
|
|
845
|
+
text: getIconFont(e),
|
|
846
|
+
fill: new Fill({ color: l })
|
|
847
|
+
}),
|
|
848
|
+
zIndex: 101
|
|
849
|
+
})
|
|
850
|
+
), routesSource.addFeature(a);
|
|
851
|
+
});
|
|
852
|
+
}, geoMarkerStyle = new Style({
|
|
853
|
+
text: new Text({
|
|
854
|
+
font: "700 20px map-iconfont",
|
|
855
|
+
text: getIconFont(""),
|
|
856
|
+
fill: new Fill({ color: "#ff0000" }),
|
|
857
|
+
rotation: 0
|
|
858
|
+
// 初始旋转角度
|
|
859
|
+
})
|
|
860
|
+
}), playShipTrack = (e, t) => {
|
|
861
|
+
handlePlay(String(e), t);
|
|
862
|
+
}, removeAllTrackLayer = () => {
|
|
863
|
+
showTracks = [], allTracks = {}, routesSource == null || routesSource.clear();
|
|
864
|
+
}, closeTrack = (e = !1) => {
|
|
865
|
+
routeLayer == null || routeLayer.setVisible(!1), e && removeAllTrackLayer(), stopAnimation();
|
|
866
|
+
}, handlePlay = (e, t) => {
|
|
867
|
+
const o = allTracks[String(e)];
|
|
868
|
+
playAnimation(o == null ? void 0 : o.map((n) => [n.lon, n.lat]), t);
|
|
869
|
+
}, moveFeature = (e, t) => {
|
|
870
|
+
var s, p;
|
|
871
|
+
const o = Number(50 * t), n = ((s = e.frameState) == null ? void 0 : s.time) ?? Date.now(), r = n - lastTime;
|
|
872
|
+
if (distance = (distance + o * r / 1e6) % 2, lastTime = n, distance >= 1) {
|
|
873
|
+
stopAnimation();
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
const a = linePath.getCoordinateAt(
|
|
877
|
+
distance > 1 ? 2 - distance : distance
|
|
878
|
+
), l = linePath.getCoordinateAt(
|
|
879
|
+
distance > 1 ? distance - 0.01 : distance
|
|
880
|
+
), i = linePath.getCoordinateAt(
|
|
881
|
+
distance > 1 ? 2 - distance : distance + 0.01
|
|
882
|
+
), d = getRotation(
|
|
883
|
+
mercatorToLonLat(l, "array"),
|
|
884
|
+
mercatorToLonLat(i, "array")
|
|
885
|
+
) * Math.PI / 180;
|
|
886
|
+
(p = geoMarkerStyle.getText()) == null || p.setRotation(d), position.setCoordinates(a);
|
|
887
|
+
const u = getVectorContext(e);
|
|
888
|
+
u.setStyle(geoMarkerStyle), u.drawGeometry(position), mapInstance$1 == null || mapInstance$1.render();
|
|
889
|
+
}, startAnimation = () => {
|
|
890
|
+
var e;
|
|
891
|
+
trackAnimating = !0, lastTime = Date.now(), distance = 0, position = ((e = startMarker.getGeometry()) == null ? void 0 : e.clone()) || new Point([0, 0]), moveFeatureHandler && (vectorLayer$3 == null || vectorLayer$3.on("postrender", moveFeatureHandler)), geoMarker == null || geoMarker.setGeometry(void 0);
|
|
892
|
+
}, stopAnimation = () => {
|
|
893
|
+
trackAnimating && (trackAnimating = !1, geoMarker == null || geoMarker.setGeometry(void 0), moveFeatureHandler && vectorLayer$3 && vectorLayer$3.un("postrender", moveFeatureHandler), vectorLayer$3 && (mapInstance$1 == null || mapInstance$1.removeLayer(vectorLayer$3)), vectorLayer$3 = null, geoMarker = null);
|
|
894
|
+
}, playAnimation = (e, t) => {
|
|
895
|
+
trackAnimating && stopAnimation(), polyline = new Polyline({
|
|
896
|
+
factor: 1e6
|
|
897
|
+
}).writeGeometry(new LineString(e)), linePath = new Polyline({
|
|
898
|
+
factor: 1e6
|
|
899
|
+
}).readGeometry(polyline, {
|
|
900
|
+
dataProjection: projection.data,
|
|
901
|
+
featureProjection: projection.mercator
|
|
902
|
+
}), startMarker = new Feature({
|
|
903
|
+
type: "icon",
|
|
904
|
+
geometry: new Point(linePath.getFirstCoordinate())
|
|
905
|
+
});
|
|
906
|
+
const o = startMarker.getGeometry();
|
|
907
|
+
position = o ? o.clone() : new Point([0, 0]), geoMarker = new Feature({
|
|
908
|
+
type: "geoMarker",
|
|
909
|
+
style: geoMarkerStyle,
|
|
910
|
+
geometry: position
|
|
911
|
+
}), vectorLayer$3 = new VectorLayer({
|
|
912
|
+
source: new VectorSource({
|
|
913
|
+
features: [geoMarker]
|
|
914
|
+
})
|
|
915
|
+
}), mapInstance$1 == null || mapInstance$1.addLayer(vectorLayer$3), moveFeatureHandler = (n) => moveFeature(n, t), startAnimation();
|
|
916
|
+
}, getRotation = (e, t, o) => {
|
|
917
|
+
function n(s) {
|
|
918
|
+
return 180 * (s % (2 * Math.PI)) / Math.PI;
|
|
919
|
+
}
|
|
920
|
+
function r(s) {
|
|
921
|
+
return s % 360 * Math.PI / 180;
|
|
922
|
+
}
|
|
923
|
+
function a(s) {
|
|
924
|
+
var p;
|
|
925
|
+
if (!s) throw new Error("Coordinate is required");
|
|
926
|
+
if (!Array.isArray(s)) {
|
|
927
|
+
if ((s == null ? void 0 : s.type) === "Feature" && (s == null ? void 0 : s.geometry) !== null && ((p = s == null ? void 0 : s.geometry) == null ? void 0 : p.type) === "Point")
|
|
928
|
+
return s == null ? void 0 : s.geometry.coordinates;
|
|
929
|
+
if (s.type === "Point") return (s == null ? void 0 : s.coordinates) || [];
|
|
930
|
+
}
|
|
931
|
+
if (Array.isArray(s) && s.length >= 2 && !Array.isArray(s[0]) && !Array.isArray(s[1]))
|
|
932
|
+
return s;
|
|
933
|
+
throw new Error(
|
|
934
|
+
"Coordinate must be GeoJSON Point or an Array of numbers"
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
function l(s, p, m = {}) {
|
|
938
|
+
if (m.final)
|
|
939
|
+
return function(k, M) {
|
|
940
|
+
return (l(M, k) + 180) % 360;
|
|
941
|
+
}(s, p);
|
|
942
|
+
const g = a(s), y = a(p), v = r(g[0]), w = r(y[0]), L = r(g[1]), f = r(y[1]), T = Math.sin(w - v) * Math.cos(f), E = Math.cos(L) * Math.sin(f) - Math.sin(L) * Math.cos(f) * Math.cos(w - v);
|
|
943
|
+
return n(Math.atan2(T, E));
|
|
944
|
+
}
|
|
945
|
+
function i(s) {
|
|
946
|
+
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
947
|
+
}
|
|
948
|
+
function c(s, p = {}, m = {}) {
|
|
949
|
+
return s || console.log("Coordinates are required"), Array.isArray(s) || console.log("Coordinates must be an Array"), s.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!i(s[0]) || !i(s[1])) && console.log("Coordinates must contain numbers"), d({ type: "Point", coordinates: s }, p, m);
|
|
950
|
+
}
|
|
951
|
+
function d(s, p = {}, m = {}) {
|
|
952
|
+
const g = {
|
|
953
|
+
type: "Feature",
|
|
954
|
+
id: "",
|
|
955
|
+
properties: {},
|
|
956
|
+
bbox: {},
|
|
957
|
+
geometry: {}
|
|
958
|
+
};
|
|
959
|
+
return m.id !== void 0 && (g.id = m.id), m.bbox && (g.bbox = m.bbox), g.properties = p, g.geometry = s, g;
|
|
960
|
+
}
|
|
961
|
+
const u = l(c(e), c(t), o);
|
|
962
|
+
return u < 0 ? 360 + u : u;
|
|
963
|
+
}, PORT_LAYER_CLASS_NAME = "zh-map-port-layer";
|
|
964
|
+
let vectorLayer$2, vectorSource$2;
|
|
965
|
+
const renderPortList = (e) => {
|
|
966
|
+
var o;
|
|
967
|
+
if (!e || e.length === 0) return;
|
|
968
|
+
const t = getZoom();
|
|
969
|
+
vectorSource$2 || (vectorSource$2 = new VectorSource()), e.forEach((n) => {
|
|
970
|
+
if ((selectedPortFeature == null ? void 0 : selectedPortFeature.get("portData").id) === n.id) return;
|
|
971
|
+
const [r, a] = n.latLon.split(","), l = new Feature({
|
|
972
|
+
geometry: new Point(fromLonLat([Number(r), Number(a)]))
|
|
973
|
+
});
|
|
974
|
+
l.setStyle(setPortStyle(n, t, !1)), l.set("portData", n), vectorSource$2.addFeature(l);
|
|
975
|
+
}), vectorLayer$2 || (vectorLayer$2 = new VectorLayer({
|
|
976
|
+
className: PORT_LAYER_CLASS_NAME,
|
|
977
|
+
source: vectorSource$2,
|
|
978
|
+
zIndex: 100
|
|
979
|
+
}), (o = getInstall()) == null || o.addLayer(vectorLayer$2));
|
|
980
|
+
}, setPortStyle = (e, t, o) => {
|
|
981
|
+
const n = (a) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
982
|
+
<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="${a}"/>
|
|
983
|
+
<g clip-path="url(#clip0_10059_122082)">
|
|
984
|
+
<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"/>
|
|
985
|
+
</g>
|
|
986
|
+
<defs>
|
|
987
|
+
<clipPath id="clip0_10059_122082">
|
|
988
|
+
<rect width="26" height="26" fill="white" transform="translate(10 8)"/>
|
|
989
|
+
</clipPath>
|
|
990
|
+
</defs>
|
|
991
|
+
</svg>
|
|
992
|
+
`, r = () => `data:image/svg+xml;utf8,${encodeURIComponent(n(o ? "#FF5733" : "#3370FF"))}`;
|
|
993
|
+
return new Style({
|
|
994
|
+
text: new Text({
|
|
995
|
+
text: e.shortName,
|
|
996
|
+
font: "12px sans-serif",
|
|
997
|
+
fill: new Fill({
|
|
998
|
+
color: o ? "#ffffff" : "#000000"
|
|
999
|
+
}),
|
|
1000
|
+
backgroundFill: new Fill({
|
|
1001
|
+
color: o ? "#FF5733" : "#FFFFFF"
|
|
1002
|
+
}),
|
|
1003
|
+
offsetY: 30
|
|
1004
|
+
}),
|
|
1005
|
+
image: new Icon({
|
|
1006
|
+
src: r(),
|
|
1007
|
+
scale: 0.5 * t / 10
|
|
1008
|
+
})
|
|
1009
|
+
});
|
|
1010
|
+
}, clearPortList = () => {
|
|
1011
|
+
if (selectedPortFeature) {
|
|
1012
|
+
console.log("清除非选中的港口");
|
|
1013
|
+
const e = selectedPortFeature.get("portData").id;
|
|
1014
|
+
vectorSource$2.getFeatures().forEach((t) => {
|
|
1015
|
+
t.get("portData").id !== e && vectorSource$2.removeFeature(t);
|
|
1016
|
+
});
|
|
1017
|
+
} else
|
|
1018
|
+
console.log("清除所有港口"), vectorSource$2.clear();
|
|
1019
|
+
};
|
|
1020
|
+
let selectedPortFeature = null;
|
|
1021
|
+
const selectedPort = (e) => {
|
|
1022
|
+
clearPrevSelectedPort(), addSelectedPortStyle(e);
|
|
1023
|
+
}, clearPrevSelectedPort = () => {
|
|
1024
|
+
if (selectedPortFeature) {
|
|
1025
|
+
const e = selectedPortFeature.get("portData"), t = getZoom();
|
|
1026
|
+
selectedPortFeature.setStyle(setPortStyle(e, t, !1));
|
|
1027
|
+
}
|
|
1028
|
+
}, addSelectedPortStyle = (e) => {
|
|
1029
|
+
const t = e.get("portData"), o = getZoom();
|
|
1030
|
+
selectedPortFeature = e, e.setStyle(setPortStyle(t, o, !0));
|
|
1031
|
+
}, handlePortHover = (e) => {
|
|
1032
|
+
const t = getInstall(), o = t.forEachFeatureAtPixel(e, (n) => n);
|
|
1033
|
+
o && o.get("portData") && (t.getTargetElement().style.cursor = "pointer");
|
|
1034
|
+
}, disableDoubleClickZoom = () => {
|
|
1035
|
+
getInstall().getInteractions().forEach((t) => {
|
|
1036
|
+
t instanceof DoubleClickZoom && t.setActive(!1);
|
|
1037
|
+
});
|
|
1038
|
+
}, enableDoubleClickZoom = () => {
|
|
1039
|
+
getInstall().getInteractions().forEach((t) => {
|
|
1040
|
+
t instanceof DoubleClickZoom && t.setActive(!0);
|
|
1041
|
+
});
|
|
1042
|
+
}, props = ref(), setProps = (e) => {
|
|
1043
|
+
props.value = e;
|
|
1044
|
+
}, getProps = () => props.value, measureHistory = ref([]), unit = ref("km"), setUnit = (e) => {
|
|
1045
|
+
unit.value = e;
|
|
1046
|
+
};
|
|
1047
|
+
let helpTooltipElement$1;
|
|
1048
|
+
const state = ref(!1), open$1 = () => {
|
|
1049
|
+
initMapLayer(), disableDoubleClickZoom(), changeCursor("pointer");
|
|
1050
|
+
const e = getInstall();
|
|
1051
|
+
e.on("pointermove", pointerMoveHandler$1), e.getViewport().addEventListener("mouseout", () => {
|
|
1052
|
+
helpTooltipElement$1 && helpTooltipElement$1.classList.add("hidden");
|
|
1053
|
+
}), addInteraction(), state.value = !0;
|
|
1054
|
+
};
|
|
1055
|
+
let vectorSource$1, vectorLayer$1;
|
|
1056
|
+
const initMapLayer = () => {
|
|
1057
|
+
vectorSource$1 = new VectorSource(), vectorLayer$1 = new VectorLayer({
|
|
1058
|
+
source: vectorSource$1,
|
|
1059
|
+
zIndex: 1e3,
|
|
1060
|
+
style: {
|
|
1061
|
+
"fill-color": "rgba(255, 255, 255, 0.2)",
|
|
1062
|
+
"stroke-color": "#ffcc33",
|
|
1063
|
+
"stroke-width": 2,
|
|
1064
|
+
"circle-radius": 7,
|
|
1065
|
+
"circle-fill-color": "#ffcc33"
|
|
1066
|
+
}
|
|
1067
|
+
}), getInstall().addLayer(vectorLayer$1);
|
|
1068
|
+
};
|
|
1069
|
+
let sketch$1, helpTooltip;
|
|
1070
|
+
const pointerMoveHandler$1 = (e) => {
|
|
1071
|
+
if (e.dragging)
|
|
1072
|
+
return;
|
|
1073
|
+
let t = "点击选择起点";
|
|
1074
|
+
sketch$1 && (t = "单击继续,双击结束"), helpTooltipElement$1 && (helpTooltipElement$1.innerHTML = t, helpTooltip.setPosition(e.coordinate), helpTooltipElement$1.classList.remove("hidden"));
|
|
1075
|
+
}, changeCursor = (e) => {
|
|
1076
|
+
getInstall().getTargetElement().style.cursor = e;
|
|
1077
|
+
};
|
|
1078
|
+
let draw$1;
|
|
1079
|
+
const addInteraction = () => {
|
|
1080
|
+
draw$1 = new Draw({
|
|
1081
|
+
source: vectorSource$1,
|
|
1082
|
+
type: "LineString",
|
|
1083
|
+
style: new Style({
|
|
1084
|
+
fill: new Fill({
|
|
1085
|
+
color: "rgba(255, 255, 255, 0.2)"
|
|
1086
|
+
}),
|
|
1087
|
+
stroke: new Stroke({
|
|
1088
|
+
color: "rgba(255,204,51)",
|
|
1089
|
+
lineDash: [10, 10],
|
|
1090
|
+
width: 2
|
|
1091
|
+
}),
|
|
1092
|
+
image: new CircleStyle({
|
|
1093
|
+
radius: 5,
|
|
1094
|
+
stroke: new Stroke({
|
|
1095
|
+
color: "rgba(0, 0, 0, 0.7)"
|
|
1096
|
+
}),
|
|
1097
|
+
fill: new Fill({
|
|
1098
|
+
color: "rgba(255, 255, 255, 0.2)"
|
|
1099
|
+
})
|
|
1100
|
+
})
|
|
1101
|
+
}),
|
|
1102
|
+
// 添加条件函数,判断是否应该出发点绘制
|
|
1103
|
+
condition: (t) => t.originalEvent.target.tagName !== "DIV"
|
|
1104
|
+
}), getInstall().addInteraction(draw$1), createMeasureTooltip$1(), createHelpTooltip$1();
|
|
1105
|
+
let e;
|
|
1106
|
+
draw$1.on("drawstart", function(t) {
|
|
1107
|
+
var n;
|
|
1108
|
+
sketch$1 = t.feature, sketch$1.set("randomId", generateRandomId());
|
|
1109
|
+
let o;
|
|
1110
|
+
e = (n = sketch$1.getGeometry()) == null ? void 0 : n.on("change", function(r) {
|
|
1111
|
+
const a = r.target, l = computedDistance(a, unit.value);
|
|
1112
|
+
o = a.getLastCoordinate(), measureTooltipElement$1 && l && (measureTooltipElement$1.innerHTML = l), measureTooltip$1.setPosition(o);
|
|
1113
|
+
});
|
|
1114
|
+
}), draw$1.on("drawend", function() {
|
|
1115
|
+
var t, o, n;
|
|
1116
|
+
if (measureTooltipElement$1 && (measureTooltipElement$1.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), measureTooltipElement$1 != null && measureTooltipElement$1.innerHTML) {
|
|
1117
|
+
const r = (sketch$1 == null ? void 0 : sketch$1.get("randomId")) || generateRandomId();
|
|
1118
|
+
measureHistory.value.push({ id: r, value: measureTooltipElement$1 == null ? void 0 : measureTooltipElement$1.innerHTML }), measureTooltipElement$1.innerHTML = `${measureTooltipElement$1.innerHTML}<div class="ol-tooltip-delete-button" data-id="${r}"><i class="map-iconfont icon-delete"></i></div>`;
|
|
1119
|
+
}
|
|
1120
|
+
(t = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || t.addEventListener("click", (r) => {
|
|
1121
|
+
var l;
|
|
1122
|
+
r.preventDefault(), r.stopPropagation();
|
|
1123
|
+
const a = (l = r.target) == null ? void 0 : l.getAttribute("data-id");
|
|
1124
|
+
a && deleteLine(a);
|
|
1125
|
+
}), measureTooltip$1.setOffset([0, -7]), sketch$1 = null, measureTooltipElement$1 = null, createMeasureTooltip$1(), e && unByKey(e), (o = getProps()) != null && o.lineDrawEnd && ((n = getProps()) == null || n.lineDrawEnd(measureHistory.value));
|
|
1126
|
+
});
|
|
1127
|
+
}, generateRandomId = () => Math.random().toString(36).substring(2, 9);
|
|
1128
|
+
let measureTooltipElement$1, measureTooltip$1;
|
|
1129
|
+
const createMeasureTooltip$1 = () => {
|
|
1130
|
+
measureTooltipElement$1 != null && measureTooltipElement$1.parentNode && measureTooltipElement$1.parentNode.removeChild(measureTooltipElement$1), measureTooltipElement$1 = document.createElement("div"), measureTooltipElement$1.className = "ol-tooltip ol-tooltip-measure", measureTooltip$1 = new Overlay({
|
|
1131
|
+
element: measureTooltipElement$1,
|
|
1132
|
+
offset: [0, -15],
|
|
1133
|
+
positioning: "bottom-center",
|
|
1134
|
+
stopEvent: !1,
|
|
1135
|
+
insertFirst: !1
|
|
1136
|
+
}), getInstall().addOverlay(measureTooltip$1);
|
|
1137
|
+
}, createHelpTooltip$1 = () => {
|
|
1138
|
+
helpTooltipElement$1 != null && helpTooltipElement$1.parentNode && helpTooltipElement$1.parentNode.removeChild(helpTooltipElement$1), helpTooltipElement$1 = document.createElement("div"), helpTooltipElement$1.className = "ol-tooltip hidden", helpTooltip = new Overlay({
|
|
1139
|
+
element: helpTooltipElement$1,
|
|
1140
|
+
offset: [15, 0],
|
|
1141
|
+
positioning: "center-left"
|
|
1142
|
+
}), getInstall().addOverlay(helpTooltip);
|
|
1143
|
+
}, close$1 = () => {
|
|
1144
|
+
measureHistory.value.forEach((e, t) => {
|
|
1145
|
+
var r, a;
|
|
1146
|
+
const o = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
|
|
1147
|
+
o[t] && ((a = (r = o[t]) == null ? void 0 : r.parentNode) == null || a.removeChild(o[t]));
|
|
1148
|
+
const n = vectorSource$1.getFeatures();
|
|
1149
|
+
n[t] && vectorSource$1.removeFeature(n[t]);
|
|
1150
|
+
}), removeInteraction(), enableDoubleClickZoom(), state.value = !1;
|
|
1151
|
+
}, deleteLine = (e) => {
|
|
1152
|
+
var o, n, r, a;
|
|
1153
|
+
const t = measureHistory.value.findIndex((l) => l.id === e);
|
|
1154
|
+
if (t !== -1) {
|
|
1155
|
+
measureHistory.value.splice(t, 1);
|
|
1156
|
+
const l = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
|
|
1157
|
+
l[t] && ((n = (o = l[t]) == null ? void 0 : o.parentNode) == null || n.removeChild(l[t]));
|
|
1158
|
+
const i = vectorSource$1.getFeatures();
|
|
1159
|
+
i[t] && vectorSource$1.removeFeature(i[t]);
|
|
1160
|
+
}
|
|
1161
|
+
(r = getProps()) != null && r.lineDrawEnd && ((a = getProps()) == null || a.lineDrawEnd(measureHistory.value));
|
|
1162
|
+
}, computedDistance = (e, t) => {
|
|
1163
|
+
const n = getLength(e);
|
|
1164
|
+
let r = "";
|
|
1165
|
+
switch (t) {
|
|
1166
|
+
case "m":
|
|
1167
|
+
r = `${Math.round(n * 100) / 100} m`;
|
|
1168
|
+
break;
|
|
1169
|
+
case "km":
|
|
1170
|
+
r = `${Math.round(n / 1e3 * 100) / 100} km`;
|
|
1171
|
+
break;
|
|
1172
|
+
case "nm":
|
|
1173
|
+
r = `${Math.round(n / 1.852 * 100) / 100} nm`;
|
|
1174
|
+
break;
|
|
1175
|
+
}
|
|
1176
|
+
return r;
|
|
1177
|
+
}, removeInteraction = () => {
|
|
1178
|
+
measureHistory.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((t) => {
|
|
1179
|
+
var o;
|
|
1180
|
+
(o = t == null ? void 0 : t.parentNode) == null || o.removeChild(t);
|
|
1181
|
+
}), vectorSource$1.clear();
|
|
1182
|
+
const e = getInstall();
|
|
1183
|
+
if (draw$1) {
|
|
1184
|
+
const t = e.getInteractions().getArray().find((o) => getUid(o) === getUid(draw$1));
|
|
1185
|
+
t && e.removeInteraction(t);
|
|
1186
|
+
}
|
|
1187
|
+
e.removeLayer(vectorLayer$1), helpTooltipElement$1 != null && helpTooltipElement$1.parentNode && helpTooltipElement$1.parentNode.removeChild(helpTooltipElement$1), measureTooltipElement$1 != null && measureTooltipElement$1.parentNode && measureTooltipElement$1.parentNode.removeChild(measureTooltipElement$1);
|
|
1188
|
+
}, getState = () => state.value, drawLine = {
|
|
1189
|
+
open: open$1,
|
|
1190
|
+
close: close$1,
|
|
1191
|
+
deleteLine,
|
|
1192
|
+
setUnit,
|
|
1193
|
+
getState
|
|
1194
|
+
}, mapInstance = ref(), getInstall = () => mapInstance.value, getView = () => getInstall().getView(), getZoom = () => {
|
|
1195
|
+
var e;
|
|
1196
|
+
return (e = getView()) == null ? void 0 : e.getZoom();
|
|
1197
|
+
}, setZoom = (e) => {
|
|
1198
|
+
var t;
|
|
1199
|
+
(t = getView()) == null || t.setZoom(e);
|
|
1200
|
+
}, setCenter = (e, t) => {
|
|
1201
|
+
var o;
|
|
1202
|
+
(o = getView()) == null || o.setCenter(fromLonLat([e, t]));
|
|
1203
|
+
}, getCenter = () => {
|
|
1204
|
+
var t;
|
|
1205
|
+
const e = (t = getView()) == null ? void 0 : t.getCenter();
|
|
1206
|
+
return toLonLat(e);
|
|
1207
|
+
}, getSize = () => {
|
|
1208
|
+
var e;
|
|
1209
|
+
return (e = getInstall()) == null ? void 0 : e.getSize();
|
|
1210
|
+
}, BASE_LAYER_MAP = new Map$2(), initMap = (e) => {
|
|
1211
|
+
setBaseLayerMap(e);
|
|
1212
|
+
const t = {
|
|
1213
|
+
zoom: e.zoom,
|
|
1214
|
+
center: fromLonLat(e.center),
|
|
1215
|
+
minZoom: MAP_ZOOM.min,
|
|
1216
|
+
maxZoom: MAP_ZOOM.max,
|
|
1217
|
+
constrainResolution: !0,
|
|
1218
|
+
enableRotation: !1,
|
|
1219
|
+
multiWorld: !0
|
|
1220
|
+
}, o = new Map$2({
|
|
1221
|
+
target: "map",
|
|
1222
|
+
layers: [
|
|
1223
|
+
BASE_LAYER_MAP.get("vectorTile"),
|
|
1224
|
+
BASE_LAYER_MAP.get("vectorTileMark"),
|
|
1225
|
+
BASE_LAYER_MAP.get("satelliteImgTile"),
|
|
1226
|
+
BASE_LAYER_MAP.get("satelliteImgTileMark")
|
|
1227
|
+
],
|
|
1228
|
+
view: new View(t)
|
|
1229
|
+
});
|
|
1230
|
+
mapInstance.value = o, setBaseMapEvent(o, e);
|
|
1231
|
+
}, setBaseLayerMap = (e) => {
|
|
1232
|
+
BASE_LAYER_MAP.set("vectorTile", new TileLayer({
|
|
1233
|
+
source: new XYZ({ url: BASE_MAP_LINK.vectorTile }),
|
|
1234
|
+
visible: e.layerType === "vector",
|
|
1235
|
+
zIndex: 0,
|
|
1236
|
+
preload: 1,
|
|
1237
|
+
className: "vector"
|
|
1238
|
+
})), BASE_LAYER_MAP.set("vectorTileMark", new TileLayer({
|
|
1239
|
+
source: new XYZ({ url: BASE_MAP_LINK.vectorTileMark }),
|
|
1240
|
+
visible: e.layerType === "vector",
|
|
1241
|
+
zIndex: 1,
|
|
1242
|
+
preload: 1,
|
|
1243
|
+
className: "vector"
|
|
1244
|
+
})), BASE_LAYER_MAP.set("satelliteImgTile", new TileLayer({
|
|
1245
|
+
source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTile }),
|
|
1246
|
+
visible: e.layerType === "satellite",
|
|
1247
|
+
zIndex: 0,
|
|
1248
|
+
preload: 1,
|
|
1249
|
+
className: "satellite"
|
|
1250
|
+
})), BASE_LAYER_MAP.set("satelliteImgTileMark", new TileLayer({
|
|
1251
|
+
source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTileMark }),
|
|
1252
|
+
visible: e.layerType === "satellite",
|
|
1253
|
+
zIndex: 1,
|
|
1254
|
+
preload: 1,
|
|
1255
|
+
className: "satellite"
|
|
1256
|
+
})), BASE_LAYER_MAP.set("greenMark", new TileLayer({
|
|
1257
|
+
source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
|
|
1258
|
+
visible: e.showGreenLayer,
|
|
1259
|
+
zIndex: 2,
|
|
1260
|
+
className: "greenTile"
|
|
1261
|
+
}));
|
|
1262
|
+
}, setBaseMapEvent = (e, t) => {
|
|
1263
|
+
e.on("moveend", () => {
|
|
1264
|
+
var n;
|
|
1265
|
+
const o = getZoom();
|
|
1266
|
+
(n = t.mapMoveEnd) == null || n.call(t, o), reRenderTrackLine();
|
|
1267
|
+
}), e.on("pointermove", (o) => {
|
|
1268
|
+
const n = e.getEventPixel(o.originalEvent), r = e.forEachFeatureAtPixel(n, (a) => a);
|
|
1269
|
+
handleShipMapEvent(r, "hover"), r && (handleTrackMapEvent(r, "hover", o), handlePortHover(n));
|
|
1270
|
+
}), e.on("click", debounce((o) => {
|
|
1271
|
+
if (console.log("1", drawLine.getState()), drawLine.getState()) return;
|
|
1272
|
+
const n = e.getEventPixel(o.originalEvent), r = e.forEachFeatureAtPixel(
|
|
1273
|
+
n,
|
|
1274
|
+
(a) => {
|
|
1275
|
+
if (a != null && a.get("shipData") || a != null && a.get("portData"))
|
|
1276
|
+
return a;
|
|
1277
|
+
}
|
|
1278
|
+
);
|
|
1279
|
+
if (console.log("2", r), !!r) {
|
|
1280
|
+
if (o.preventDefault(), o.stopPropagation(), r.get("shipData"))
|
|
1281
|
+
handleShipMapEvent(r, "click", t == null ? void 0 : t.selectShip);
|
|
1282
|
+
else if (r.get("portData")) {
|
|
1283
|
+
const a = r.get("portData");
|
|
1284
|
+
selectedPort(r), t == null || t.selectPort(String(a == null ? void 0 : a.id));
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}, 150));
|
|
1288
|
+
}, _hoisted_1$1 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1289
|
+
__name: "scaleLine",
|
|
1290
|
+
setup(e, { expose: t }) {
|
|
1291
|
+
return t({
|
|
1292
|
+
setScaleLine: (n) => {
|
|
1293
|
+
n || (n = "metric");
|
|
1294
|
+
const r = new ScaleLine$1({
|
|
1295
|
+
units: n
|
|
1296
|
+
}), a = document.getElementById("scale-line-container");
|
|
1297
|
+
a && (r.setTarget(a), getInstall().addControl(r));
|
|
1298
|
+
}
|
|
1299
|
+
}), (n, r) => (openBlock(), createElementBlock("div", _hoisted_1$1));
|
|
1300
|
+
}
|
|
1301
|
+
}), ScaleLine = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-31ff8293"]]), _hoisted_1 = { class: "zoom" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1302
|
+
__name: "zoomControl",
|
|
1303
|
+
setup(e) {
|
|
1304
|
+
const t = inject("mapInstance"), o = () => {
|
|
1305
|
+
if (t != null && t.value) {
|
|
1306
|
+
const r = getZoom();
|
|
1307
|
+
if (!r) return;
|
|
1308
|
+
setZoom(r + 1);
|
|
1309
|
+
}
|
|
1310
|
+
}, n = () => {
|
|
1311
|
+
if (t != null && t.value) {
|
|
1312
|
+
const r = getZoom();
|
|
1313
|
+
if (!r) return;
|
|
1314
|
+
setZoom(r - 1);
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
return (r, a) => (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
1318
|
+
createElementVNode("div", {
|
|
1319
|
+
class: "button big-button",
|
|
1320
|
+
onClick: o
|
|
1321
|
+
}, " + "),
|
|
1322
|
+
createElementVNode("div", {
|
|
1323
|
+
class: "button small-button",
|
|
1324
|
+
onClick: n
|
|
1325
|
+
}, " - ")
|
|
1326
|
+
]));
|
|
1327
|
+
}
|
|
1328
|
+
}), ZoomControl = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-37968fef"]]), getLayers = () => {
|
|
1329
|
+
var e;
|
|
1330
|
+
return (e = getInstall()) == null ? void 0 : e.getLayers();
|
|
1331
|
+
}, layerType = ref("vector"), getShowLayerType = () => layerType.value, setShowLayerType = (e) => {
|
|
1332
|
+
layerType.value = e;
|
|
1333
|
+
const t = getLayers();
|
|
1334
|
+
t && t.getArray().forEach((o) => {
|
|
1335
|
+
o.setVisible(o.className_ === e);
|
|
1336
|
+
});
|
|
1337
|
+
}, showGreenTile = ref(), getGreenTileVisible = () => showGreenTile.value, setGreenTileVisible = (e) => {
|
|
1338
|
+
if (e !== showGreenTile.value) {
|
|
1339
|
+
if (e) {
|
|
1340
|
+
const t = getLayers();
|
|
1341
|
+
if (!t.getArray().find((n) => n.className_ === "greenTile")) {
|
|
1342
|
+
const n = new TileLayer({
|
|
1343
|
+
source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
|
|
1344
|
+
visible: e,
|
|
1345
|
+
zIndex: 2,
|
|
1346
|
+
className: "greenTile"
|
|
1347
|
+
});
|
|
1348
|
+
t.push(n);
|
|
1349
|
+
}
|
|
1350
|
+
} else {
|
|
1351
|
+
const t = getLayers(), o = t.getArray().find((n) => n.className_ === "greenTile");
|
|
1352
|
+
o && t.remove(o);
|
|
1353
|
+
}
|
|
1354
|
+
showGreenTile.value = e;
|
|
1355
|
+
}
|
|
1356
|
+
}, open = () => {
|
|
1357
|
+
initLayer(), initDraw(), createMeasureTooltip(), createHelpTooltip();
|
|
1358
|
+
};
|
|
1359
|
+
let vectorLayer = null, vectorSource = null;
|
|
1360
|
+
const initLayer = () => {
|
|
1361
|
+
if (vectorLayer || vectorSource) return;
|
|
1362
|
+
const e = new VectorSource(), t = new VectorLayer({
|
|
1363
|
+
source: e,
|
|
1364
|
+
style: new Style({
|
|
1365
|
+
stroke: new Stroke({
|
|
1366
|
+
color: "#fbcc33",
|
|
1367
|
+
width: 2
|
|
1368
|
+
})
|
|
1369
|
+
})
|
|
1370
|
+
});
|
|
1371
|
+
vectorLayer = t, vectorSource = e;
|
|
1372
|
+
const o = getInstall();
|
|
1373
|
+
o.on("pointermove", pointerMoveHandler), o.addLayer(t), o.on(["dblclick"], function(n) {
|
|
1374
|
+
draw && (n.stopPropagation(), n.preventDefault());
|
|
1375
|
+
});
|
|
1376
|
+
};
|
|
1377
|
+
let sketch;
|
|
1378
|
+
const pointerMoveHandler = (e) => {
|
|
1379
|
+
if (e.dragging) return;
|
|
1380
|
+
const t = sketch ? "单击继续,双击结束" : "点击选择起点";
|
|
1381
|
+
helpTooltipElement && (helpTooltipElement.innerHTML = t, tipOverlay.setPosition(e.coordinate));
|
|
1382
|
+
};
|
|
1383
|
+
let draw;
|
|
1384
|
+
const initDraw = () => {
|
|
1385
|
+
let e = !1;
|
|
1386
|
+
draw = new Draw({
|
|
1387
|
+
type: "Polygon",
|
|
1388
|
+
source: vectorSource,
|
|
1389
|
+
trace: !0,
|
|
1390
|
+
style: [new Style({
|
|
1391
|
+
stroke: new Stroke({
|
|
1392
|
+
color: "rgba(255, 255, 255, 1)",
|
|
1393
|
+
width: 1.5,
|
|
1394
|
+
lineDash: [10, 10]
|
|
1395
|
+
}),
|
|
1396
|
+
fill: new Fill({
|
|
1397
|
+
color: "rgba(255, 255, 255, 0.25)"
|
|
1398
|
+
})
|
|
1399
|
+
}), new Style({
|
|
1400
|
+
image: new CircleStyle({
|
|
1401
|
+
radius: 5,
|
|
1402
|
+
fill: new Fill({
|
|
1403
|
+
color: "rgb(51,112,255, 1)"
|
|
1404
|
+
})
|
|
1405
|
+
}),
|
|
1406
|
+
geometry: function(o) {
|
|
1407
|
+
const n = o.getGeometry().getCoordinates();
|
|
1408
|
+
return new MultiPoint(n);
|
|
1409
|
+
}
|
|
1410
|
+
})]
|
|
1411
|
+
}), getInstall().addInteraction(draw);
|
|
1412
|
+
let t;
|
|
1413
|
+
draw.on("drawstart", (o) => {
|
|
1414
|
+
var n;
|
|
1415
|
+
sketch = o.feature, t = (n = sketch.getGeometry()) == null ? void 0 : n.on("change", (r) => {
|
|
1416
|
+
const a = r.target, l = computedArea(a, "nm"), c = a.getCoordinates()[0], d = new LineString([c[c.length - 2], c[c.length - 1]]), u = computedDistance(d, "nm");
|
|
1417
|
+
if (e = Number(getLength(d) / 1e3) > 150, !l) return;
|
|
1418
|
+
const s = '<span class="error pl-4">超出可以绘画的距离</span>';
|
|
1419
|
+
measureTooltipElement && (measureTooltipElement.innerHTML = `
|
|
1420
|
+
<div class="text">
|
|
1421
|
+
面积:${l}
|
|
1422
|
+
${e ? s : ""}
|
|
1423
|
+
</div>
|
|
1424
|
+
`), helpTooltipElement && (helpTooltipElement.innerHTML = `
|
|
1425
|
+
<div class="text">
|
|
1426
|
+
面积:${l}
|
|
1427
|
+
</div>
|
|
1428
|
+
<div class="text ${e ? "error" : ""}">
|
|
1429
|
+
线段 ${c.length - 2}: ${u}
|
|
1430
|
+
${e ? s : ""}
|
|
1431
|
+
|
|
1432
|
+
</div>
|
|
1433
|
+
<div>
|
|
1434
|
+
<span class="text">单击继续,双击结束</span>
|
|
1435
|
+
</div>
|
|
1436
|
+
`);
|
|
1437
|
+
});
|
|
1438
|
+
}), draw.on("drawend", (o) => {
|
|
1439
|
+
var l, i, c;
|
|
1440
|
+
if (!o.feature.getGeometry()) return;
|
|
1441
|
+
measureTooltipElement && (measureTooltipElement.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), measureTooltip.setOffset([10, 0]);
|
|
1442
|
+
const r = o.feature.getGeometry().getCoordinates(), a = r[0][r[0].length - 2];
|
|
1443
|
+
measureTooltip.setPosition(a), helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), (l = getProps()) != null && l.areaDrawEnd && ((i = getProps()) == null || i.areaDrawEnd(r)), draw && (draw.setActive(!1), getInstall().removeInteraction(draw), getInstall().getInteractions().forEach((u) => {
|
|
1444
|
+
u instanceof Draw && (u.setActive(!1), getInstall().removeInteraction(u));
|
|
1445
|
+
})), t && unByKey(t), (c = document.querySelector(".delete-icon")) == null || c.addEventListener("click", () => {
|
|
1446
|
+
reset();
|
|
1447
|
+
});
|
|
1448
|
+
});
|
|
1449
|
+
}, computedArea = (e, t) => {
|
|
1450
|
+
const o = getArea(e);
|
|
1451
|
+
switch (t) {
|
|
1452
|
+
case "km":
|
|
1453
|
+
return o > 1e4 ? Math.round(o / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(o * 100) / 100 + " m<sup>2</sup>";
|
|
1454
|
+
case "nm":
|
|
1455
|
+
return o > 1e4 ? Math.round(o / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(o * 100) / 100 + " m<sup>2</sup>";
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
let measureTooltipElement, measureTooltip;
|
|
1459
|
+
const createMeasureTooltip = () => {
|
|
1460
|
+
measureTooltipElement != null && measureTooltipElement.parentNode && measureTooltipElement.parentNode.removeChild(measureTooltipElement), measureTooltipElement = document.createElement("div"), measureTooltipElement.style.display = "flex", measureTooltipElement.className = "ol-tooltip ol-tooltip-draw-polygon", measureTooltip = new Overlay({
|
|
1461
|
+
element: measureTooltipElement,
|
|
1462
|
+
offset: [0, -15],
|
|
1463
|
+
positioning: "bottom-center"
|
|
1464
|
+
// stopEvent: false,
|
|
1465
|
+
// insertFirst: false
|
|
1466
|
+
}), getInstall().addOverlay(measureTooltip);
|
|
1467
|
+
};
|
|
1468
|
+
let helpTooltipElement, tipOverlay;
|
|
1469
|
+
const createHelpTooltip = () => {
|
|
1470
|
+
helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), helpTooltipElement = document.createElement("div"), helpTooltipElement.className = "ol-tooltip ol-help-tooltip hidden", tipOverlay = new Overlay({
|
|
1471
|
+
element: helpTooltipElement,
|
|
1472
|
+
offset: [15, 0],
|
|
1473
|
+
positioning: "center-left"
|
|
1474
|
+
}), getInstall().addOverlay(tipOverlay);
|
|
1475
|
+
}, reset = () => {
|
|
1476
|
+
var e;
|
|
1477
|
+
vectorSource == null || vectorSource.clear(), draw == null || draw.setActive(!0), (e = measureTooltipElement == null ? void 0 : measureTooltipElement.parentNode) == null || e.removeChild(measureTooltipElement), measureTooltip.setPosition(void 0), createMeasureTooltip(), createHelpTooltip(), getInstall().removeOverlay(tipOverlay), getInstall().removeOverlay(measureTooltip), initDraw();
|
|
1478
|
+
}, close = () => {
|
|
1479
|
+
vectorSource == null || vectorSource.clear(), vectorSource = null;
|
|
1480
|
+
const e = getInstall();
|
|
1481
|
+
vectorLayer && (e.removeLayer(vectorLayer), vectorLayer = null), sketch = null, draw && (e.removeInteraction(draw), draw = null);
|
|
1482
|
+
}, drawPolygon = {
|
|
1483
|
+
open,
|
|
1484
|
+
reset,
|
|
1485
|
+
close
|
|
1486
|
+
};
|
|
1487
|
+
let currentTruckOverlay = null;
|
|
1488
|
+
const locationTruck = async (e) => {
|
|
1489
|
+
const t = getInstall();
|
|
1490
|
+
if (!t || (console.log("vehicleInfo", e), !(e != null && e.lon && (e != null && e.lat)))) return;
|
|
1491
|
+
const o = Math.abs(Number(e.lon)) > 180 ? convertSixHundredThousandToLatLng(e.lon, e.lat) : [e.lon, e.lat];
|
|
1492
|
+
drawTruckIcon(e, fromLonLat(o));
|
|
1493
|
+
const n = t.getView(), r = new Point(o);
|
|
1494
|
+
n.setCenter(transform(r.getCoordinates(), projection.data, projection.mercator));
|
|
1495
|
+
}, drawTruckIcon = (e, t) => {
|
|
1496
|
+
const o = getInstall(), n = `${CDN_URL}map/car-icon.gif`;
|
|
1497
|
+
currentTruckOverlay || (currentTruckOverlay = new Overlay({
|
|
1498
|
+
element: document.createElement("div"),
|
|
1499
|
+
positioning: "center-center",
|
|
1500
|
+
stopEvent: !1
|
|
1501
|
+
// 允许交互事件穿透
|
|
1502
|
+
}), o.addOverlay(currentTruckOverlay));
|
|
1503
|
+
const r = currentTruckOverlay.getElement();
|
|
1504
|
+
r.style.backgroundImage = `url(${n})`, r.style.width = "80px", r.style.height = "80px";
|
|
1505
|
+
const a = (e == null ? void 0 : e.drc) || "";
|
|
1506
|
+
r.style.transform = `rotate(${a}deg)`, r.style.backgroundSize = "cover", currentTruckOverlay == null || currentTruckOverlay.setPosition(t);
|
|
1507
|
+
}, renderTruckTrack = (e, t, o, n = 1e3) => {
|
|
1508
|
+
renderTrackLine(e, t, o, LENGTH_UNIT.KM, "truck", n);
|
|
1509
|
+
}, closeTruckTrack = () => {
|
|
1510
|
+
closeTrack();
|
|
1511
|
+
}, removeTruckIcon = () => {
|
|
1512
|
+
const e = currentTruckOverlay == null ? void 0 : currentTruckOverlay.getElement();
|
|
1513
|
+
e && (e.innerHTML = "");
|
|
1514
|
+
}, resetTrackView = (e) => {
|
|
1515
|
+
setTrackViewCenter(e);
|
|
1516
|
+
}, playTrack = (e, t) => {
|
|
1517
|
+
playShipTrack(e, t);
|
|
1518
|
+
}, carTrack = {
|
|
1519
|
+
locationTruck,
|
|
1520
|
+
renderTruckTrack,
|
|
1521
|
+
removeTruckIcon,
|
|
1522
|
+
closeTruckTrack,
|
|
1523
|
+
resetTrackView,
|
|
1524
|
+
playTrack
|
|
1525
|
+
}, _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1526
|
+
__name: "Map",
|
|
1527
|
+
props: {
|
|
1528
|
+
zoom: { default: MAP_ZOOM.default },
|
|
1529
|
+
center: { default: MAP_DEFAULT_CENTER },
|
|
1530
|
+
layerType: { default: "vector" },
|
|
1531
|
+
showGreenLayer: { type: Boolean, default: !1 },
|
|
1532
|
+
showScale: { type: Boolean, default: !0 },
|
|
1533
|
+
scaleLineUnit: { default: "metric" },
|
|
1534
|
+
mapMoveEnd: { type: Function, default: () => {
|
|
1535
|
+
} },
|
|
1536
|
+
lineDrawEnd: {},
|
|
1537
|
+
areaDrawEnd: { type: Function, default: () => {
|
|
1538
|
+
} },
|
|
1539
|
+
selectShip: { type: Function, default: () => {
|
|
1540
|
+
} },
|
|
1541
|
+
selectPort: { type: Function, default: () => {
|
|
1542
|
+
} }
|
|
1543
|
+
},
|
|
1544
|
+
setup(e, { expose: t }) {
|
|
1545
|
+
const o = ref(), n = ref(), r = e;
|
|
1546
|
+
return console.log(r), onMounted(() => {
|
|
1547
|
+
var l;
|
|
1548
|
+
initMap(r), setProps(r), setShowLayerType(r.layerType), setGreenTileVisible(r.showGreenLayer), (l = n.value) == null || l.setScaleLine(r.scaleLineUnit);
|
|
1549
|
+
}), t({
|
|
1550
|
+
getInstall,
|
|
1551
|
+
getZoom,
|
|
1552
|
+
setZoom,
|
|
1553
|
+
getView,
|
|
1554
|
+
setCenter,
|
|
1555
|
+
getCenter,
|
|
1556
|
+
layer: {
|
|
1557
|
+
getGreenTileVisible,
|
|
1558
|
+
setGreenTileVisible,
|
|
1559
|
+
getShowLayerType,
|
|
1560
|
+
setShowLayerType
|
|
1561
|
+
},
|
|
1562
|
+
ship: {
|
|
1563
|
+
render: renderShipList,
|
|
1564
|
+
selected: renderShipSelected,
|
|
1565
|
+
filter: filterShipShow,
|
|
1566
|
+
blinking: renderShipBlink,
|
|
1567
|
+
clear: clearShipList
|
|
1568
|
+
},
|
|
1569
|
+
track: {
|
|
1570
|
+
renderTrackLine,
|
|
1571
|
+
handleTrackMapEvent,
|
|
1572
|
+
removeAllTrackLayer,
|
|
1573
|
+
playShipTrack,
|
|
1574
|
+
setTrackViewCenter,
|
|
1575
|
+
closeTrack
|
|
1576
|
+
},
|
|
1577
|
+
port: {
|
|
1578
|
+
render: renderPortList,
|
|
1579
|
+
clear: clearPortList,
|
|
1580
|
+
selected: selectedPort
|
|
1581
|
+
},
|
|
1582
|
+
drawLine,
|
|
1583
|
+
// 绘制矩形
|
|
1584
|
+
drawPolygon,
|
|
1585
|
+
carTrack,
|
|
1586
|
+
utils: {
|
|
1587
|
+
getCalculateExtent: () => {
|
|
1588
|
+
const l = getView().calculateExtent(getSize()), i = transform([l[0], l[1]], projection.mercator, projection.data), c = transform([l[2], l[3]], projection.mercator, projection.data);
|
|
1589
|
+
return [i[0], i[1], c[0], c[1]];
|
|
1590
|
+
},
|
|
1591
|
+
convertSixHundredThousandToLatLng
|
|
1592
|
+
}
|
|
1593
|
+
}), (l, i) => (openBlock(), createElementBlock(Fragment, null, [
|
|
1594
|
+
createElementVNode("div", {
|
|
1595
|
+
id: "map",
|
|
1596
|
+
ref_key: "zhMapRef",
|
|
1597
|
+
ref: o,
|
|
1598
|
+
class: "zh-map"
|
|
1599
|
+
}, null, 512),
|
|
1600
|
+
createVNode(ScaleLine, {
|
|
1601
|
+
ref_key: "scaleLineRef",
|
|
1602
|
+
ref: n
|
|
1603
|
+
}, null, 512),
|
|
1604
|
+
createVNode(ZoomControl, { ref: "zoomControlRef" }, null, 512)
|
|
1605
|
+
], 64));
|
|
1606
|
+
}
|
|
1607
|
+
}), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1f377837"]]), ZhMap = withInstall(Map$1);
|
|
1608
|
+
export {
|
|
1609
|
+
ZhMap as Z
|
|
1610
|
+
};
|