zhihao-ui 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/{BaseInfo-DZ0pUsfS.js → BaseInfo-BqJWKOdd.js} +1 -1
- package/dist/es/{BaseItem-C_JbnRPH.js → BaseItem-BQbkTxt9.js} +3 -3
- package/dist/es/{Button-CydCp4hf.js → Button-1UUC8v6b.js} +2 -2
- package/dist/es/{DatePicker-C__sA0-h.js → DatePicker-ByP3ZkhE.js} +3 -3
- package/dist/es/{DetailHeader-bEliAoL-.js → DetailHeader-CnZCthjX.js} +3 -3
- package/dist/es/{DetailSubTitle-COsgdEV-.js → DetailSubTitle-COQCdb8X.js} +2 -2
- package/dist/es/{Dialog-D-vnJqtW.js → Dialog-DFQIVnQP.js} +3 -3
- package/dist/es/{DiyDataTable-DTMKwxu9.js → DiyDataTable-D0gTwPB4.js} +4 -4
- package/dist/es/{EditInfoPair-C4vN_b9E.js → EditInfoPair-CZpQKhX6.js} +3 -3
- package/dist/es/{FileWrapper-D7KcyVg2.js → FileWrapper-C9Cqt-L8.js} +4 -4
- package/dist/es/{Grid-BE-CLeGr.js → Grid-CfwiS54k.js} +2 -2
- package/dist/es/{InfoPair-T3_TncEu.js → InfoPair-ZKRxEmIC.js} +3 -3
- package/dist/es/{Input-C0UdD80I.js → Input-CloA0e6h.js} +3 -3
- package/dist/es/{Loading-QlWiWU_L.js → Loading-BXtzvylk.js} +2 -2
- package/dist/es/{Map-DMb_YG1p.js → Map-Ce0s7g5Z.js} +551 -475
- package/dist/es/{MessageBox-B42XuRHh.js → MessageBox-BNOuww77.js} +2 -2
- package/dist/es/{MoneyInput-BsulLCsJ.js → MoneyInput-CuHL7bEc.js} +8 -8
- package/dist/es/{PageHeadPanel-BlFg_TvH.js → PageHeadPanel-BroYHTD8.js} +2 -2
- package/dist/es/{Table-Oo-hQWGa.js → Table-DFGzUqS3.js} +5 -5
- package/dist/es/{ToolTips-YgMKfoQ0.js → ToolTips-BBi5iPOb.js} +3 -3
- package/dist/es/index.js +22 -22
- package/dist/es/{utils-CU-8DWnA.js → utils-BbOeFn3W.js} +3 -3
- package/dist/es/{vendor-1zIwhmRg.js → vendor-D-B7bNnH.js} +32 -31
- package/dist/index.css +1 -1
- package/dist/types/components/Map/config/global.d.ts +1 -0
- package/dist/types/components/Map/config/index.d.ts +0 -41
- package/dist/types/components/Map/config/map.d.ts +0 -3
- package/dist/types/components/Map/function/drawPolygon.d.ts +1 -1
- package/dist/types/components/Map/function/port.d.ts +1 -2
- package/dist/types/components/Map/function/ship/index.d.ts +22 -0
- package/dist/types/components/Map/function/ship/style.d.ts +6 -0
- package/dist/types/components/Map/function/shipTrack.d.ts +7 -0
- package/dist/types/components/Map/meta/index.d.ts +0 -5
- package/dist/types/components/Map/utils/overlay.d.ts +2 -1
- package/dist/types/components/Map/utils/util.d.ts +42 -0
- package/dist/umd/index.css +1 -1
- package/dist/umd/index.umd.cjs +17 -15
- package/package.json +1 -1
- package/dist/types/components/Map/Map.vue.d.ts +0 -130
- package/dist/types/components/Map/function/label.d.ts +0 -9
- package/dist/types/components/Map/function/ship.d.ts +0 -34
- package/dist/types/components/Map/function/shipLabel.d.ts +0 -25
- package/dist/types/components/Map/index.d.ts +0 -418
|
@@ -1,7 +1,7 @@
|
|
|
1
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 fromLonLat, t as transformExtent, q as getLength, R as RBush$1, O as Overlay, I as Icon, V as VectorSource, r as VectorLayer, s as debounce, i as cloneDeep, u as Feature, P as Point, h as hooks, L as LineString, v as Stroke, C as CircleStyle, w as Polyline, x as buffer, y as transform, z as getVectorContext, D as DoubleClickZoom, A as Draw, B as unByKey, G as getUid, M as Map$2, H as TileLayer, X as XYZ, J as View, K as
|
|
3
|
-
import { _ as _export_sfc } from "./Button-
|
|
4
|
-
import { w as withInstall } from "./utils-
|
|
2
|
+
import { T as Text, F as Fill, S as Style, p as fromLonLat, t as transformExtent, q as getLength, R as RBush$1, O as Overlay, I as Icon, V as VectorSource, r as VectorLayer, s as debounce, i as cloneDeep, u as Feature, P as Point, h as hooks, L as LineString, v as Stroke, C as CircleStyle, w as Polyline, x as buffer, y as transform, z as getVectorContext, D as DoubleClickZoom, A as Draw, B as unByKey, G as getUid, M as Map$2, H as TileLayer, X as XYZ, J as View, K as defaults, N as toLonLat, Q as ScaleLine$1, U as getArea, W as MultiPoint } from "./vendor-D-B7bNnH.js";
|
|
3
|
+
import { _ as _export_sfc } from "./Button-1UUC8v6b.js";
|
|
4
|
+
import { w as withInstall } from "./utils-BbOeFn3W.js";
|
|
5
5
|
const TIAN_DI_TU_KEY = "a6e8f78974f2581f2ca00485b40c948f", MAP_ZOOM = {
|
|
6
6
|
// 地图默认层级
|
|
7
7
|
default: 13,
|
|
@@ -20,39 +20,41 @@ const TIAN_DI_TU_KEY = "a6e8f78974f2581f2ca00485b40c948f", MAP_ZOOM = {
|
|
|
20
20
|
data: "EPSG:4326",
|
|
21
21
|
// 墨卡托投影坐标 渲染坐标
|
|
22
22
|
mercator: "EPSG:3857"
|
|
23
|
-
}, MAP_DEFAULT_CENTER = [114.84, 30.52], CDN_URL = "https://static.zhihaoscm.cn/",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
}, MAP_DEFAULT_CENTER = [114.84, 30.52], CDN_URL = "https://static.zhihaoscm.cn/", equatorialCircumference = 2003750834e-2;
|
|
24
|
+
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 || {});
|
|
25
|
+
const calculateCirclePoints = (e, t) => {
|
|
26
|
+
const n = fromLonLat(e), o = t * 1e3, r = [
|
|
27
|
+
n[0] - o,
|
|
28
|
+
n[1] - o,
|
|
29
|
+
n[0] + o,
|
|
30
|
+
n[1] + o
|
|
31
|
+
], l = transformExtent(r, projection.mercator, projection.data);
|
|
30
32
|
return {
|
|
31
|
-
leftTopPoint: { lng:
|
|
32
|
-
rightTopPoint: { lng:
|
|
33
|
-
rightBottomPoint: { lng:
|
|
34
|
-
leftBottomPoint: { lng:
|
|
33
|
+
leftTopPoint: { lng: l[0], lat: l[3] },
|
|
34
|
+
rightTopPoint: { lng: l[2], lat: l[3] },
|
|
35
|
+
rightBottomPoint: { lng: l[2], lat: l[1] },
|
|
36
|
+
leftBottomPoint: { lng: l[0], lat: l[1] }
|
|
35
37
|
};
|
|
36
38
|
}, formatLength = function(e, t) {
|
|
37
|
-
const
|
|
39
|
+
const o = getLength(e);
|
|
38
40
|
let r = "";
|
|
39
|
-
switch (t) {
|
|
41
|
+
switch (console.log(t, LENGTH_UNIT), t) {
|
|
40
42
|
case LENGTH_UNIT.M:
|
|
41
|
-
r = Math.round(
|
|
43
|
+
r = Math.round(o * 100) / 100 + " m";
|
|
42
44
|
break;
|
|
43
45
|
case LENGTH_UNIT.KM:
|
|
44
|
-
r = Math.round(
|
|
46
|
+
r = Math.round(o / 1e3 * 100) / 100 + " km";
|
|
45
47
|
break;
|
|
46
48
|
case LENGTH_UNIT.NM:
|
|
47
|
-
r = (Math.round(
|
|
49
|
+
r = (Math.round(o / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
|
|
48
50
|
break;
|
|
49
51
|
}
|
|
50
52
|
return r;
|
|
51
|
-
}
|
|
53
|
+
};
|
|
52
54
|
function lonLatToMercator(e) {
|
|
53
55
|
const t = e[0] * equatorialCircumference / 180;
|
|
54
|
-
let
|
|
55
|
-
return
|
|
56
|
+
let n = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
|
|
57
|
+
return n = n * equatorialCircumference / 180, [t, n];
|
|
56
58
|
}
|
|
57
59
|
function getIconFont(unicode = "") {
|
|
58
60
|
return unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), eval('("' + unicode.replace("&#x", "\\u").replace(";", "") + '")');
|
|
@@ -68,21 +70,23 @@ const getIconStyle = (e) => {
|
|
|
68
70
|
text: t,
|
|
69
71
|
zIndex: 100
|
|
70
72
|
});
|
|
71
|
-
},
|
|
72
|
-
const
|
|
73
|
+
}, mercatorToLonLat = (e, t = "lonlat") => {
|
|
74
|
+
const n = { lon: 0, lat: 0 }, o = e[0] / equatorialCircumference * 180;
|
|
73
75
|
let r = e[1] / equatorialCircumference * 180;
|
|
74
|
-
return r = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2),
|
|
75
|
-
};
|
|
76
|
-
var
|
|
77
|
-
const
|
|
76
|
+
return r = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2), n.lon = o, n.lat = r, t === "lonlat" ? n : [o, r];
|
|
77
|
+
}, 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];
|
|
78
|
+
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 || {});
|
|
79
|
+
const convertSixHundredThousandToLatLng = function(e, t) {
|
|
80
|
+
const n = Number(t) / 6e5;
|
|
81
|
+
return [Number(e) / 6e5, n];
|
|
82
|
+
}, getRightIcons = (e) => {
|
|
78
83
|
const t = [];
|
|
79
84
|
return e.existDevice && t.push(""), e.existMobile && t.push(""), e.existWaterGauge && t.push(""), t;
|
|
80
85
|
};
|
|
81
86
|
new RBush$1();
|
|
82
|
-
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 || {});
|
|
83
87
|
function useShipOverlay(e) {
|
|
84
|
-
const t = ref(null),
|
|
85
|
-
"--overlay-color": e.color,
|
|
88
|
+
const t = ref(null), n = ref(null), o = computed(() => ({
|
|
89
|
+
"--overlay-color": e.color || "#FFF",
|
|
86
90
|
"--bg-color": e.selected ? e.color : "#ffffff",
|
|
87
91
|
position: "relative",
|
|
88
92
|
"pointer-events": "none"
|
|
@@ -101,26 +105,12 @@ function useShipOverlay(e) {
|
|
|
101
105
|
"z-index": "1",
|
|
102
106
|
display: "flex",
|
|
103
107
|
"align-items": "center"
|
|
104
|
-
})),
|
|
108
|
+
})), l = computed(() => ({
|
|
105
109
|
width: "14px",
|
|
106
110
|
height: "14px",
|
|
107
111
|
margin: "1px 5px 1px 1px",
|
|
108
112
|
"background-color": "var(--bg-color)"
|
|
109
|
-
})),
|
|
110
|
-
// 'position': 'absolute',
|
|
111
|
-
// 'background': '#FFF',
|
|
112
|
-
// 'height': '1px',
|
|
113
|
-
// 'color': 'var(--overlay-color)',
|
|
114
|
-
// .connection-line::before {
|
|
115
|
-
// content: '';
|
|
116
|
-
// position: absolute;
|
|
117
|
-
// width: var(--length);
|
|
118
|
-
// height: 100%;
|
|
119
|
-
// transform: rotate(var(--angle));
|
|
120
|
-
// transform-origin: left center;
|
|
121
|
-
// left: var(--start-x);
|
|
122
|
-
// top: var(--start-y);
|
|
123
|
-
// }
|
|
113
|
+
})), s = computed(() => ({
|
|
124
114
|
position: "absolute",
|
|
125
115
|
top: "0px",
|
|
126
116
|
color: "var(--overlay-color)",
|
|
@@ -131,23 +121,23 @@ function useShipOverlay(e) {
|
|
|
131
121
|
height: "20px",
|
|
132
122
|
overflow: "visible"
|
|
133
123
|
}));
|
|
134
|
-
let
|
|
124
|
+
let a = null;
|
|
135
125
|
const c = () => {
|
|
136
|
-
d(),
|
|
126
|
+
d(), a = window.setInterval(() => {
|
|
137
127
|
if (t.value) {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
128
|
+
const i = t.value.querySelector(".ship-overlay-content");
|
|
129
|
+
i && i.style && (i.style.backgroundColor = e.color, i.style.color = "#FFF", setTimeout(() => {
|
|
130
|
+
i && i.style && (i.style.backgroundColor = "#ffffff", i.style.color = "#000");
|
|
141
131
|
}, 500));
|
|
142
132
|
}
|
|
143
133
|
}, 1e3);
|
|
144
134
|
}, d = () => {
|
|
145
|
-
|
|
135
|
+
a && (clearInterval(a), a = null);
|
|
146
136
|
}, u = () => {
|
|
147
|
-
|
|
137
|
+
n.value && n.value.setPosition(fromLonLat(e.position));
|
|
148
138
|
};
|
|
149
|
-
return watch(() => e.selected, (
|
|
150
|
-
|
|
139
|
+
return watch(() => e.selected, (i) => {
|
|
140
|
+
i ? c() : d();
|
|
151
141
|
}, { immediate: !0 }), watch(() => e.position, () => {
|
|
152
142
|
u();
|
|
153
143
|
}, { deep: !0 }), onMounted(() => {
|
|
@@ -156,7 +146,7 @@ function useShipOverlay(e) {
|
|
|
156
146
|
}), () => h("div", {
|
|
157
147
|
ref: t,
|
|
158
148
|
class: "ship-overlay-container",
|
|
159
|
-
style:
|
|
149
|
+
style: o.value
|
|
160
150
|
}, [
|
|
161
151
|
h(
|
|
162
152
|
"div",
|
|
@@ -166,7 +156,7 @@ function useShipOverlay(e) {
|
|
|
166
156
|
},
|
|
167
157
|
[
|
|
168
158
|
h("div", {
|
|
169
|
-
style: e.selected ?
|
|
159
|
+
style: e.selected ? l.value : {}
|
|
170
160
|
}, ""),
|
|
171
161
|
h("div", {
|
|
172
162
|
class: "text"
|
|
@@ -198,13 +188,9 @@ function useShipOverlay(e) {
|
|
|
198
188
|
])
|
|
199
189
|
]
|
|
200
190
|
),
|
|
201
|
-
// h('div',{
|
|
202
|
-
// class: 'ship-overlay-line',
|
|
203
|
-
// style: lineStyle.value,
|
|
204
|
-
// })
|
|
205
191
|
h("svg", {
|
|
206
192
|
class: "ship-overlay-line",
|
|
207
|
-
style:
|
|
193
|
+
style: s.value,
|
|
208
194
|
viewBox: "0 0 20 20",
|
|
209
195
|
xmlns: "http://www.w3.org/2000/svg"
|
|
210
196
|
}, [
|
|
@@ -255,72 +241,72 @@ function isOverlapping(e, t) {
|
|
|
255
241
|
return !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom);
|
|
256
242
|
}
|
|
257
243
|
function calculateBestPosition(e, t) {
|
|
258
|
-
const
|
|
244
|
+
const n = existingOverlays.value.filter((o) => o !== e).map((o) => {
|
|
259
245
|
var r;
|
|
260
|
-
return (r =
|
|
261
|
-
}).filter((
|
|
262
|
-
for (const
|
|
263
|
-
e.setPositioning(
|
|
246
|
+
return (r = o.getElement()) == null ? void 0 : r.getBoundingClientRect();
|
|
247
|
+
}).filter((o) => o !== void 0);
|
|
248
|
+
for (const o of POSITION_PRIORITY) {
|
|
249
|
+
e.setPositioning(o.positioning), e.setOffset(o.offset), e.setPosition(t);
|
|
264
250
|
const r = e.getElement();
|
|
265
251
|
if (!r) continue;
|
|
266
252
|
r.offsetHeight;
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
(
|
|
253
|
+
const l = r.getBoundingClientRect();
|
|
254
|
+
if (!n.some(
|
|
255
|
+
(a) => isOverlapping(l, a)
|
|
270
256
|
))
|
|
271
257
|
break;
|
|
272
258
|
}
|
|
273
259
|
}
|
|
274
|
-
function addOverlay(e, t,
|
|
260
|
+
function addOverlay(e, t, n, o) {
|
|
275
261
|
const r = new Overlay({
|
|
276
|
-
element:
|
|
262
|
+
element: n,
|
|
277
263
|
positioning: "top-left",
|
|
278
|
-
id: "label-" +
|
|
264
|
+
id: "label-" + (o == null ? void 0 : o.id),
|
|
279
265
|
offset: [0, 0],
|
|
280
266
|
autoPan: !1,
|
|
281
|
-
className: "ship-label-overlay"
|
|
267
|
+
className: o.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
|
|
282
268
|
});
|
|
283
269
|
r.set("class", "zh-map-ship-overlay"), e.addOverlay(r), existingOverlays.value.push(r), nextTick(async () => {
|
|
284
270
|
await calculateBestPosition(r, t), setLinePath(r);
|
|
285
271
|
});
|
|
286
272
|
}
|
|
287
273
|
function setLinePath(e) {
|
|
288
|
-
const t = e.getElement(),
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
292
|
-
const { x1:
|
|
293
|
-
|
|
274
|
+
const t = e.getElement(), n = t == null ? void 0 : t.querySelector(".ship-overlay-line"), o = e.getPositioning(), r = e.getOffset();
|
|
275
|
+
n && o === "top-right" && (n.style.right = "-20px"), n && o === "top-left" && (n.style.left = "-20px");
|
|
276
|
+
const l = POSITION_PRIORITY.filter((a) => a.positioning === o && a.offset === r), s = t == null ? void 0 : t.querySelector(".ship-overlay-line line");
|
|
277
|
+
if (l.length > 0) {
|
|
278
|
+
const { x1: a, y1: c, x2: d, y2: u } = l[0].line;
|
|
279
|
+
s && (s.setAttribute("x1", a), s.setAttribute("y1", c), s.setAttribute("x2", d), s.setAttribute("y2", u));
|
|
294
280
|
}
|
|
295
281
|
}
|
|
296
282
|
function removeLabelOverlay(e) {
|
|
297
|
-
existingOverlays.value = [], e.getOverlays().getArray().filter((
|
|
298
|
-
|
|
283
|
+
existingOverlays.value = [], e.getOverlays().getArray().filter((o) => o.get("class") === "zh-map-ship-overlay").forEach((o) => {
|
|
284
|
+
o.setPosition(void 0), o.setElement(void 0), e.removeOverlay(o), o.dispose();
|
|
299
285
|
});
|
|
300
286
|
}
|
|
301
287
|
const getShipDirectPath = (e) => {
|
|
302
|
-
const { spd: t, hdg:
|
|
303
|
-
return t ?
|
|
288
|
+
const { spd: t, hdg: n, cog: o } = e;
|
|
289
|
+
return t ? n !== null && +n != 511 && o !== null ? o - +n >= 3 ? SHIP_DIRECT.right : o - +n <= -3 ? SHIP_DIRECT.left : SHIP_DIRECT.front : SHIP_DIRECT.front : "";
|
|
304
290
|
}, createShipStyle = (e) => {
|
|
305
|
-
const { shipData: t } = e.getProperties(),
|
|
306
|
-
return initShipStyle(e,
|
|
291
|
+
const { shipData: t } = e.getProperties(), n = getShipType(), o = getShipScale(t, n);
|
|
292
|
+
return initShipStyle(e, o, n);
|
|
307
293
|
}, getShipType = () => {
|
|
308
294
|
const e = getZoom();
|
|
309
295
|
return e <= MAP_ZOOM.shipModelMax && e >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
|
|
310
296
|
}, getShipScale = (e, t) => {
|
|
311
297
|
if (t === "ship") {
|
|
312
|
-
const { len:
|
|
298
|
+
const { len: n, wid: o } = e, r = 97, l = 20, a = 1 / getView().getResolution(), c = n * a / r, d = o * a / l;
|
|
313
299
|
return Math.max(c, d);
|
|
314
300
|
}
|
|
315
301
|
return MAP_ZOOM.scaleNum;
|
|
316
|
-
}, initShipStyle = (e, t,
|
|
317
|
-
const { color:
|
|
302
|
+
}, initShipStyle = (e, t, n) => {
|
|
303
|
+
const { color: o, direct: r, isHighlight: l, shipData: s } = e.getProperties(), a = (s.cog - 90 + 360) % 360;
|
|
318
304
|
return new Style({
|
|
319
305
|
image: new Icon({
|
|
320
306
|
src: c(),
|
|
321
307
|
scale: t || MAP_ZOOM.scaleNum,
|
|
322
308
|
anchor: [0.5, 0.5],
|
|
323
|
-
rotation:
|
|
309
|
+
rotation: a * Math.PI / 180,
|
|
324
310
|
rotateWithView: !1
|
|
325
311
|
})
|
|
326
312
|
});
|
|
@@ -328,26 +314,26 @@ const getShipDirectPath = (e) => {
|
|
|
328
314
|
return `data:image/svg+xml;utf8,${encodeURIComponent(d())}`;
|
|
329
315
|
}
|
|
330
316
|
function d() {
|
|
331
|
-
switch (
|
|
317
|
+
switch (n) {
|
|
332
318
|
case "triangle":
|
|
333
319
|
return `<svg width="41" height="24" viewBox="0 0 41 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
334
320
|
<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"
|
|
335
|
-
fill="${
|
|
321
|
+
fill="${o}" stroke="${l ? "#FF2424" : "black"}" stroke-width="${l ? "2" : "0.578947"}" />
|
|
336
322
|
<!--path船航向左边或者向前-->
|
|
337
|
-
${r === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${
|
|
323
|
+
${r === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${l ? "#FF2424" : "black"}" stroke-width="2"/>`}
|
|
338
324
|
<!--path船航向右边-->
|
|
339
|
-
${r === SHIP_DIRECT.right && `<path d="M30 12L40 12L40 16" stroke="${
|
|
325
|
+
${r === SHIP_DIRECT.right && `<path d="M30 12L40 12L40 16" stroke="${l ? "#FF2424" : "black"}" stroke-width="2"/>`}
|
|
340
326
|
<!--path黑线无左右-->
|
|
341
|
-
${r === SHIP_DIRECT.front && `<path d="M30 12L40 12" stroke="${
|
|
327
|
+
${r === SHIP_DIRECT.front && `<path d="M30 12L40 12" stroke="${l ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
342
328
|
</svg>
|
|
343
329
|
`;
|
|
344
330
|
case "ship":
|
|
345
331
|
return `<svg width="97" height="20" viewBox="0 0 97 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
346
332
|
<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"
|
|
347
|
-
fill="${
|
|
348
|
-
${r === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${
|
|
349
|
-
${r === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${
|
|
350
|
-
${r === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${
|
|
333
|
+
fill="${o}" stroke="${l ? "#FF2424" : "black"}" stroke-width="${l ? "4" : "0.578947"}"/>
|
|
334
|
+
${r === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${l ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
335
|
+
${r === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${l ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
336
|
+
${r === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${l ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
351
337
|
</svg>
|
|
352
338
|
`;
|
|
353
339
|
default:
|
|
@@ -355,39 +341,43 @@ const getShipDirectPath = (e) => {
|
|
|
355
341
|
}
|
|
356
342
|
}
|
|
357
343
|
}, selectedShipStyle = (e) => {
|
|
358
|
-
const t =
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
<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"/>
|
|
362
|
-
</svg>
|
|
363
|
-
`, l = document.createElement("div");
|
|
364
|
-
l.className = "ship-overlay-selected", l.innerHTML = a;
|
|
365
|
-
const { lon: i, lat: c } = e, d = new Overlay({
|
|
366
|
-
element: l,
|
|
367
|
-
position: fromLonLat([i, c]),
|
|
344
|
+
const t = selectedShipElement(e), n = e.id, { lon: o, lat: r } = e, l = new Overlay({
|
|
345
|
+
element: t,
|
|
346
|
+
position: fromLonLat([o, r]),
|
|
368
347
|
id: "selected-" + n,
|
|
369
348
|
positioning: "center-center",
|
|
370
349
|
offset: [0, 5],
|
|
371
350
|
className: "ship-selected-overlay"
|
|
372
351
|
});
|
|
373
|
-
return
|
|
352
|
+
return l.set("class", "ship-overlay-selected"), l;
|
|
353
|
+
}, selectedShipElement = (e) => {
|
|
354
|
+
const t = getShipType(), n = getShipScale(e, t), o = t === "ship" ? 109 : 49, r = `
|
|
355
|
+
<svg style="transform:scale(${n});" xmlns="http://www.w3.org/2000/svg" width="${o}" height="${o}" viewBox="0 0 49 49" fill="none">
|
|
356
|
+
<path d="M1.99982 46.9998L1.99982 1.99982L46.9998 1.99982L46.9998 46.9998L1.99982 46.9998Z" fill="#FF2424" fill-opacity="0.2"/>
|
|
357
|
+
<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"/>
|
|
358
|
+
</svg>
|
|
359
|
+
`, l = document.createElement("div");
|
|
360
|
+
return l.className = "ship-overlay-selected", l.innerHTML = r, l;
|
|
374
361
|
}, createLabelStyle = (e) => {
|
|
375
|
-
const t = getInstall(), o =
|
|
376
|
-
|
|
377
|
-
|
|
362
|
+
const t = getInstall(), { shipData: n, blinking: o } = e.getProperties(), { lon: r, lat: l } = n, s = createLabelElement(e);
|
|
363
|
+
addOverlay(t, fromLonLat([r, l]), s, { ...n, blinking: o });
|
|
364
|
+
}, createLabelElement = (e) => {
|
|
365
|
+
const t = document.createElement("div");
|
|
366
|
+
t.className = "ship-overlay-box", t.style.position = "relative";
|
|
367
|
+
const n = e.getProperties(), { shipData: o, blinking: r, blinkingColor: l, name: s } = n, { lon: a, lat: c } = o, d = createVNode({
|
|
378
368
|
setup() {
|
|
379
369
|
return useShipOverlay({
|
|
380
|
-
position: [
|
|
381
|
-
selected:
|
|
382
|
-
name:
|
|
370
|
+
position: [a + 2e-3, c + 2e-3],
|
|
371
|
+
selected: r,
|
|
372
|
+
name: s,
|
|
383
373
|
color: l,
|
|
384
|
-
existDevice:
|
|
385
|
-
existMobile:
|
|
386
|
-
existWaterGauge:
|
|
374
|
+
existDevice: o == null ? void 0 : o.existDevice,
|
|
375
|
+
existMobile: o == null ? void 0 : o.existMobile,
|
|
376
|
+
existWaterGauge: o == null ? void 0 : o.existWaterGauge
|
|
387
377
|
});
|
|
388
378
|
}
|
|
389
379
|
});
|
|
390
|
-
render(
|
|
380
|
+
return render(d, t), t;
|
|
391
381
|
};
|
|
392
382
|
let selectedShipFeature = null, selectedShip = null;
|
|
393
383
|
const shipsSource = new VectorSource(), shipsLayer = new VectorLayer({
|
|
@@ -404,104 +394,139 @@ const renderShipList = (e) => {
|
|
|
404
394
|
const t = getInstall();
|
|
405
395
|
if (!t) return;
|
|
406
396
|
t.getLayers().getArray().includes(shipsLayer) || t.addLayer(shipsLayer);
|
|
407
|
-
const
|
|
397
|
+
const n = (selectedShip == null ? void 0 : selectedShip.id) || (selectedShipFeature == null ? void 0 : selectedShipFeature.get("id"));
|
|
408
398
|
removeLabelOverlay(t), removeSelectedOverlay(), shipsSource && shipsSource.clear();
|
|
409
|
-
const
|
|
399
|
+
const o = [];
|
|
410
400
|
if (selectedShip) {
|
|
411
|
-
const r = e.filter((
|
|
401
|
+
const r = e.filter((l) => l.id === n);
|
|
412
402
|
r.length === 0 ? e.push(selectedShip) : selectedShip = r[0];
|
|
413
403
|
}
|
|
414
404
|
e.forEach((r) => {
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
405
|
+
const l = createShipFetature(r);
|
|
406
|
+
o.push(l), createLabelStyle(l);
|
|
407
|
+
}), shipsSource.addFeatures(o), handleChangeSelected();
|
|
408
|
+
}, createShipFetature = (e) => {
|
|
409
|
+
const t = (selectedShip == null ? void 0 : selectedShip.id) || (selectedShipFeature == null ? void 0 : selectedShipFeature.get("id")), n = fromLonLat([e.lon, e.lat]), o = new Feature({
|
|
410
|
+
geometry: new Point(n),
|
|
411
|
+
// 船舶数据
|
|
412
|
+
shipData: e,
|
|
413
|
+
id: e.id,
|
|
414
|
+
name: e.cnname || "未命名船舶",
|
|
415
|
+
selected: e.id === t,
|
|
416
|
+
// 图标
|
|
417
|
+
rightIcons: getRightIcons(e),
|
|
418
|
+
// 是否闪烁
|
|
419
|
+
blinking: attentionShips[e.id] || !1,
|
|
420
|
+
// 闪烁颜色
|
|
421
|
+
blinkingColor: attentionShipsColor[e.id] || "",
|
|
422
|
+
// 船舶颜色
|
|
423
|
+
color: e.fill || "#04C900",
|
|
424
|
+
// 船艏向的方向
|
|
425
|
+
direct: getShipDirectPath(e),
|
|
426
|
+
// 高亮
|
|
427
|
+
isHighlight: !1
|
|
428
|
+
});
|
|
429
|
+
return o.setStyle(createShipStyle(o)), o;
|
|
430
|
+
}, handleChangeSelected = () => {
|
|
431
|
+
var o;
|
|
432
|
+
if (!selectedShip) return;
|
|
433
|
+
const e = getInstall();
|
|
434
|
+
if (!e) return;
|
|
435
|
+
const n = cloneDeep(e.getOverlays().getArray()).find((r) => r.get("class") == "ship-overlay-selected");
|
|
436
|
+
if (console.log("selectedOverlay-----------", n), n) {
|
|
437
|
+
const r = selectedShipElement(selectedShip);
|
|
438
|
+
n.setElement(r), n.setPosition(fromLonLat([selectedShip.lon, selectedShip.lat])), n.get("element").style.visibility = "visible";
|
|
439
|
+
} else {
|
|
440
|
+
const r = selectedShipStyle(selectedShip);
|
|
441
|
+
e.addOverlay(r);
|
|
442
|
+
}
|
|
443
|
+
(o = n.get("element")) != null && o.parentElement && (n.get("element").parentElement.style.display = "block");
|
|
442
444
|
}, clearShipList = () => {
|
|
443
445
|
const e = getInstall();
|
|
444
446
|
if (!e || !shipsSource) return;
|
|
445
447
|
const t = (selectedShip == null ? void 0 : selectedShip.id) || "";
|
|
446
|
-
shipsSource.getFeatures().forEach((
|
|
447
|
-
|
|
448
|
+
shipsSource.getFeatures().forEach((o) => {
|
|
449
|
+
o.get("shipData").shipId !== t && shipsSource.removeFeature(o);
|
|
448
450
|
});
|
|
449
|
-
const
|
|
450
|
-
cloneDeep(
|
|
451
|
-
(
|
|
451
|
+
const n = e.getOverlays().getArray();
|
|
452
|
+
cloneDeep(n).map((o) => {
|
|
453
|
+
(o.getId() !== "label-" + t || o.getId() !== "selected-" + t) && (o.setPosition(void 0), e.removeOverlay(o), o.dispose());
|
|
452
454
|
});
|
|
453
455
|
}, renderShipBlink = (e, t) => {
|
|
456
|
+
const n = getInstall();
|
|
454
457
|
attentionShips = e, attentionShipsColor = t;
|
|
458
|
+
const o = cloneDeep(n.getOverlays().getArray()), r = cloneDeep(shipsSource.getFeatures());
|
|
459
|
+
for (const l in attentionShips) {
|
|
460
|
+
const s = attentionShips[l], a = o.find((d) => d.getId() === "label-" + l), c = r.find((d) => l === d.get("id"));
|
|
461
|
+
if (a && c) {
|
|
462
|
+
c.set("blinking", s), c.set("blinkingColor", attentionShipsColor[l] || "");
|
|
463
|
+
const d = a.getElement(), u = createLabelElement(c), i = u.querySelector(".ship-overlay-line"), p = d == null ? void 0 : d.querySelector(".ship-overlay-line");
|
|
464
|
+
d && d !== u && (p && i && i.replaceWith(p), a.setElement(u));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
455
467
|
}, filterShipShow = (e) => {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
468
|
+
const t = getInstall();
|
|
469
|
+
if (!t) return;
|
|
470
|
+
const n = shipsSource.getFeatures(), o = selectedShipFeature ? selectedShipFeature.get("id") : "", r = n.filter((a) => a.get("id") !== o), l = /* @__PURE__ */ new Map();
|
|
471
|
+
e.forEach((a) => {
|
|
472
|
+
l.set(a.id, !0);
|
|
473
|
+
});
|
|
474
|
+
const s = cloneDeep(t.getOverlays().getArray());
|
|
475
|
+
r.forEach((a) => {
|
|
476
|
+
const c = a.get("id"), d = s.find((u) => u.getId() === "label-" + c);
|
|
477
|
+
if (!l.has(c))
|
|
478
|
+
a.setStyle([]), d && (d.get("element").style.visibility = "hidden");
|
|
464
479
|
else {
|
|
465
|
-
|
|
466
|
-
|
|
480
|
+
d && (d.get("element").style.visibility = "visible");
|
|
481
|
+
const u = a.getStyle();
|
|
482
|
+
(u == null ? void 0 : u.length) == 0 && a.setStyle(createShipStyle(a));
|
|
467
483
|
}
|
|
468
484
|
});
|
|
469
485
|
}, renderShipSelected = (e) => {
|
|
470
486
|
if (e) {
|
|
471
487
|
console.log("选中", e);
|
|
472
|
-
const t = shipsSource.getFeatures().find((
|
|
488
|
+
const t = shipsSource.getFeatures().find((n) => n.get("id") === e.id);
|
|
473
489
|
t && (selectedShipFeature = t), selectedShip = e;
|
|
474
490
|
} else
|
|
475
|
-
console.log("取消选中"), removeSelectedOverlay();
|
|
476
|
-
},
|
|
477
|
-
|
|
491
|
+
console.log("取消选中"), selectedShip = null, removeSelectedOverlay();
|
|
492
|
+
}, renderShipSelectedChange = () => {
|
|
493
|
+
console.log("selectedShip------------------", selectedShip);
|
|
494
|
+
const e = shipsSource.getFeatures().find((t) => t.get("id") === (selectedShip == null ? void 0 : selectedShip.id));
|
|
495
|
+
if (console.log("hasShipFetature------------------", e), e)
|
|
496
|
+
hasShip == null || hasShip.setStyle(createShipStyle(hasShip)), createLabelStyle(hasShip);
|
|
497
|
+
else {
|
|
498
|
+
const t = createShipFetature(selectedShip);
|
|
499
|
+
shipsSource.addFeature(t), createLabelStyle(t);
|
|
500
|
+
}
|
|
501
|
+
handleChangeSelected();
|
|
502
|
+
}, handleShipMapEvent = debounce((e, t, n) => {
|
|
503
|
+
const o = getInstall();
|
|
478
504
|
if (e) {
|
|
479
|
-
const r = e.get("shipData"),
|
|
480
|
-
if (
|
|
481
|
-
hoveredShipId && hoveredShipId !==
|
|
482
|
-
const
|
|
483
|
-
|
|
505
|
+
const r = e.get("shipData"), l = e.get("id");
|
|
506
|
+
if (o.getTargetElement().style.cursor = l ? "pointer" : "", t === "click" && (renderShipSelected(r), n && n(l)), t === "hover") {
|
|
507
|
+
hoveredShipId && hoveredShipId !== l && clearHoverHight(), hoveredShipId = l;
|
|
508
|
+
const s = shipsSource.getFeatures().find((a) => a.get("id") === hoveredShipId);
|
|
509
|
+
s == null || s.set("isHighlight", !0), s == null || s.setStyle(createShipStyle(s));
|
|
484
510
|
}
|
|
485
511
|
} else
|
|
486
|
-
|
|
512
|
+
o.getTargetElement().style.cursor = "", clearHoverHight();
|
|
487
513
|
}, 10), clearHoverHight = () => {
|
|
488
514
|
const e = hoveredShipId ? shipsSource.getFeatures().find((t) => t.get("id") === hoveredShipId) : null;
|
|
489
515
|
hoveredShipId = null, e == null || e.set("isHighlight", !1), e == null || e.setStyle(createShipStyle(e));
|
|
490
516
|
}, removeSelectedOverlay = () => {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
n
|
|
494
|
-
})
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
return [Number(e) / 6e5, o];
|
|
517
|
+
try {
|
|
518
|
+
const e = getInstall(), n = cloneDeep(e.getOverlays().getArray()).find((o) => o.get("class") == "ship-overlay-selected");
|
|
519
|
+
n && n.get("element") && (n.get("element").style.visibility = "hidden");
|
|
520
|
+
} catch (e) {
|
|
521
|
+
console.log(e);
|
|
522
|
+
}
|
|
498
523
|
}, stopIcon = "", stopColor = "#E31818", slowIcon = "", slowColor = "#1890FF", dropletsIcon = "", DEFAULT_VALUE = "--";
|
|
499
524
|
let moveFeatureHandler = null;
|
|
500
525
|
const stopIconStyle = getIconStyle(stopIcon), slowIconStyle = getIconStyle(slowIcon), popupEle = document.createElement("div"), popupOverlay = new Overlay({
|
|
501
526
|
element: popupEle,
|
|
502
527
|
positioning: "top-left",
|
|
503
528
|
stopEvent: !1,
|
|
504
|
-
className: "track-label-
|
|
529
|
+
className: "track-label-popup"
|
|
505
530
|
});
|
|
506
531
|
let polyline, linePath, startMarker, position, geoMarker, trackAnimating = !1, lastTime = Date.now(), vectorLayer$3, distance = 0, thresholdNum = 20;
|
|
507
532
|
const routesSource = new VectorSource(), routeLayer = new VectorLayer({
|
|
@@ -509,57 +534,59 @@ const routesSource = new VectorSource(), routeLayer = new VectorLayer({
|
|
|
509
534
|
className: "zh-map--track-layer",
|
|
510
535
|
zIndex: 102
|
|
511
536
|
});
|
|
512
|
-
let routeFeatures = [], showTracks = [], allTracks = {}, trackId = "", trackColor = "", trackList = [], mapInstance$1 = null;
|
|
537
|
+
let routeFeatures = [], showTracks = [], allTracks = {}, trackId = "", trackColor = "", trackList = [], mapInstance$1 = null, isClosing = !1;
|
|
513
538
|
const reRenderTrackLine = () => {
|
|
514
|
-
mapInstance$1 = getInstall(), handlerRenderLine();
|
|
515
|
-
}, renderTrackLine = async (e, t,
|
|
539
|
+
mapInstance$1 = getInstall(), isClosing || handlerRenderLine();
|
|
540
|
+
}, renderTrackLine = async (e, t, n, o = LENGTH_UNIT.NM, r = "ship", l = 200) => {
|
|
516
541
|
if (mapInstance$1 = getInstall(), !mapInstance$1) return;
|
|
517
|
-
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)),
|
|
518
|
-
(showTracks == null ? void 0 : showTracks.findIndex((
|
|
542
|
+
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)), renderShipSelectedChange(), isClosing = !1, (t == null ? void 0 : t.length) < 2) {
|
|
543
|
+
(showTracks == null ? void 0 : showTracks.findIndex((i) => i.id === e)) < 0 && showTracks.push({ id: e, length: "" });
|
|
519
544
|
return;
|
|
520
545
|
}
|
|
521
|
-
const
|
|
522
|
-
t.forEach((
|
|
523
|
-
|
|
524
|
-
}), trackId = e,
|
|
525
|
-
const
|
|
526
|
-
(
|
|
527
|
-
), c = new LineString(
|
|
528
|
-
|
|
546
|
+
const s = {};
|
|
547
|
+
t.forEach((i) => {
|
|
548
|
+
i.state ? i.state = Number(i.state) : delete i.state;
|
|
549
|
+
}), trackId = e, s[e] = t, trackList = t;
|
|
550
|
+
const a = s[e].map(
|
|
551
|
+
(i) => transform([i.lon, i.lat], projection.data, projection.mercator)
|
|
552
|
+
), c = new LineString(a), d = formatLength(c, o) || "--";
|
|
553
|
+
console.log("length", formatLength(c, o));
|
|
554
|
+
const u = showTracks == null ? void 0 : showTracks.findIndex((i) => i.id === e);
|
|
555
|
+
u < 0 ? showTracks.push({ id: e, length: d }) : showTracks[u].length = d, console.log("showTracks", showTracks), allTracks[e] = t, trackList = [], trackColor = n, thresholdNum = l, await handlerRenderLine(), await setTrackViewCenter(trackId);
|
|
529
556
|
}, handlerRenderLine = async () => {
|
|
530
|
-
const e = trackColor || "", t = trackId,
|
|
531
|
-
trackList =
|
|
532
|
-
if (Number(
|
|
533
|
-
const [d, u] = convertSixHundredThousandToLatLng(
|
|
534
|
-
|
|
557
|
+
const e = trackColor || "", t = trackId, n = allTracks[trackId] || [], o = thresholdNum || 200, r = Math.max(1, Math.floor(n.length / o));
|
|
558
|
+
trackList = n.filter((a, c) => c % r === 0).map((a, c) => {
|
|
559
|
+
if (Number(a.lon) > 180 || Number(a.lat) > 180) {
|
|
560
|
+
const [d, u] = convertSixHundredThousandToLatLng(a.lon, a.lat);
|
|
561
|
+
a.lon = d, a.lat = u;
|
|
535
562
|
}
|
|
536
|
-
return
|
|
563
|
+
return a.center = [a.lon, a.lat], a.centerPoint = lonLatToMercator(a.center), a.id = t, a.index = c, a.time = hooks(a.createdAt).format("YYYY-MM-DD HH:mm:ss"), a;
|
|
537
564
|
});
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
}, createTrackLineFeature = (e, t,
|
|
541
|
-
var
|
|
542
|
-
const
|
|
543
|
-
r.setStyle(createTrackLineStyle(
|
|
544
|
-
const
|
|
545
|
-
|
|
565
|
+
const s = trackList.map((a) => a.centerPoint);
|
|
566
|
+
s.length >= 2 && (mapInstance$1 == null || mapInstance$1.addLayer(routeLayer), await createTrackLineFeature(t, s, e));
|
|
567
|
+
}, createTrackLineFeature = (e, t, n) => {
|
|
568
|
+
var s;
|
|
569
|
+
const o = new LineString(t), r = new Feature({ geometry: o });
|
|
570
|
+
r.setStyle(createTrackLineStyle(n)), r.setId(e), r.set("type", "line"), (s = routeLayer == null ? void 0 : routeLayer.getSource()) == null || s.clear(), removeAllLabel(), routeFeatures = [];
|
|
571
|
+
const l = routeFeatures.findIndex((a) => a.getId() === e);
|
|
572
|
+
l >= 0 ? routeFeatures[l] = r : routeFeatures.push(r), routesSource.addFeatures([...routeFeatures]), createPointFeature(n);
|
|
546
573
|
}, createTrackLineStyle = (e) => new Style({
|
|
547
574
|
stroke: new Stroke({
|
|
548
575
|
color: e,
|
|
549
576
|
width: 2
|
|
550
577
|
})
|
|
551
|
-
}), handleTrackMapEvent = (e, t,
|
|
552
|
-
const
|
|
553
|
-
if (e &&
|
|
554
|
-
mapInstance$1.getTargetElement().style.cursor =
|
|
555
|
-
const r = e.get("data"),
|
|
556
|
-
|
|
578
|
+
}), handleTrackMapEvent = (e, t, n) => {
|
|
579
|
+
const o = e == null ? void 0 : e.get("trackId");
|
|
580
|
+
if (e && o && t === "hover") {
|
|
581
|
+
mapInstance$1.getTargetElement().style.cursor = o ? "pointer" : "";
|
|
582
|
+
const r = e.get("data"), l = renderTrackPointHtml(r), s = n == null ? void 0 : n.coordinate;
|
|
583
|
+
s && (popupEle.querySelector(".popup-content"), popupEle.innerHTML = l, popupOverlay == null || popupOverlay.setPosition(s));
|
|
557
584
|
} else
|
|
558
585
|
popupOverlay && popupOverlay.setPosition(void 0);
|
|
559
586
|
}, formatMinutesToDDHHMM = (e) => {
|
|
560
|
-
const t = hooks.duration(e, "minutes"),
|
|
561
|
-
let
|
|
562
|
-
return
|
|
587
|
+
const t = hooks.duration(e, "minutes"), n = Math.floor(t.asDays()), o = t.hours(), r = t.minutes();
|
|
588
|
+
let l = `${String(r).padStart(2, "0")}分`;
|
|
589
|
+
return o !== 0 && (l = `${String(o).padStart(2, "0")}时${l}`), n !== 0 && (l = `${String(n).padStart(2, "0")}天${l}`), l;
|
|
563
590
|
}, renderTrackPointHtml = (e) => {
|
|
564
591
|
if (!(e != null && e.time)) return;
|
|
565
592
|
let t = "";
|
|
@@ -603,44 +630,44 @@ const reRenderTrackLine = () => {
|
|
|
603
630
|
}, createPointFeature = (e) => {
|
|
604
631
|
const t = trackList || [];
|
|
605
632
|
if (!(t && t.length > 1)) return [];
|
|
606
|
-
const
|
|
607
|
-
for (let
|
|
608
|
-
t[
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
611
|
-
let c =
|
|
633
|
+
const n = { 16: 24, 17: 15, default: 4 }, o = [], r = t.length;
|
|
634
|
+
for (let s = 0; s < r; s++) {
|
|
635
|
+
t[s].index = s;
|
|
636
|
+
const a = mapInstance$1 == null ? void 0 : mapInstance$1.getPixelFromCoordinate(t[s].centerPoint);
|
|
637
|
+
if (a) {
|
|
638
|
+
let c = a.concat(a);
|
|
612
639
|
c = adjustBounds(c, [20, 20]);
|
|
613
640
|
const d = mapInstance$1 == null ? void 0 : mapInstance$1.getView().getZoom();
|
|
614
641
|
if (!d) return;
|
|
615
642
|
if (d > 15) {
|
|
616
|
-
const
|
|
617
|
-
c = adjustBounds(c, [
|
|
643
|
+
const i = n[d] || n.default;
|
|
644
|
+
c = adjustBounds(c, [i, i]);
|
|
618
645
|
}
|
|
619
646
|
let u = !0;
|
|
620
|
-
if (t[
|
|
621
|
-
for (let
|
|
622
|
-
if (isOverlapping$1(c,
|
|
647
|
+
if (t[s].state !== "0") {
|
|
648
|
+
for (let i = 0; i < o.length; i++)
|
|
649
|
+
if (isOverlapping$1(c, o[i].bounds)) {
|
|
623
650
|
u = !1;
|
|
624
651
|
break;
|
|
625
652
|
}
|
|
626
653
|
}
|
|
627
|
-
u && (t[
|
|
654
|
+
u && (t[s].bounds = c, o.push(t[s]));
|
|
628
655
|
}
|
|
629
656
|
}
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
const
|
|
633
|
-
geometry: new Point(
|
|
634
|
-
time:
|
|
657
|
+
const l = [];
|
|
658
|
+
o.forEach((s) => {
|
|
659
|
+
const a = new Feature({
|
|
660
|
+
geometry: new Point(s.centerPoint),
|
|
661
|
+
time: s.time
|
|
635
662
|
});
|
|
636
|
-
|
|
637
|
-
}), routesSource.addFeatures(
|
|
638
|
-
const
|
|
663
|
+
a.set("type", "track_point"), a.set("trackId", s.id), a.set("data", s), a.setStyle(createPointStyle(e)), l.push(a), typeof s == "object" && Object.prototype.hasOwnProperty.call(s, "state") && createIconFeature(s);
|
|
664
|
+
}), routesSource.addFeatures(l), console.log("createPointLabelOverlay---------------"), l.forEach((s) => {
|
|
665
|
+
const a = s.getProperties().data, c = createPointLabelOverlay(e, a);
|
|
639
666
|
mapInstance$1 == null || mapInstance$1.addOverlay(c);
|
|
640
|
-
}), createArrowFetaure(
|
|
667
|
+
}), createArrowFetaure(o, e), createIconPointFeature();
|
|
641
668
|
}, createPointLabelOverlay = (e, t) => {
|
|
642
|
-
const
|
|
643
|
-
|
|
669
|
+
const n = document.createElement("div");
|
|
670
|
+
n.className = "track-overlay-label", n.style.position = "relative", n.style.backgroundColor = "rgba(255,255,255,0.8)", n.style.border = `1px solid ${e}`, n.style.fontSize = "12px", n.innerHTML = `
|
|
644
671
|
<span>${t.time}</span>
|
|
645
672
|
<svg
|
|
646
673
|
style="position: absolute;left: -20px;top: 0;"
|
|
@@ -653,18 +680,19 @@ const reRenderTrackLine = () => {
|
|
|
653
680
|
stroke="${e}"
|
|
654
681
|
stroke-width="1" />
|
|
655
682
|
`;
|
|
656
|
-
const
|
|
657
|
-
element:
|
|
683
|
+
const o = new Overlay({
|
|
684
|
+
element: n,
|
|
658
685
|
position: fromLonLat(t.center),
|
|
659
686
|
positioning: "top-left",
|
|
660
687
|
offset: [20, -20],
|
|
688
|
+
stopEvent: !1,
|
|
661
689
|
className: "track-label-time-overlay"
|
|
662
690
|
});
|
|
663
|
-
return
|
|
691
|
+
return o.set("class", "track-label-overlay"), o;
|
|
664
692
|
}, removeAllLabel = () => {
|
|
665
|
-
const e = mapInstance$1 == null ? void 0 : mapInstance$1.getOverlays().getArray(), t = e == null ? void 0 : e.filter((
|
|
666
|
-
t && t.length > 0 && t.forEach((
|
|
667
|
-
|
|
693
|
+
const e = cloneDeep(mapInstance$1 == null ? void 0 : mapInstance$1.getOverlays().getArray()), t = e == null ? void 0 : e.filter((n) => n.get("class") === "track-label-overlay");
|
|
694
|
+
t && t.length > 0 && t.forEach((n) => {
|
|
695
|
+
n.setPosition(void 0), n.setElement(void 0), mapInstance$1 == null || mapInstance$1.removeOverlay(n), n.dispose();
|
|
668
696
|
});
|
|
669
697
|
}, createPointStyle = (e) => [
|
|
670
698
|
new Style({
|
|
@@ -784,7 +812,7 @@ const reRenderTrackLine = () => {
|
|
|
784
812
|
time: e.time
|
|
785
813
|
});
|
|
786
814
|
t.set("type", "track_icon");
|
|
787
|
-
const
|
|
815
|
+
const n = new Style({
|
|
788
816
|
text: new Text({
|
|
789
817
|
font: "Normal 22px map-iconfont",
|
|
790
818
|
text: getIconFont(dropletsIcon),
|
|
@@ -794,26 +822,26 @@ const reRenderTrackLine = () => {
|
|
|
794
822
|
})
|
|
795
823
|
}),
|
|
796
824
|
zIndex: 99
|
|
797
|
-
}),
|
|
798
|
-
Number(e.state) === 0 ?
|
|
825
|
+
}), o = [];
|
|
826
|
+
Number(e.state) === 0 ? o.push(stopIconStyle) : Number(e.state) === 1 && o.push(slowIconStyle), o.push(n), t.setStyle(o), routesSource.addFeature(t);
|
|
799
827
|
}, createArrowFetaure = (e, t) => {
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
for (let r = 0; r <
|
|
803
|
-
let
|
|
804
|
-
const
|
|
805
|
-
if (
|
|
806
|
-
|
|
828
|
+
const n = e || [], o = e.length;
|
|
829
|
+
o || (n.push(trackList[0]), n.push(trackList[trackList.length - 1]));
|
|
830
|
+
for (let r = 0; r < o - 1; r++) {
|
|
831
|
+
let l;
|
|
832
|
+
const s = e[r], a = (e[r + 1].index + s.index) / 2;
|
|
833
|
+
if (a % 2 === 0)
|
|
834
|
+
l = trackList[a].centerPoint;
|
|
807
835
|
else {
|
|
808
|
-
const c = trackList[Math.floor(
|
|
836
|
+
const c = trackList[Math.floor(a)], d = trackList[Math.ceil(a)];
|
|
809
837
|
if (c && d) {
|
|
810
|
-
const [u,
|
|
811
|
-
|
|
838
|
+
const [u, i] = c.centerPoint, [p, m] = d.centerPoint;
|
|
839
|
+
l = [(u + p) / 2, (i + m) / 2];
|
|
812
840
|
}
|
|
813
841
|
}
|
|
814
|
-
if (
|
|
842
|
+
if (l) {
|
|
815
843
|
const c = new Feature({
|
|
816
|
-
geometry: new Point(
|
|
844
|
+
geometry: new Point(l)
|
|
817
845
|
});
|
|
818
846
|
c.set("type", "track_arrow"), c.setStyle(
|
|
819
847
|
new Style({
|
|
@@ -833,34 +861,34 @@ const reRenderTrackLine = () => {
|
|
|
833
861
|
}
|
|
834
862
|
}, setTrackViewCenter = (e) => {
|
|
835
863
|
var r;
|
|
836
|
-
const t = mapInstance$1.getView(),
|
|
837
|
-
if (!
|
|
838
|
-
const
|
|
839
|
-
if (
|
|
864
|
+
const t = mapInstance$1.getView(), n = e ? routeFeatures.find((l) => l.getId() === e) : routeFeatures[0];
|
|
865
|
+
if (!n) return;
|
|
866
|
+
const o = (r = n == null ? void 0 : n.getGeometry()) == null ? void 0 : r.getExtent();
|
|
867
|
+
if (o != null && o.length)
|
|
840
868
|
try {
|
|
841
|
-
const
|
|
842
|
-
t.fit(
|
|
843
|
-
} catch (
|
|
844
|
-
console.log(
|
|
869
|
+
const l = buffer(o, Math.max(o[2] - o[0], o[3] - o[1]) * 0.02);
|
|
870
|
+
t.fit(l);
|
|
871
|
+
} catch (l) {
|
|
872
|
+
console.log(l);
|
|
845
873
|
}
|
|
846
874
|
}, createIconPointFeature = () => {
|
|
847
|
-
const e = "", t = "#fcdc3f",
|
|
875
|
+
const e = "", t = "#fcdc3f", n = "#ff0000";
|
|
848
876
|
(trackList.length < 2 ? [trackList[0]] : [trackList[0], trackList[trackList.length - 1]]).forEach((r) => {
|
|
849
|
-
const
|
|
877
|
+
const l = new Feature({
|
|
850
878
|
geometry: new Point(r.centerPoint)
|
|
851
879
|
});
|
|
852
|
-
|
|
853
|
-
const
|
|
854
|
-
|
|
880
|
+
l.set("type", "track_begin"), l.set("data", r);
|
|
881
|
+
const s = r.index === 0 && trackList.length >= 2 ? t : n;
|
|
882
|
+
l.setStyle(
|
|
855
883
|
new Style({
|
|
856
884
|
text: new Text({
|
|
857
885
|
font: "Normal 14px map-iconfont",
|
|
858
886
|
text: getIconFont(e),
|
|
859
|
-
fill: new Fill({ color:
|
|
887
|
+
fill: new Fill({ color: s })
|
|
860
888
|
}),
|
|
861
889
|
zIndex: 101
|
|
862
890
|
})
|
|
863
|
-
), routesSource.addFeature(
|
|
891
|
+
), routesSource.addFeature(l);
|
|
864
892
|
});
|
|
865
893
|
}, geoMarkerStyle = new Style({
|
|
866
894
|
text: new Text({
|
|
@@ -875,28 +903,32 @@ const reRenderTrackLine = () => {
|
|
|
875
903
|
}, removeAllTrackLayer = () => {
|
|
876
904
|
showTracks = [], allTracks = {}, routesSource == null || routesSource.clear();
|
|
877
905
|
}, closeTrack = (e = !1) => {
|
|
878
|
-
routeLayer == null || routeLayer.setVisible(!1)
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
906
|
+
routeLayer == null || routeLayer.setVisible(!1);
|
|
907
|
+
const t = getInstall();
|
|
908
|
+
cloneDeep(t.getOverlays().getArray()).forEach((o) => {
|
|
909
|
+
o.get("class") === "track-label-overlay" && (o.setPosition(void 0), t.removeOverlay(o), o.dispose());
|
|
910
|
+
}), e && removeAllTrackLayer(), stopAnimation(), isClosing = !0;
|
|
911
|
+
}, getShowTracks = () => showTracks, handlePlay = (e, t) => {
|
|
912
|
+
const n = allTracks[String(e)];
|
|
913
|
+
playAnimation(n == null ? void 0 : n.map((o) => [o.lon, o.lat]), t);
|
|
882
914
|
}, moveFeature = (e, t) => {
|
|
883
|
-
var
|
|
884
|
-
const
|
|
885
|
-
if (distance = (distance +
|
|
915
|
+
var i, p;
|
|
916
|
+
const n = Number(50 * t), o = ((i = e.frameState) == null ? void 0 : i.time) ?? Date.now(), r = o - lastTime;
|
|
917
|
+
if (distance = (distance + n * r / 1e6) % 2, lastTime = o, distance >= 1) {
|
|
886
918
|
stopAnimation();
|
|
887
919
|
return;
|
|
888
920
|
}
|
|
889
|
-
const
|
|
921
|
+
const l = linePath.getCoordinateAt(
|
|
890
922
|
distance > 1 ? 2 - distance : distance
|
|
891
|
-
),
|
|
923
|
+
), s = linePath.getCoordinateAt(
|
|
892
924
|
distance > 1 ? distance - 0.01 : distance
|
|
893
|
-
),
|
|
925
|
+
), a = linePath.getCoordinateAt(
|
|
894
926
|
distance > 1 ? 2 - distance : distance + 0.01
|
|
895
927
|
), d = getRotation(
|
|
896
|
-
mercatorToLonLat(
|
|
897
|
-
mercatorToLonLat(
|
|
928
|
+
mercatorToLonLat(s, "array"),
|
|
929
|
+
mercatorToLonLat(a, "array")
|
|
898
930
|
) * Math.PI / 180;
|
|
899
|
-
(p = geoMarkerStyle.getText()) == null || p.setRotation(d), position.setCoordinates(
|
|
931
|
+
(p = geoMarkerStyle.getText()) == null || p.setRotation(d), position.setCoordinates(l);
|
|
900
932
|
const u = getVectorContext(e);
|
|
901
933
|
u.setStyle(geoMarkerStyle), u.drawGeometry(position), mapInstance$1 == null || mapInstance$1.render();
|
|
902
934
|
}, startAnimation = () => {
|
|
@@ -916,8 +948,8 @@ const reRenderTrackLine = () => {
|
|
|
916
948
|
type: "icon",
|
|
917
949
|
geometry: new Point(linePath.getFirstCoordinate())
|
|
918
950
|
});
|
|
919
|
-
const
|
|
920
|
-
position =
|
|
951
|
+
const n = startMarker.getGeometry();
|
|
952
|
+
position = n ? n.clone() : new Point([0, 0]), geoMarker = new Feature({
|
|
921
953
|
type: "geoMarker",
|
|
922
954
|
style: geoMarkerStyle,
|
|
923
955
|
geometry: position
|
|
@@ -925,43 +957,43 @@ const reRenderTrackLine = () => {
|
|
|
925
957
|
source: new VectorSource({
|
|
926
958
|
features: [geoMarker]
|
|
927
959
|
})
|
|
928
|
-
}), mapInstance$1 == null || mapInstance$1.addLayer(vectorLayer$3), moveFeatureHandler = (
|
|
929
|
-
}, getRotation = (e, t,
|
|
930
|
-
function
|
|
931
|
-
return 180 * (
|
|
960
|
+
}), mapInstance$1 == null || mapInstance$1.addLayer(vectorLayer$3), moveFeatureHandler = (o) => moveFeature(o, t), startAnimation();
|
|
961
|
+
}, getRotation = (e, t, n) => {
|
|
962
|
+
function o(i) {
|
|
963
|
+
return 180 * (i % (2 * Math.PI)) / Math.PI;
|
|
932
964
|
}
|
|
933
|
-
function r(
|
|
934
|
-
return
|
|
965
|
+
function r(i) {
|
|
966
|
+
return i % 360 * Math.PI / 180;
|
|
935
967
|
}
|
|
936
|
-
function
|
|
968
|
+
function l(i) {
|
|
937
969
|
var p;
|
|
938
|
-
if (!
|
|
939
|
-
if (!Array.isArray(
|
|
940
|
-
if ((
|
|
941
|
-
return
|
|
942
|
-
if (
|
|
970
|
+
if (!i) throw new Error("Coordinate is required");
|
|
971
|
+
if (!Array.isArray(i)) {
|
|
972
|
+
if ((i == null ? void 0 : i.type) === "Feature" && (i == null ? void 0 : i.geometry) !== null && ((p = i == null ? void 0 : i.geometry) == null ? void 0 : p.type) === "Point")
|
|
973
|
+
return i == null ? void 0 : i.geometry.coordinates;
|
|
974
|
+
if (i.type === "Point") return (i == null ? void 0 : i.coordinates) || [];
|
|
943
975
|
}
|
|
944
|
-
if (Array.isArray(
|
|
945
|
-
return
|
|
976
|
+
if (Array.isArray(i) && i.length >= 2 && !Array.isArray(i[0]) && !Array.isArray(i[1]))
|
|
977
|
+
return i;
|
|
946
978
|
throw new Error(
|
|
947
979
|
"Coordinate must be GeoJSON Point or an Array of numbers"
|
|
948
980
|
);
|
|
949
981
|
}
|
|
950
|
-
function
|
|
982
|
+
function s(i, p, m = {}) {
|
|
951
983
|
if (m.final)
|
|
952
|
-
return function(k,
|
|
953
|
-
return (
|
|
954
|
-
}(
|
|
955
|
-
const g =
|
|
956
|
-
return
|
|
984
|
+
return function(k, S) {
|
|
985
|
+
return (s(S, k) + 180) % 360;
|
|
986
|
+
}(i, p);
|
|
987
|
+
const g = l(i), y = l(p), v = r(g[0]), w = r(y[0]), T = r(g[1]), f = r(y[1]), L = Math.sin(w - v) * Math.cos(f), E = Math.cos(T) * Math.sin(f) - Math.sin(T) * Math.cos(f) * Math.cos(w - v);
|
|
988
|
+
return o(Math.atan2(L, E));
|
|
957
989
|
}
|
|
958
|
-
function i
|
|
959
|
-
return !isNaN(
|
|
990
|
+
function a(i) {
|
|
991
|
+
return !isNaN(i) && i !== null && !Array.isArray(i);
|
|
960
992
|
}
|
|
961
|
-
function c(
|
|
962
|
-
return
|
|
993
|
+
function c(i, p = {}, m = {}) {
|
|
994
|
+
return i || console.log("Coordinates are required"), Array.isArray(i) || console.log("Coordinates must be an Array"), i.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!a(i[0]) || !a(i[1])) && console.log("Coordinates must contain numbers"), d({ type: "Point", coordinates: i }, p, m);
|
|
963
995
|
}
|
|
964
|
-
function d(
|
|
996
|
+
function d(i, p = {}, m = {}) {
|
|
965
997
|
const g = {
|
|
966
998
|
type: "Feature",
|
|
967
999
|
id: "",
|
|
@@ -969,30 +1001,35 @@ const reRenderTrackLine = () => {
|
|
|
969
1001
|
bbox: {},
|
|
970
1002
|
geometry: {}
|
|
971
1003
|
};
|
|
972
|
-
return m.id !== void 0 && (g.id = m.id), m.bbox && (g.bbox = m.bbox), g.properties = p, g.geometry =
|
|
1004
|
+
return m.id !== void 0 && (g.id = m.id), m.bbox && (g.bbox = m.bbox), g.properties = p, g.geometry = i, g;
|
|
973
1005
|
}
|
|
974
|
-
const u =
|
|
1006
|
+
const u = s(c(e), c(t), n);
|
|
975
1007
|
return u < 0 ? 360 + u : u;
|
|
976
1008
|
}, PORT_LAYER_CLASS_NAME = "zh-map-port-layer";
|
|
977
1009
|
let vectorLayer$2, vectorSource$2;
|
|
978
1010
|
const renderPortList = (e) => {
|
|
979
|
-
var
|
|
980
|
-
if (!e || e.length === 0)
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
}
|
|
993
|
-
},
|
|
994
|
-
const
|
|
995
|
-
|
|
1011
|
+
var t;
|
|
1012
|
+
if (!(!e || e.length === 0)) {
|
|
1013
|
+
if (vectorSource$2 || (vectorSource$2 = new VectorSource()), vectorSource$2.clear(), selectedPortData) {
|
|
1014
|
+
const n = e.find((o) => o.id === selectedPortData.id);
|
|
1015
|
+
n ? selectedPortData = n : e.push(selectedPortData);
|
|
1016
|
+
}
|
|
1017
|
+
e.forEach((n) => {
|
|
1018
|
+
renderPortPoint(n);
|
|
1019
|
+
}), vectorLayer$2 || (vectorLayer$2 = new VectorLayer({
|
|
1020
|
+
className: PORT_LAYER_CLASS_NAME,
|
|
1021
|
+
source: vectorSource$2,
|
|
1022
|
+
zIndex: 100
|
|
1023
|
+
}), (t = getInstall()) == null || t.addLayer(vectorLayer$2));
|
|
1024
|
+
}
|
|
1025
|
+
}, renderPortPoint = (e) => {
|
|
1026
|
+
const t = getZoom(), [n, o] = e.latLon.split(","), r = new Feature({
|
|
1027
|
+
geometry: new Point(fromLonLat([Number(n), Number(o)]))
|
|
1028
|
+
});
|
|
1029
|
+
r.setStyle(setPortStyle(e, t, e.id === (selectedPortData == null ? void 0 : selectedPortData.id))), r.set("portData", e), vectorSource$2.addFeature(r);
|
|
1030
|
+
}, setPortStyle = (e, t, n) => {
|
|
1031
|
+
const o = (l) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1032
|
+
<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="${l}"/>
|
|
996
1033
|
<g clip-path="url(#clip0_10059_122082)">
|
|
997
1034
|
<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"/>
|
|
998
1035
|
</g>
|
|
@@ -1002,16 +1039,16 @@ const renderPortList = (e) => {
|
|
|
1002
1039
|
</clipPath>
|
|
1003
1040
|
</defs>
|
|
1004
1041
|
</svg>
|
|
1005
|
-
`, r = () => `data:image/svg+xml;utf8,${encodeURIComponent(n
|
|
1042
|
+
`, r = () => `data:image/svg+xml;utf8,${encodeURIComponent(o(n ? "#FF5733" : "#3370FF"))}`;
|
|
1006
1043
|
return new Style({
|
|
1007
1044
|
text: new Text({
|
|
1008
1045
|
text: e.shortName,
|
|
1009
1046
|
font: "12px sans-serif",
|
|
1010
1047
|
fill: new Fill({
|
|
1011
|
-
color:
|
|
1048
|
+
color: n ? "#ffffff" : "#000000"
|
|
1012
1049
|
}),
|
|
1013
1050
|
backgroundFill: new Fill({
|
|
1014
|
-
color:
|
|
1051
|
+
color: n ? "#FF5733" : "#FFFFFF"
|
|
1015
1052
|
}),
|
|
1016
1053
|
offsetY: 30
|
|
1017
1054
|
}),
|
|
@@ -1029,21 +1066,26 @@ const renderPortList = (e) => {
|
|
|
1029
1066
|
});
|
|
1030
1067
|
} else
|
|
1031
1068
|
console.log("清除所有港口"), vectorSource$2.clear();
|
|
1069
|
+
}, clearSelectedPort = () => {
|
|
1070
|
+
const e = selectedPortFeature.get("portData"), t = getZoom();
|
|
1071
|
+
vectorSource$2.getFeatures().forEach((o) => {
|
|
1072
|
+
o.get("portData").id === e.id && (o == null || o.setStyle(setPortStyle(e, t, !1)));
|
|
1073
|
+
}), selectedPortData = null, selectedPortFeature = null;
|
|
1032
1074
|
};
|
|
1033
|
-
let selectedPortFeature = null;
|
|
1075
|
+
let selectedPortFeature = null, selectedPortData = null;
|
|
1034
1076
|
const selectedPort = (e) => {
|
|
1035
|
-
clearPrevSelectedPort(), addSelectedPortStyle(e);
|
|
1077
|
+
e ? (clearPrevSelectedPort(), addSelectedPortStyle(e)) : clearSelectedPort();
|
|
1036
1078
|
}, clearPrevSelectedPort = () => {
|
|
1037
1079
|
if (selectedPortFeature) {
|
|
1038
1080
|
const e = selectedPortFeature.get("portData"), t = getZoom();
|
|
1039
1081
|
selectedPortFeature.setStyle(setPortStyle(e, t, !1));
|
|
1040
1082
|
}
|
|
1041
1083
|
}, addSelectedPortStyle = (e) => {
|
|
1042
|
-
const t =
|
|
1043
|
-
|
|
1084
|
+
const t = vectorSource$2.getFeatures();
|
|
1085
|
+
selectedPortData = e, selectedPortFeature = t.find((n) => n.get("portData").id === e.id);
|
|
1044
1086
|
}, handlePortHover = (e) => {
|
|
1045
|
-
const t = getInstall(),
|
|
1046
|
-
|
|
1087
|
+
const t = getInstall(), n = t.forEachFeatureAtPixel(e, (o) => o);
|
|
1088
|
+
n && n.get("portData") && (t.getTargetElement().style.cursor = "pointer");
|
|
1047
1089
|
}, disableDoubleClickZoom = () => {
|
|
1048
1090
|
getInstall().getInteractions().forEach((t) => {
|
|
1049
1091
|
t instanceof DoubleClickZoom && t.setActive(!1);
|
|
@@ -1117,25 +1159,25 @@ const addInteraction = () => {
|
|
|
1117
1159
|
}), getInstall().addInteraction(draw$1), createMeasureTooltip$1(), createHelpTooltip$1();
|
|
1118
1160
|
let e;
|
|
1119
1161
|
draw$1.on("drawstart", function(t) {
|
|
1120
|
-
var
|
|
1162
|
+
var o;
|
|
1121
1163
|
sketch$1 = t.feature, sketch$1.set("randomId", generateRandomId());
|
|
1122
|
-
let
|
|
1123
|
-
e = (
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1164
|
+
let n;
|
|
1165
|
+
e = (o = sketch$1.getGeometry()) == null ? void 0 : o.on("change", function(r) {
|
|
1166
|
+
const l = r.target, s = computedDistance(l, unit.value);
|
|
1167
|
+
n = l.getLastCoordinate(), measureTooltipElement$1 && s && (measureTooltipElement$1.innerHTML = s), measureTooltip$1.setPosition(n);
|
|
1126
1168
|
});
|
|
1127
1169
|
}), draw$1.on("drawend", function() {
|
|
1128
|
-
var t,
|
|
1170
|
+
var t, n, o;
|
|
1129
1171
|
if (measureTooltipElement$1 && (measureTooltipElement$1.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), measureTooltipElement$1 != null && measureTooltipElement$1.innerHTML) {
|
|
1130
1172
|
const r = (sketch$1 == null ? void 0 : sketch$1.get("randomId")) || generateRandomId();
|
|
1131
1173
|
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>`;
|
|
1132
1174
|
}
|
|
1133
1175
|
(t = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || t.addEventListener("click", (r) => {
|
|
1134
|
-
var
|
|
1176
|
+
var s;
|
|
1135
1177
|
r.preventDefault(), r.stopPropagation();
|
|
1136
|
-
const
|
|
1137
|
-
|
|
1138
|
-
}), measureTooltip$1.setOffset([0, -7]), sketch$1 = null, measureTooltipElement$1 = null, createMeasureTooltip$1(), e && unByKey(e), (
|
|
1178
|
+
const l = (s = r.target) == null ? void 0 : s.getAttribute("data-id");
|
|
1179
|
+
l && deleteLine(l);
|
|
1180
|
+
}), measureTooltip$1.setOffset([0, -7]), sketch$1 = null, measureTooltipElement$1 = null, createMeasureTooltip$1(), e && unByKey(e), (n = getProps()) != null && n.lineDrawEnd && ((o = getProps()) == null || o.lineDrawEnd(measureHistory.value));
|
|
1139
1181
|
});
|
|
1140
1182
|
}, generateRandomId = () => Math.random().toString(36).substring(2, 9);
|
|
1141
1183
|
let measureTooltipElement$1, measureTooltip$1;
|
|
@@ -1155,46 +1197,46 @@ const createMeasureTooltip$1 = () => {
|
|
|
1155
1197
|
}), getInstall().addOverlay(helpTooltip);
|
|
1156
1198
|
}, close$1 = () => {
|
|
1157
1199
|
measureHistory.value.forEach((e, t) => {
|
|
1158
|
-
var r,
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1200
|
+
var r, l;
|
|
1201
|
+
const n = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
|
|
1202
|
+
n[t] && ((l = (r = n[t]) == null ? void 0 : r.parentNode) == null || l.removeChild(n[t]));
|
|
1203
|
+
const o = vectorSource$1.getFeatures();
|
|
1204
|
+
o[t] && vectorSource$1.removeFeature(o[t]);
|
|
1163
1205
|
}), removeInteraction(), enableDoubleClickZoom(), state.value = !1;
|
|
1164
1206
|
}, deleteLine = (e) => {
|
|
1165
|
-
var
|
|
1166
|
-
const t = measureHistory.value.findIndex((
|
|
1207
|
+
var n, o, r, l;
|
|
1208
|
+
const t = measureHistory.value.findIndex((s) => s.id === e);
|
|
1167
1209
|
if (t !== -1) {
|
|
1168
1210
|
measureHistory.value.splice(t, 1);
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1211
|
+
const s = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
|
|
1212
|
+
s[t] && ((o = (n = s[t]) == null ? void 0 : n.parentNode) == null || o.removeChild(s[t]));
|
|
1213
|
+
const a = vectorSource$1.getFeatures();
|
|
1214
|
+
a[t] && vectorSource$1.removeFeature(a[t]);
|
|
1173
1215
|
}
|
|
1174
|
-
(r = getProps()) != null && r.lineDrawEnd && ((
|
|
1216
|
+
(r = getProps()) != null && r.lineDrawEnd && ((l = getProps()) == null || l.lineDrawEnd(measureHistory.value));
|
|
1175
1217
|
}, computedDistance = (e, t) => {
|
|
1176
|
-
const
|
|
1218
|
+
const o = getLength(e);
|
|
1177
1219
|
let r = "";
|
|
1178
1220
|
switch (t) {
|
|
1179
1221
|
case "m":
|
|
1180
|
-
r = `${Math.round(
|
|
1222
|
+
r = `${Math.round(o * 100) / 100} m`;
|
|
1181
1223
|
break;
|
|
1182
1224
|
case "km":
|
|
1183
|
-
r = `${Math.round(
|
|
1225
|
+
r = `${Math.round(o / 1e3 * 100) / 100} km`;
|
|
1184
1226
|
break;
|
|
1185
1227
|
case "nm":
|
|
1186
|
-
r = `${Math.round(
|
|
1228
|
+
r = `${Math.round(o / 1.852 * 100) / 100} nm`;
|
|
1187
1229
|
break;
|
|
1188
1230
|
}
|
|
1189
1231
|
return r;
|
|
1190
1232
|
}, removeInteraction = () => {
|
|
1191
1233
|
measureHistory.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((t) => {
|
|
1192
|
-
var
|
|
1193
|
-
(
|
|
1234
|
+
var n;
|
|
1235
|
+
(n = t == null ? void 0 : t.parentNode) == null || n.removeChild(t);
|
|
1194
1236
|
}), vectorSource$1.clear();
|
|
1195
1237
|
const e = getInstall();
|
|
1196
1238
|
if (draw$1) {
|
|
1197
|
-
const t = e.getInteractions().getArray().find((
|
|
1239
|
+
const t = e.getInteractions().getArray().find((n) => getUid(n) === getUid(draw$1));
|
|
1198
1240
|
t && e.removeInteraction(t);
|
|
1199
1241
|
}
|
|
1200
1242
|
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);
|
|
@@ -1211,8 +1253,8 @@ const createMeasureTooltip$1 = () => {
|
|
|
1211
1253
|
var t;
|
|
1212
1254
|
(t = getView()) == null || t.setZoom(e);
|
|
1213
1255
|
}, setCenter = (e, t) => {
|
|
1214
|
-
var
|
|
1215
|
-
(
|
|
1256
|
+
var n;
|
|
1257
|
+
(n = getView()) == null || n.setCenter(fromLonLat([e, t]));
|
|
1216
1258
|
}, getCenter = () => {
|
|
1217
1259
|
var t;
|
|
1218
1260
|
const e = (t = getView()) == null ? void 0 : t.getCenter();
|
|
@@ -1230,8 +1272,11 @@ const createMeasureTooltip$1 = () => {
|
|
|
1230
1272
|
constrainResolution: !0,
|
|
1231
1273
|
enableRotation: !1,
|
|
1232
1274
|
multiWorld: !0
|
|
1233
|
-
},
|
|
1275
|
+
}, n = new Map$2({
|
|
1234
1276
|
target: "map",
|
|
1277
|
+
controls: defaults({
|
|
1278
|
+
zoom: !1
|
|
1279
|
+
}),
|
|
1235
1280
|
layers: [
|
|
1236
1281
|
BASE_LAYER_MAP.get("vectorTile"),
|
|
1237
1282
|
BASE_LAYER_MAP.get("vectorTileMark"),
|
|
@@ -1240,7 +1285,7 @@ const createMeasureTooltip$1 = () => {
|
|
|
1240
1285
|
],
|
|
1241
1286
|
view: new View(t)
|
|
1242
1287
|
});
|
|
1243
|
-
mapInstance.value =
|
|
1288
|
+
mapInstance.value = n, setBaseMapEvent(n, e);
|
|
1244
1289
|
}, setBaseLayerMap = (e) => {
|
|
1245
1290
|
BASE_LAYER_MAP.set("vectorTile", new TileLayer({
|
|
1246
1291
|
source: new XYZ({ url: BASE_MAP_LINK.vectorTile }),
|
|
@@ -1274,27 +1319,29 @@ const createMeasureTooltip$1 = () => {
|
|
|
1274
1319
|
}));
|
|
1275
1320
|
}, setBaseMapEvent = (e, t) => {
|
|
1276
1321
|
e.on("moveend", () => {
|
|
1277
|
-
var
|
|
1278
|
-
const
|
|
1279
|
-
(
|
|
1280
|
-
}), e.on("pointermove", (
|
|
1281
|
-
const
|
|
1282
|
-
handleShipMapEvent(r, "hover"),
|
|
1283
|
-
}), e.on("
|
|
1322
|
+
var o;
|
|
1323
|
+
const n = getZoom();
|
|
1324
|
+
(o = t.mapMoveEnd) == null || o.call(t, n), reRenderTrackLine();
|
|
1325
|
+
}), e.on("pointermove", (n) => {
|
|
1326
|
+
const o = e.getEventPixel(n.originalEvent), r = e.forEachFeatureAtPixel(o, (l) => l);
|
|
1327
|
+
handleShipMapEvent(r, "hover"), handleTrackMapEvent(r, "hover", n), r && handlePortHover(o);
|
|
1328
|
+
}), e.on("movestart", () => {
|
|
1329
|
+
removeSelectedOverlay();
|
|
1330
|
+
}), e.on("click", debounce((n) => {
|
|
1284
1331
|
if (console.log("1", drawLine.getState()), drawLine.getState()) return;
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1287
|
-
(
|
|
1288
|
-
if (
|
|
1289
|
-
return
|
|
1332
|
+
const o = e.getEventPixel(n.originalEvent), r = e.forEachFeatureAtPixel(
|
|
1333
|
+
o,
|
|
1334
|
+
(l) => {
|
|
1335
|
+
if (l != null && l.get("shipData") || l != null && l.get("portData"))
|
|
1336
|
+
return l;
|
|
1290
1337
|
}
|
|
1291
1338
|
);
|
|
1292
1339
|
if (console.log("2", r), !!r) {
|
|
1293
|
-
if (
|
|
1340
|
+
if (n.preventDefault(), n.stopPropagation(), r.get("shipData"))
|
|
1294
1341
|
handleShipMapEvent(r, "click", t == null ? void 0 : t.selectShip);
|
|
1295
1342
|
else if (r.get("portData")) {
|
|
1296
|
-
const
|
|
1297
|
-
selectedPort(
|
|
1343
|
+
const l = r.get("portData");
|
|
1344
|
+
selectedPort(l), t == null || t.selectPort(l);
|
|
1298
1345
|
}
|
|
1299
1346
|
}
|
|
1300
1347
|
}, 150));
|
|
@@ -1302,39 +1349,39 @@ const createMeasureTooltip$1 = () => {
|
|
|
1302
1349
|
__name: "scaleLine",
|
|
1303
1350
|
setup(e, { expose: t }) {
|
|
1304
1351
|
return t({
|
|
1305
|
-
setScaleLine: (
|
|
1306
|
-
|
|
1352
|
+
setScaleLine: (o) => {
|
|
1353
|
+
o || (o = "metric");
|
|
1307
1354
|
const r = new ScaleLine$1({
|
|
1308
|
-
units:
|
|
1309
|
-
}),
|
|
1310
|
-
|
|
1355
|
+
units: o
|
|
1356
|
+
}), l = document.getElementById("scale-line-container");
|
|
1357
|
+
l && (r.setTarget(l), getInstall().addControl(r));
|
|
1311
1358
|
}
|
|
1312
|
-
}), (
|
|
1359
|
+
}), (o, r) => (openBlock(), createElementBlock("div", _hoisted_1$1));
|
|
1313
1360
|
}
|
|
1314
1361
|
}), ScaleLine = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-31ff8293"]]), _hoisted_1 = { class: "zoom" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1315
1362
|
__name: "zoomControl",
|
|
1316
1363
|
setup(e) {
|
|
1317
|
-
const t = inject("mapInstance"),
|
|
1364
|
+
const t = inject("mapInstance"), n = () => {
|
|
1318
1365
|
if (t != null && t.value) {
|
|
1319
1366
|
const r = getZoom();
|
|
1320
1367
|
if (!r) return;
|
|
1321
1368
|
setZoom(r + 1);
|
|
1322
1369
|
}
|
|
1323
|
-
},
|
|
1370
|
+
}, o = () => {
|
|
1324
1371
|
if (t != null && t.value) {
|
|
1325
1372
|
const r = getZoom();
|
|
1326
1373
|
if (!r) return;
|
|
1327
1374
|
setZoom(r - 1);
|
|
1328
1375
|
}
|
|
1329
1376
|
};
|
|
1330
|
-
return (r,
|
|
1377
|
+
return (r, l) => (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
1331
1378
|
createElementVNode("div", {
|
|
1332
1379
|
class: "button big-button",
|
|
1333
|
-
onClick:
|
|
1380
|
+
onClick: n
|
|
1334
1381
|
}, " + "),
|
|
1335
1382
|
createElementVNode("div", {
|
|
1336
1383
|
class: "button small-button",
|
|
1337
|
-
onClick:
|
|
1384
|
+
onClick: o
|
|
1338
1385
|
}, " - ")
|
|
1339
1386
|
]));
|
|
1340
1387
|
}
|
|
@@ -1344,30 +1391,34 @@ const createMeasureTooltip$1 = () => {
|
|
|
1344
1391
|
}, layerType = ref("vector"), getShowLayerType = () => layerType.value, setShowLayerType = (e) => {
|
|
1345
1392
|
layerType.value = e;
|
|
1346
1393
|
const t = getLayers();
|
|
1347
|
-
t && t.getArray().forEach((
|
|
1348
|
-
|
|
1394
|
+
t && t.getArray().forEach((n) => {
|
|
1395
|
+
n.setVisible(n.className_ === e);
|
|
1349
1396
|
});
|
|
1350
1397
|
}, showGreenTile = ref(), getGreenTileVisible = () => showGreenTile.value, setGreenTileVisible = (e) => {
|
|
1351
1398
|
if (e !== showGreenTile.value) {
|
|
1352
1399
|
if (e) {
|
|
1353
1400
|
const t = getLayers();
|
|
1354
|
-
if (!t.getArray().find((
|
|
1355
|
-
const
|
|
1401
|
+
if (!t.getArray().find((o) => o.className_ === "greenTile")) {
|
|
1402
|
+
const o = new TileLayer({
|
|
1356
1403
|
source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
|
|
1357
1404
|
visible: e,
|
|
1358
1405
|
zIndex: 2,
|
|
1359
1406
|
className: "greenTile"
|
|
1360
1407
|
});
|
|
1361
|
-
t.push(
|
|
1408
|
+
t.push(o);
|
|
1362
1409
|
}
|
|
1363
1410
|
} else {
|
|
1364
|
-
const t = getLayers(),
|
|
1365
|
-
|
|
1411
|
+
const t = getLayers(), n = t.getArray().find((o) => o.className_ === "greenTile");
|
|
1412
|
+
n && t.remove(n);
|
|
1366
1413
|
}
|
|
1367
1414
|
showGreenTile.value = e;
|
|
1368
1415
|
}
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1416
|
+
};
|
|
1417
|
+
let storeFeature;
|
|
1418
|
+
const open = () => {
|
|
1419
|
+
init();
|
|
1420
|
+
}, init = () => {
|
|
1421
|
+
initLayer(), createMeasureTooltip(), createHelpTooltip(), initDraw();
|
|
1371
1422
|
};
|
|
1372
1423
|
let vectorLayer = null, vectorSource = null;
|
|
1373
1424
|
const initLayer = () => {
|
|
@@ -1382,9 +1433,9 @@ const initLayer = () => {
|
|
|
1382
1433
|
})
|
|
1383
1434
|
});
|
|
1384
1435
|
vectorLayer = t, vectorSource = e;
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1387
|
-
draw && (
|
|
1436
|
+
const n = getInstall();
|
|
1437
|
+
n.on("pointermove", pointerMoveHandler), n.addLayer(t), n.on(["dblclick"], function(o) {
|
|
1438
|
+
draw && (o.stopPropagation(), o.preventDefault());
|
|
1388
1439
|
});
|
|
1389
1440
|
};
|
|
1390
1441
|
let sketch;
|
|
@@ -1393,9 +1444,27 @@ const pointerMoveHandler = (e) => {
|
|
|
1393
1444
|
const t = sketch ? "单击继续,双击结束" : "点击选择起点";
|
|
1394
1445
|
helpTooltipElement && (helpTooltipElement.innerHTML = t, tipOverlay.setPosition(e.coordinate));
|
|
1395
1446
|
};
|
|
1396
|
-
let draw;
|
|
1447
|
+
let draw, lineLimitError = !1;
|
|
1397
1448
|
const initDraw = () => {
|
|
1398
|
-
|
|
1449
|
+
var t, n;
|
|
1450
|
+
if (storeFeature) {
|
|
1451
|
+
helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement);
|
|
1452
|
+
const o = storeFeature.getGeometry();
|
|
1453
|
+
if (!o) return;
|
|
1454
|
+
const r = computedArea(o, "nm");
|
|
1455
|
+
measureTooltipElement && (measureTooltipElement.innerHTML = `
|
|
1456
|
+
<span class="text">面积:${r}${lineLimitError ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
|
|
1457
|
+
`), measureTooltipElement && (measureTooltipElement.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
|
|
1458
|
+
const l = o.getCoordinates(), s = l[0][l[0].length - 2];
|
|
1459
|
+
measureTooltip.setPosition(s), vectorLayer && ((t = vectorLayer.getSource()) == null || t.addFeature(storeFeature)), console.log("helpTooltipElement", (n = document.querySelector(".delete-icon")) == null ? void 0 : n.parentNode), setTimeout(() => {
|
|
1460
|
+
var a;
|
|
1461
|
+
(a = document.querySelector(".delete-icon")) == null || a.addEventListener("click", () => {
|
|
1462
|
+
var c;
|
|
1463
|
+
console.log("delete"), reset(), (c = getProps()) == null || c.areaDrawEnd([]);
|
|
1464
|
+
});
|
|
1465
|
+
}, 0);
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1399
1468
|
draw = new Draw({
|
|
1400
1469
|
type: "Polygon",
|
|
1401
1470
|
source: vectorSource,
|
|
@@ -1417,30 +1486,30 @@ const initDraw = () => {
|
|
|
1417
1486
|
})
|
|
1418
1487
|
}),
|
|
1419
1488
|
geometry: function(o) {
|
|
1420
|
-
const
|
|
1421
|
-
return new MultiPoint(
|
|
1489
|
+
const r = o.getGeometry().getCoordinates();
|
|
1490
|
+
return new MultiPoint(r);
|
|
1422
1491
|
}
|
|
1423
1492
|
})]
|
|
1424
1493
|
}), getInstall().addInteraction(draw);
|
|
1425
|
-
let
|
|
1494
|
+
let e;
|
|
1426
1495
|
draw.on("drawstart", (o) => {
|
|
1427
|
-
var
|
|
1428
|
-
sketch = o.feature,
|
|
1429
|
-
const
|
|
1430
|
-
if (
|
|
1431
|
-
const
|
|
1496
|
+
var r;
|
|
1497
|
+
sketch = o.feature, e = (r = sketch.getGeometry()) == null ? void 0 : r.on("change", (l) => {
|
|
1498
|
+
const s = l.target, a = computedArea(s, "nm"), d = s.getCoordinates()[0], u = new LineString([d[d.length - 2], d[d.length - 1]]), i = computedDistance(u, "nm");
|
|
1499
|
+
if (lineLimitError = Number(getLength(u) / 1e3) > 150, !a) return;
|
|
1500
|
+
const p = '<span class="error pl-4">超出可以绘画的距离</span>';
|
|
1432
1501
|
measureTooltipElement && (measureTooltipElement.innerHTML = `
|
|
1433
1502
|
<div class="text">
|
|
1434
|
-
面积:${
|
|
1435
|
-
${
|
|
1503
|
+
面积:${a}
|
|
1504
|
+
${lineLimitError ? p : ""}
|
|
1436
1505
|
</div>
|
|
1437
1506
|
`), helpTooltipElement && (helpTooltipElement.innerHTML = `
|
|
1438
1507
|
<div class="text">
|
|
1439
|
-
面积:${
|
|
1508
|
+
面积:${a}
|
|
1440
1509
|
</div>
|
|
1441
|
-
<div class="text ${
|
|
1442
|
-
线段 ${
|
|
1443
|
-
${
|
|
1510
|
+
<div class="text ${lineLimitError ? "error" : ""}">
|
|
1511
|
+
线段 ${d.length - 2}: ${i}
|
|
1512
|
+
${lineLimitError ? p : ""}
|
|
1444
1513
|
|
|
1445
1514
|
</div>
|
|
1446
1515
|
<div>
|
|
@@ -1449,23 +1518,29 @@ const initDraw = () => {
|
|
|
1449
1518
|
`);
|
|
1450
1519
|
});
|
|
1451
1520
|
}), draw.on("drawend", (o) => {
|
|
1452
|
-
var
|
|
1521
|
+
var a, c, d;
|
|
1453
1522
|
if (!o.feature.getGeometry()) return;
|
|
1454
|
-
measureTooltipElement && (measureTooltipElement.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), measureTooltip.setOffset([10, 0]);
|
|
1455
|
-
const r = o.feature.getGeometry().getCoordinates(),
|
|
1456
|
-
measureTooltip.setPosition(
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1523
|
+
storeFeature = o.feature, measureTooltipElement && (measureTooltipElement.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), measureTooltip.setOffset([10, 0]);
|
|
1524
|
+
const r = o.feature.getGeometry(), l = r.getCoordinates(), s = l[0][l[0].length - 2];
|
|
1525
|
+
if (measureTooltip.setPosition(s), helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), (a = getProps()) != null && a.areaDrawEnd) {
|
|
1526
|
+
r.getInteriorPoint().getCoordinates();
|
|
1527
|
+
const u = l[0].map((i) => transform(i, projection.mercator, projection.data));
|
|
1528
|
+
(c = getProps()) == null || c.areaDrawEnd(u);
|
|
1529
|
+
}
|
|
1530
|
+
draw && (draw.setActive(!1), getInstall().removeInteraction(draw), getInstall().getInteractions().forEach((i) => {
|
|
1531
|
+
i instanceof Draw && (i.setActive(!1), getInstall().removeInteraction(i));
|
|
1532
|
+
})), e && unByKey(e), (d = document.querySelector(".delete-icon")) == null || d.addEventListener("click", () => {
|
|
1533
|
+
var u;
|
|
1534
|
+
reset(), (u = getProps()) == null || u.areaDrawEnd([]);
|
|
1460
1535
|
});
|
|
1461
1536
|
});
|
|
1462
1537
|
}, computedArea = (e, t) => {
|
|
1463
|
-
const
|
|
1538
|
+
const n = getArea(e);
|
|
1464
1539
|
switch (t) {
|
|
1465
1540
|
case "km":
|
|
1466
|
-
return
|
|
1541
|
+
return n > 1e4 ? Math.round(n / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(n * 100) / 100 + " m<sup>2</sup>";
|
|
1467
1542
|
case "nm":
|
|
1468
|
-
return
|
|
1543
|
+
return n > 1e4 ? Math.round(n / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(n * 100) / 100 + " m<sup>2</sup>";
|
|
1469
1544
|
}
|
|
1470
1545
|
};
|
|
1471
1546
|
let measureTooltipElement, measureTooltip;
|
|
@@ -1473,52 +1548,52 @@ const createMeasureTooltip = () => {
|
|
|
1473
1548
|
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({
|
|
1474
1549
|
element: measureTooltipElement,
|
|
1475
1550
|
offset: [0, -15],
|
|
1476
|
-
positioning: "bottom-center"
|
|
1477
|
-
|
|
1478
|
-
|
|
1551
|
+
positioning: "bottom-center",
|
|
1552
|
+
stopEvent: !1,
|
|
1553
|
+
insertFirst: !1
|
|
1479
1554
|
}), getInstall().addOverlay(measureTooltip);
|
|
1480
1555
|
};
|
|
1481
1556
|
let helpTooltipElement, tipOverlay;
|
|
1482
1557
|
const createHelpTooltip = () => {
|
|
1483
|
-
helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), helpTooltipElement = document.createElement("div"), helpTooltipElement.className = "ol-tooltip ol-help-tooltip
|
|
1558
|
+
helpTooltipElement != null && helpTooltipElement.parentNode && helpTooltipElement.parentNode.removeChild(helpTooltipElement), helpTooltipElement = document.createElement("div"), helpTooltipElement.className = "ol-tooltip ol-help-tooltip", tipOverlay = new Overlay({
|
|
1484
1559
|
element: helpTooltipElement,
|
|
1485
1560
|
offset: [15, 0],
|
|
1486
1561
|
positioning: "center-left"
|
|
1487
1562
|
}), getInstall().addOverlay(tipOverlay);
|
|
1488
1563
|
}, reset = () => {
|
|
1489
|
-
|
|
1490
|
-
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();
|
|
1564
|
+
vectorSource == null || vectorSource.clear(), storeFeature = null, createMeasureTooltip(), createHelpTooltip(), initDraw();
|
|
1491
1565
|
}, close = () => {
|
|
1492
|
-
vectorSource == null || vectorSource.clear(), vectorSource = null;
|
|
1493
1566
|
const e = getInstall();
|
|
1494
|
-
vectorLayer && (e.removeLayer(vectorLayer), vectorLayer = null), sketch = null, draw && (e.
|
|
1567
|
+
vectorSource == null || vectorSource.clear(), vectorSource = null, vectorLayer && (e.removeLayer(vectorLayer), vectorLayer = null), sketch = null, draw && (draw = null, e.getInteractions().forEach((t) => {
|
|
1568
|
+
t instanceof Draw && e.removeInteraction(t);
|
|
1569
|
+
})), helpTooltipElement != null && helpTooltipElement.parentElement && helpTooltipElement.parentElement.removeChild(helpTooltipElement), measureTooltipElement != null && measureTooltipElement.parentElement && measureTooltipElement.parentElement.removeChild(measureTooltipElement), tipOverlay && e.removeOverlay(tipOverlay), measureTooltip && e.removeOverlay(measureTooltip);
|
|
1495
1570
|
}, drawPolygon = {
|
|
1496
1571
|
open,
|
|
1497
|
-
|
|
1498
|
-
|
|
1572
|
+
close,
|
|
1573
|
+
reset
|
|
1499
1574
|
};
|
|
1500
1575
|
let currentTruckOverlay = null;
|
|
1501
1576
|
const locationTruck = async (e) => {
|
|
1502
1577
|
const t = getInstall();
|
|
1503
1578
|
if (!t || (console.log("vehicleInfo", e), !(e != null && e.lon && (e != null && e.lat)))) return;
|
|
1504
|
-
const
|
|
1505
|
-
drawTruckIcon(e, fromLonLat(
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1579
|
+
const n = Math.abs(Number(e.lon)) > 180 ? convertSixHundredThousandToLatLng(e.lon, e.lat) : [e.lon, e.lat];
|
|
1580
|
+
drawTruckIcon(e, fromLonLat(n));
|
|
1581
|
+
const o = t.getView(), r = new Point(n);
|
|
1582
|
+
o.setCenter(transform(r.getCoordinates(), projection.data, projection.mercator));
|
|
1508
1583
|
}, drawTruckIcon = (e, t) => {
|
|
1509
|
-
const
|
|
1584
|
+
const n = getInstall(), o = `${CDN_URL}map/car-icon.gif`;
|
|
1510
1585
|
currentTruckOverlay || (currentTruckOverlay = new Overlay({
|
|
1511
1586
|
element: document.createElement("div"),
|
|
1512
1587
|
positioning: "center-center",
|
|
1513
1588
|
stopEvent: !1
|
|
1514
1589
|
// 允许交互事件穿透
|
|
1515
|
-
}),
|
|
1590
|
+
}), n.addOverlay(currentTruckOverlay));
|
|
1516
1591
|
const r = currentTruckOverlay.getElement();
|
|
1517
|
-
r.style.backgroundImage = `url(${
|
|
1518
|
-
const
|
|
1519
|
-
r.style.transform = `rotate(${
|
|
1520
|
-
}, renderTruckTrack = (e, t,
|
|
1521
|
-
renderTrackLine(e, t,
|
|
1592
|
+
r.style.backgroundImage = `url(${o})`, r.style.width = "80px", r.style.height = "80px";
|
|
1593
|
+
const l = (e == null ? void 0 : e.drc) || "";
|
|
1594
|
+
r.style.transform = `rotate(${l}deg)`, r.style.backgroundSize = "cover", currentTruckOverlay == null || currentTruckOverlay.setPosition(t);
|
|
1595
|
+
}, renderTruckTrack = (e, t, n, o = 1e3) => {
|
|
1596
|
+
renderTrackLine(e, t, n, LENGTH_UNIT.KM, "truck", o);
|
|
1522
1597
|
}, closeTruckTrack = () => {
|
|
1523
1598
|
closeTrack();
|
|
1524
1599
|
}, removeTruckIcon = () => {
|
|
@@ -1555,10 +1630,10 @@ const locationTruck = async (e) => {
|
|
|
1555
1630
|
} }
|
|
1556
1631
|
},
|
|
1557
1632
|
setup(e, { expose: t }) {
|
|
1558
|
-
const
|
|
1633
|
+
const n = ref(), o = ref(), r = e;
|
|
1559
1634
|
return console.log(r), onMounted(() => {
|
|
1560
|
-
var
|
|
1561
|
-
initMap(r), setProps(r), setShowLayerType(r.layerType), setGreenTileVisible(r.showGreenLayer), (
|
|
1635
|
+
var s;
|
|
1636
|
+
initMap(r), setProps(r), setShowLayerType(r.layerType), setGreenTileVisible(r.showGreenLayer), (s = o.value) == null || s.setScaleLine(r.scaleLineUnit);
|
|
1562
1637
|
}), t({
|
|
1563
1638
|
getInstall,
|
|
1564
1639
|
getZoom,
|
|
@@ -1585,7 +1660,8 @@ const locationTruck = async (e) => {
|
|
|
1585
1660
|
removeAllTrackLayer,
|
|
1586
1661
|
playShipTrack,
|
|
1587
1662
|
setTrackViewCenter,
|
|
1588
|
-
closeTrack
|
|
1663
|
+
closeTrack,
|
|
1664
|
+
getTrack: getShowTracks
|
|
1589
1665
|
},
|
|
1590
1666
|
port: {
|
|
1591
1667
|
render: renderPortList,
|
|
@@ -1598,27 +1674,27 @@ const locationTruck = async (e) => {
|
|
|
1598
1674
|
carTrack,
|
|
1599
1675
|
utils: {
|
|
1600
1676
|
getCalculateExtent: () => {
|
|
1601
|
-
const
|
|
1602
|
-
return [
|
|
1677
|
+
const s = getView().calculateExtent(getSize()), a = transform([s[0], s[1]], projection.mercator, projection.data), c = transform([s[2], s[3]], projection.mercator, projection.data);
|
|
1678
|
+
return [a[0], a[1], c[0], c[1]];
|
|
1603
1679
|
},
|
|
1604
1680
|
convertSixHundredThousandToLatLng,
|
|
1605
1681
|
calculateCirclePoints
|
|
1606
1682
|
}
|
|
1607
|
-
}), (
|
|
1683
|
+
}), (s, a) => (openBlock(), createElementBlock(Fragment, null, [
|
|
1608
1684
|
createElementVNode("div", {
|
|
1609
1685
|
id: "map",
|
|
1610
1686
|
ref_key: "zhMapRef",
|
|
1611
|
-
ref:
|
|
1687
|
+
ref: n,
|
|
1612
1688
|
class: "zh-map"
|
|
1613
1689
|
}, null, 512),
|
|
1614
1690
|
createVNode(ScaleLine, {
|
|
1615
1691
|
ref_key: "scaleLineRef",
|
|
1616
|
-
ref:
|
|
1692
|
+
ref: o
|
|
1617
1693
|
}, null, 512),
|
|
1618
1694
|
createVNode(ZoomControl, { ref: "zoomControlRef" }, null, 512)
|
|
1619
1695
|
], 64));
|
|
1620
1696
|
}
|
|
1621
|
-
}), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
1697
|
+
}), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-a27bd97d"]]), ZhMap = withInstall(Map$1);
|
|
1622
1698
|
export {
|
|
1623
1699
|
ZhMap as Z
|
|
1624
1700
|
};
|