zhihao-ui 1.3.16 → 1.3.17
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.
|
@@ -4,16 +4,16 @@ import { _ as _export_sfc } from "./Button-CGndQwez.js";
|
|
|
4
4
|
import { w as withInstall } from "./utils-D2wHR1YB.js";
|
|
5
5
|
const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
6
6
|
__name: "scaleLine",
|
|
7
|
-
setup(e, { expose:
|
|
8
|
-
return
|
|
9
|
-
setScaleLine: (
|
|
7
|
+
setup(e, { expose: s }) {
|
|
8
|
+
return s({
|
|
9
|
+
setScaleLine: (n, a) => {
|
|
10
10
|
a || (a = "metric");
|
|
11
11
|
const o = new ScaleLine$1({
|
|
12
12
|
units: a
|
|
13
|
-
}),
|
|
14
|
-
|
|
13
|
+
}), m = document.getElementById("scale-line-container");
|
|
14
|
+
m && (o.setTarget(m), n.addControl(o));
|
|
15
15
|
}
|
|
16
|
-
}), (
|
|
16
|
+
}), (n, a) => (openBlock(), createElementBlock("div", _hoisted_1$2));
|
|
17
17
|
}
|
|
18
18
|
}), ScaleLine = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2bc5dee8"]]), _hoisted_1$1 = { class: "zoom" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
19
19
|
__name: "zoomControl",
|
|
@@ -24,17 +24,17 @@ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
setup(e) {
|
|
27
|
-
const
|
|
28
|
-
console.log("props",
|
|
27
|
+
const s = e;
|
|
28
|
+
console.log("props", s);
|
|
29
29
|
const l = () => {
|
|
30
30
|
console.log("props");
|
|
31
|
-
const { setZoom: a, getZoom: o, getInstall:
|
|
32
|
-
if (!
|
|
31
|
+
const { setZoom: a, getZoom: o, getInstall: m } = s.mapInstance.methods;
|
|
32
|
+
if (!m()) return;
|
|
33
33
|
const t = o();
|
|
34
34
|
t && a(t + 1);
|
|
35
|
-
},
|
|
36
|
-
const { setZoom: a, getZoom: o, getInstall:
|
|
37
|
-
if (!
|
|
35
|
+
}, n = () => {
|
|
36
|
+
const { setZoom: a, getZoom: o, getInstall: m } = s.mapInstance.methods;
|
|
37
|
+
if (!m()) return;
|
|
38
38
|
const t = o();
|
|
39
39
|
t && a(t - 1);
|
|
40
40
|
};
|
|
@@ -45,7 +45,7 @@ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__
|
|
|
45
45
|
}, " + "),
|
|
46
46
|
createElementVNode("div", {
|
|
47
47
|
class: "button small-button",
|
|
48
|
-
onClick:
|
|
48
|
+
onClick: n
|
|
49
49
|
}, " - ")
|
|
50
50
|
]));
|
|
51
51
|
}
|
|
@@ -72,34 +72,34 @@ const _hoisted_1$2 = { id: "scale-line-container" }, _sfc_main$2 = /* @__PURE__
|
|
|
72
72
|
}, MAP_DEFAULT_CENTER = [114.84, 30.52], CDN_URL = "https://static.zhihaoscm.cn/", equatorialCircumference = 2003750834e-2;
|
|
73
73
|
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 || {});
|
|
74
74
|
function useMapInitializer() {
|
|
75
|
-
const e = ref(),
|
|
76
|
-
var
|
|
77
|
-
return (
|
|
78
|
-
}, a = (
|
|
79
|
-
var
|
|
80
|
-
(
|
|
81
|
-
}, o = (
|
|
82
|
-
var
|
|
83
|
-
(
|
|
84
|
-
},
|
|
85
|
-
var
|
|
86
|
-
const
|
|
87
|
-
return toLonLat(
|
|
88
|
-
},
|
|
89
|
-
var
|
|
90
|
-
return (
|
|
91
|
-
}, t = new Map$2(), r = (
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
zoom:
|
|
95
|
-
center: fromLonLat(
|
|
75
|
+
const e = ref(), s = () => e.value, l = () => s().getView(), n = () => {
|
|
76
|
+
var v;
|
|
77
|
+
return (v = l()) == null ? void 0 : v.getZoom();
|
|
78
|
+
}, a = (v) => {
|
|
79
|
+
var P;
|
|
80
|
+
(P = l()) == null || P.setZoom(v);
|
|
81
|
+
}, o = (v, P) => {
|
|
82
|
+
var O;
|
|
83
|
+
(O = l()) == null || O.setCenter(fromLonLat([v, P]));
|
|
84
|
+
}, m = () => {
|
|
85
|
+
var P;
|
|
86
|
+
const v = (P = l()) == null ? void 0 : P.getCenter();
|
|
87
|
+
return toLonLat(v);
|
|
88
|
+
}, L = () => {
|
|
89
|
+
var v;
|
|
90
|
+
return (v = s()) == null ? void 0 : v.getSize();
|
|
91
|
+
}, t = new Map$2(), r = (v, P) => {
|
|
92
|
+
w(P);
|
|
93
|
+
const O = {
|
|
94
|
+
zoom: P.zoom,
|
|
95
|
+
center: fromLonLat(P.center),
|
|
96
96
|
minZoom: MAP_ZOOM.min,
|
|
97
97
|
maxZoom: MAP_ZOOM.max,
|
|
98
98
|
constrainResolution: !0,
|
|
99
99
|
enableRotation: !1,
|
|
100
100
|
multiWorld: !0
|
|
101
|
-
},
|
|
102
|
-
target:
|
|
101
|
+
}, f = new Map$2({
|
|
102
|
+
target: v,
|
|
103
103
|
controls: defaults({
|
|
104
104
|
zoom: !1
|
|
105
105
|
}),
|
|
@@ -109,62 +109,62 @@ function useMapInitializer() {
|
|
|
109
109
|
t.get("satelliteImgTile"),
|
|
110
110
|
t.get("satelliteImgTileMark")
|
|
111
111
|
],
|
|
112
|
-
view: new View(
|
|
112
|
+
view: new View(O)
|
|
113
113
|
});
|
|
114
|
-
e.value =
|
|
115
|
-
},
|
|
114
|
+
e.value = f;
|
|
115
|
+
}, w = (v) => {
|
|
116
116
|
t.set("vectorTile", new TileLayer({
|
|
117
117
|
source: new XYZ({ url: BASE_MAP_LINK.vectorTile }),
|
|
118
|
-
visible:
|
|
118
|
+
visible: v.layerType === "vector",
|
|
119
119
|
zIndex: 0,
|
|
120
120
|
preload: 1,
|
|
121
121
|
className: "vector"
|
|
122
122
|
})), t.set("vectorTileMark", new TileLayer({
|
|
123
123
|
source: new XYZ({ url: BASE_MAP_LINK.vectorTileMark }),
|
|
124
|
-
visible:
|
|
124
|
+
visible: v.layerType === "vector",
|
|
125
125
|
zIndex: 1,
|
|
126
126
|
preload: 1,
|
|
127
127
|
className: "vector"
|
|
128
128
|
})), t.set("satelliteImgTile", new TileLayer({
|
|
129
129
|
source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTile }),
|
|
130
|
-
visible:
|
|
130
|
+
visible: v.layerType === "satellite",
|
|
131
131
|
zIndex: 0,
|
|
132
132
|
preload: 1,
|
|
133
133
|
className: "satellite"
|
|
134
134
|
})), t.set("satelliteImgTileMark", new TileLayer({
|
|
135
135
|
source: new XYZ({ url: BASE_MAP_LINK.satelliteImgTileMark }),
|
|
136
|
-
visible:
|
|
136
|
+
visible: v.layerType === "satellite",
|
|
137
137
|
zIndex: 1,
|
|
138
138
|
preload: 1,
|
|
139
139
|
className: "satellite"
|
|
140
140
|
})), t.set("greenMark", new TileLayer({
|
|
141
141
|
source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
|
|
142
|
-
visible:
|
|
142
|
+
visible: v.showGreenLayer,
|
|
143
143
|
zIndex: 2,
|
|
144
144
|
className: "greenTile"
|
|
145
145
|
}));
|
|
146
146
|
};
|
|
147
147
|
return {
|
|
148
|
-
getInstall:
|
|
148
|
+
getInstall: s,
|
|
149
149
|
getView: l,
|
|
150
|
-
getZoom:
|
|
150
|
+
getZoom: n,
|
|
151
151
|
setZoom: a,
|
|
152
152
|
setCenter: o,
|
|
153
|
-
getCenter:
|
|
154
|
-
getSize:
|
|
153
|
+
getCenter: m,
|
|
154
|
+
getSize: L,
|
|
155
155
|
initMap: r,
|
|
156
|
-
setBaseLayerMap:
|
|
156
|
+
setBaseLayerMap: w
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
const convertSixHundredThousandToLatLng = function(e,
|
|
160
|
-
const l = Number(
|
|
159
|
+
const convertSixHundredThousandToLatLng = function(e, s) {
|
|
160
|
+
const l = Number(s) / 6e5;
|
|
161
161
|
return [Number(e) / 6e5, l];
|
|
162
|
-
}, calculateCirclePoints = (e,
|
|
163
|
-
const l = fromLonLat(e),
|
|
164
|
-
l[0] -
|
|
165
|
-
l[1] -
|
|
166
|
-
l[0] +
|
|
167
|
-
l[1] +
|
|
162
|
+
}, calculateCirclePoints = (e, s) => {
|
|
163
|
+
const l = fromLonLat(e), n = s * 1e3, a = [
|
|
164
|
+
l[0] - n,
|
|
165
|
+
l[1] - n,
|
|
166
|
+
l[0] + n,
|
|
167
|
+
l[1] + n
|
|
168
168
|
], o = transformExtent(a, projection.mercator, projection.data);
|
|
169
169
|
return {
|
|
170
170
|
leftTopPoint: { lng: o[0], lat: o[3] },
|
|
@@ -172,134 +172,134 @@ const convertSixHundredThousandToLatLng = function(e, n) {
|
|
|
172
172
|
rightBottomPoint: { lng: o[2], lat: o[1] },
|
|
173
173
|
leftBottomPoint: { lng: o[0], lat: o[1] }
|
|
174
174
|
};
|
|
175
|
-
}, formatLength = function(e,
|
|
176
|
-
const
|
|
175
|
+
}, formatLength = function(e, s) {
|
|
176
|
+
const n = getLength(e);
|
|
177
177
|
let a = "";
|
|
178
|
-
switch (console.log(
|
|
178
|
+
switch (console.log(s, LENGTH_UNIT), s) {
|
|
179
179
|
case LENGTH_UNIT.M:
|
|
180
|
-
a = Math.round(
|
|
180
|
+
a = Math.round(n * 100) / 100 + " m";
|
|
181
181
|
break;
|
|
182
182
|
case LENGTH_UNIT.KM:
|
|
183
|
-
a = Math.round(
|
|
183
|
+
a = Math.round(n / 1e3 * 100) / 100 + " km";
|
|
184
184
|
break;
|
|
185
185
|
case LENGTH_UNIT.NM:
|
|
186
|
-
a = (Math.round(
|
|
186
|
+
a = (Math.round(n / 1e3 * 100) / 100 / 1.852).toFixed(2) + " nm";
|
|
187
187
|
break;
|
|
188
188
|
}
|
|
189
189
|
return a;
|
|
190
190
|
};
|
|
191
191
|
function lonLatToMercator(e) {
|
|
192
|
-
const
|
|
192
|
+
const s = e[0] * equatorialCircumference / 180;
|
|
193
193
|
let l = Math.log(Math.tan((90 + e[1]) * Math.PI / 360)) / (Math.PI / 180);
|
|
194
|
-
return l = l * equatorialCircumference / 180, [
|
|
194
|
+
return l = l * equatorialCircumference / 180, [s, l];
|
|
195
195
|
}
|
|
196
196
|
function getIconFont(unicode = "") {
|
|
197
197
|
return unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), unicode.indexOf("&") !== -1 && (unicode = unicode.replace("&", "&")), eval('("' + unicode.replace("&#x", "\\u").replace(";", "") + '")');
|
|
198
198
|
}
|
|
199
199
|
const getIconStyle = (e) => {
|
|
200
|
-
const
|
|
200
|
+
const s = new Text({
|
|
201
201
|
font: "Normal 14px map-iconfont",
|
|
202
202
|
text: getIconFont(e),
|
|
203
203
|
fill: new Fill({ color: "#fff" }),
|
|
204
204
|
offsetY: -14
|
|
205
205
|
});
|
|
206
206
|
return new Style({
|
|
207
|
-
text:
|
|
207
|
+
text: s,
|
|
208
208
|
zIndex: 100
|
|
209
209
|
});
|
|
210
|
-
}, mercatorToLonLat = (e,
|
|
211
|
-
const l = { lon: 0, lat: 0 },
|
|
210
|
+
}, mercatorToLonLat = (e, s = "lonlat") => {
|
|
211
|
+
const l = { lon: 0, lat: 0 }, n = e[0] / equatorialCircumference * 180;
|
|
212
212
|
let a = e[1] / equatorialCircumference * 180;
|
|
213
|
-
return a = 180 / Math.PI * (2 * Math.atan(Math.exp(a * Math.PI / 180)) - Math.PI / 2), l.lon =
|
|
213
|
+
return a = 180 / Math.PI * (2 * Math.atan(Math.exp(a * Math.PI / 180)) - Math.PI / 2), l.lon = n, l.lat = a, s === "lonlat" ? l : [n, a];
|
|
214
214
|
}, formatMinutesToDDHHMM = (e) => {
|
|
215
|
-
const
|
|
215
|
+
const s = hooks.duration(e, "minutes"), l = Math.floor(s.asDays()), n = s.hours(), a = s.minutes();
|
|
216
216
|
let o = `${String(a).padStart(2, "0")}分`;
|
|
217
|
-
return
|
|
218
|
-
}, useCarTrackManager = (e,
|
|
217
|
+
return n !== 0 && (o = `${String(n).padStart(2, "0")}时${o}`), l !== 0 && (o = `${String(l).padStart(2, "0")}天${o}`), o;
|
|
218
|
+
}, useCarTrackManager = (e, s) => {
|
|
219
219
|
let l = null;
|
|
220
|
-
const
|
|
221
|
-
if (!e || (console.log("vehicleInfo",
|
|
222
|
-
const
|
|
223
|
-
a(
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
}, a = (
|
|
227
|
-
const
|
|
220
|
+
const n = async (w) => {
|
|
221
|
+
if (!e || (console.log("vehicleInfo", w), !(w != null && w.lon && (w != null && w.lat)))) return;
|
|
222
|
+
const v = Math.abs(Number(w.lon)) > 180 ? convertSixHundredThousandToLatLng(w.lon, w.lat) : [w.lon, w.lat];
|
|
223
|
+
a(w, fromLonLat(v));
|
|
224
|
+
const P = e == null ? void 0 : e.getView(), O = new Point(v);
|
|
225
|
+
P.setCenter(transform(O.getCoordinates(), projection.data, projection.mercator));
|
|
226
|
+
}, a = (w, v) => {
|
|
227
|
+
const P = `${CDN_URL}map/car-icon.gif`;
|
|
228
228
|
l || (l = new Overlay({
|
|
229
229
|
element: document.createElement("div"),
|
|
230
230
|
positioning: "center-center",
|
|
231
231
|
stopEvent: !1
|
|
232
232
|
// 允许交互事件穿透
|
|
233
233
|
}), e.addOverlay(l));
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
234
|
+
const O = l.getElement();
|
|
235
|
+
O.style.backgroundImage = `url(${P})`, O.style.width = "80px", O.style.height = "80px";
|
|
236
|
+
const f = (w == null ? void 0 : w.drc) || "";
|
|
237
|
+
O.style.transform = `rotate(${f}deg)`, O.style.backgroundSize = "cover", l == null || l.setPosition(v);
|
|
238
238
|
};
|
|
239
239
|
return {
|
|
240
|
-
location:
|
|
240
|
+
location: n,
|
|
241
241
|
remove: () => {
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
const w = l == null ? void 0 : l.getElement();
|
|
243
|
+
w && (w.innerHTML = "");
|
|
244
244
|
},
|
|
245
|
-
renderTrack: (
|
|
246
|
-
|
|
245
|
+
renderTrack: (w, v, P) => {
|
|
246
|
+
s.render(w, v, P, "truck", 1e3);
|
|
247
247
|
},
|
|
248
|
-
setCenter: (
|
|
249
|
-
|
|
248
|
+
setCenter: (w) => {
|
|
249
|
+
s.setCenter(w);
|
|
250
250
|
},
|
|
251
251
|
closeTrack: () => {
|
|
252
|
-
|
|
252
|
+
s.close();
|
|
253
253
|
},
|
|
254
|
-
playTrack: (
|
|
255
|
-
|
|
254
|
+
playTrack: (w, v) => {
|
|
255
|
+
s.play(w, v);
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
258
|
};
|
|
259
259
|
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 || {});
|
|
260
260
|
const useTrackManager = (e) => {
|
|
261
|
-
const
|
|
262
|
-
let
|
|
261
|
+
const s = /* @__PURE__ */ new Map(), l = {};
|
|
262
|
+
let n = null;
|
|
263
263
|
const a = "--";
|
|
264
264
|
let o = null;
|
|
265
|
-
const
|
|
266
|
-
element:
|
|
265
|
+
const m = document.createElement("div"), L = new Overlay({
|
|
266
|
+
element: m,
|
|
267
267
|
positioning: "top-left",
|
|
268
268
|
stopEvent: !1,
|
|
269
269
|
className: "track-label-popup"
|
|
270
270
|
});
|
|
271
|
-
let t, r,
|
|
272
|
-
const
|
|
271
|
+
let t, r, w, v, P, O = !1, f = Date.now(), y, F = 0, E = null, T = 20, G = !1;
|
|
272
|
+
const q = 5, W = [], Q = (i) => {
|
|
273
273
|
var c;
|
|
274
|
-
for (
|
|
275
|
-
const d =
|
|
276
|
-
|
|
274
|
+
for (W.unshift(i); W.length > q; ) {
|
|
275
|
+
const d = W.pop(), p = s.get(d);
|
|
276
|
+
p && ((c = p.getSource()) == null || c.clear(), e == null || e.removeLayer(p), s.delete(d), delete l[d]);
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
279
|
let u = "";
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
280
|
+
const x = ["#ff0000", "#00ff00", "#0079ff", "#ffa500", "#800080", "#008080", "#ffc0cb", "#800000", "#000080", "#808000"], g = debounce(() => {
|
|
281
|
+
if (n && l[n] && s.get(n).getVisible() && G) {
|
|
282
282
|
console.log("reRenderTrackLine------------");
|
|
283
|
-
const i = cloneDeep(
|
|
284
|
-
ce(
|
|
283
|
+
const i = cloneDeep(M(n, l[n]));
|
|
284
|
+
ce(n, i);
|
|
285
285
|
}
|
|
286
|
-
}, 300),
|
|
286
|
+
}, 300), M = (i, c) => {
|
|
287
287
|
let d = [];
|
|
288
|
-
const
|
|
289
|
-
return d = c.filter((
|
|
290
|
-
if (Number(
|
|
291
|
-
const [
|
|
292
|
-
|
|
288
|
+
const p = Math.max(1, Math.floor(c.length / T));
|
|
289
|
+
return d = c.filter((k, _) => _ % p === 0).map((k, _) => {
|
|
290
|
+
if (Number(k.lon) > 180 || Number(k.lat) > 180) {
|
|
291
|
+
const [N, z] = convertSixHundredThousandToLatLng(k.lon, k.lat);
|
|
292
|
+
k.lon = N, k.lat = z;
|
|
293
293
|
}
|
|
294
|
-
return
|
|
294
|
+
return k.center = [k.lon, k.lat], k.centerPoint = lonLatToMercator(k.center), k.time = hooks(k.createdAt).format("YYYY-MM-DD HH:mm:ss"), k.id = i, k.index = _, k;
|
|
295
295
|
}), d;
|
|
296
|
-
},
|
|
297
|
-
if (!e || (c = c == null ? void 0 : c.reverse(),
|
|
296
|
+
}, V = async (i, c, d, p = "ship", b = 200) => {
|
|
297
|
+
if (!e || (c = c == null ? void 0 : c.reverse(), L && p === "ship" && (e != null && e.getOverlays().getArray().includes(L) || e.addOverlay(L)), (c == null ? void 0 : c.length) < 2))
|
|
298
298
|
return;
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
u = d ||
|
|
302
|
-
},
|
|
299
|
+
Q(i), n = i, l[i] = c, T = b;
|
|
300
|
+
const k = Object.keys(l).findIndex((_) => _ === i) || 0;
|
|
301
|
+
u = d || x[k > 10 ? 10 : k], G = !0, await R(), await ne(n);
|
|
302
|
+
}, D = (i) => {
|
|
303
303
|
const c = new VectorSource();
|
|
304
304
|
return new VectorLayer({
|
|
305
305
|
source: c,
|
|
@@ -310,46 +310,46 @@ const useTrackManager = (e) => {
|
|
|
310
310
|
// 增大渲染缓冲区
|
|
311
311
|
});
|
|
312
312
|
}, $ = (i) => {
|
|
313
|
-
|
|
314
|
-
var
|
|
315
|
-
const
|
|
316
|
-
c.getVisible() !==
|
|
317
|
-
}),
|
|
318
|
-
},
|
|
319
|
-
const i =
|
|
320
|
-
if (!
|
|
321
|
-
const
|
|
322
|
-
|
|
313
|
+
s.forEach((c, d) => {
|
|
314
|
+
var b;
|
|
315
|
+
const p = d === i;
|
|
316
|
+
c.getVisible() !== p && (c.setVisible(p), e.getLayers().getArray().includes(c) || e.addLayer(c), p || (b = c.getSource()) == null || b.clear());
|
|
317
|
+
}), n = i;
|
|
318
|
+
}, R = async () => {
|
|
319
|
+
const i = n;
|
|
320
|
+
if (!s.has(i)) {
|
|
321
|
+
const k = D(i);
|
|
322
|
+
s.set(i, k);
|
|
323
323
|
}
|
|
324
324
|
await $(i);
|
|
325
325
|
const c = u || "", d = l[i] || [];
|
|
326
326
|
if (!(d && d.length > 1)) return [];
|
|
327
|
-
let
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
},
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
334
|
-
|
|
327
|
+
let p = [];
|
|
328
|
+
p = M(i, d);
|
|
329
|
+
const b = p.map((k) => k.centerPoint);
|
|
330
|
+
p.length >= 2 && await S(i, b, c);
|
|
331
|
+
}, S = (i, c, d) => {
|
|
332
|
+
const p = new LineString(c), b = s.get(i).getSource(), k = b.getFeatureById(i);
|
|
333
|
+
if (k)
|
|
334
|
+
k.setGeometry(p), k.setId(i), k.setStyle(A(d)), E = k;
|
|
335
335
|
else {
|
|
336
|
-
const _ = new Feature({ geometry:
|
|
337
|
-
_.setId(i), _.set("type", "line"), _.setStyle(
|
|
336
|
+
const _ = new Feature({ geometry: p });
|
|
337
|
+
_.setId(i), _.set("type", "line"), _.setStyle(A(d)), b.addFeature(_), E = _;
|
|
338
338
|
}
|
|
339
|
-
return
|
|
340
|
-
},
|
|
339
|
+
return E;
|
|
340
|
+
}, A = (i) => new Style({
|
|
341
341
|
stroke: new Stroke({
|
|
342
342
|
color: i,
|
|
343
343
|
width: 2
|
|
344
344
|
})
|
|
345
|
-
}),
|
|
346
|
-
const
|
|
347
|
-
if (i &&
|
|
348
|
-
e.getTargetElement().style.cursor =
|
|
349
|
-
const
|
|
350
|
-
_ && (
|
|
345
|
+
}), X = (i, c, d) => {
|
|
346
|
+
const p = i == null ? void 0 : i.get("trackId");
|
|
347
|
+
if (i && p && c === "hover") {
|
|
348
|
+
e.getTargetElement().style.cursor = p ? "pointer" : "";
|
|
349
|
+
const b = i.get("data"), k = K(b), _ = d == null ? void 0 : d.coordinate;
|
|
350
|
+
_ && (m.querySelector(".popup-content"), m.innerHTML = k, L == null || L.setPosition(_));
|
|
351
351
|
} else
|
|
352
|
-
|
|
352
|
+
L && L.setPosition(void 0);
|
|
353
353
|
}, K = (i) => {
|
|
354
354
|
if (!(i != null && i.time)) return;
|
|
355
355
|
let c = "";
|
|
@@ -391,63 +391,63 @@ const useTrackManager = (e) => {
|
|
|
391
391
|
${c ?? c}
|
|
392
392
|
</div>`;
|
|
393
393
|
}, ie = (i) => {
|
|
394
|
-
const d = i.map((
|
|
395
|
-
const
|
|
394
|
+
const d = i.map((N) => {
|
|
395
|
+
const z = e.getPixelFromCoordinate(fromLonLat(N.center));
|
|
396
396
|
return {
|
|
397
|
-
...
|
|
398
|
-
original:
|
|
399
|
-
pixel:
|
|
397
|
+
...N,
|
|
398
|
+
original: N,
|
|
399
|
+
pixel: z,
|
|
400
400
|
distance: 0
|
|
401
401
|
// 先初始化,后续计算
|
|
402
402
|
};
|
|
403
403
|
});
|
|
404
|
-
let
|
|
404
|
+
let p = 0;
|
|
405
405
|
d[0].distance = 0;
|
|
406
|
-
for (let
|
|
407
|
-
const
|
|
408
|
-
|
|
406
|
+
for (let N = 1; N < d.length; N++) {
|
|
407
|
+
const z = d[N - 1].pixel, H = d[N].pixel, Y = H[0] - z[0], C = H[1] - z[1];
|
|
408
|
+
p += Math.sqrt(Y * Y + C * C), d[N].distance = p;
|
|
409
409
|
}
|
|
410
|
-
const
|
|
411
|
-
(
|
|
412
|
-
),
|
|
413
|
-
for (let
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
const
|
|
417
|
-
for (let
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
420
|
-
const
|
|
410
|
+
const b = d.filter(
|
|
411
|
+
(N, z) => z === 0 || z === d.length - 1
|
|
412
|
+
), k = [];
|
|
413
|
+
for (let N = 0; N < b.length; N++) {
|
|
414
|
+
const z = b[N];
|
|
415
|
+
if (k.push(z), N < b.length - 1) {
|
|
416
|
+
const H = b[N + 1], Y = H.distance - z.distance, C = Math.floor(Y / 100);
|
|
417
|
+
for (let Z = 1; Z <= C; Z++) {
|
|
418
|
+
const B = z.distance + Z * 100;
|
|
419
|
+
if (B >= H.distance) break;
|
|
420
|
+
const j = ae(
|
|
421
421
|
d,
|
|
422
|
-
|
|
422
|
+
B
|
|
423
423
|
);
|
|
424
|
-
|
|
424
|
+
j && k.push(j);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
return Array.from(
|
|
429
|
-
new Map(
|
|
430
|
-
).map((
|
|
431
|
-
...
|
|
429
|
+
new Map(k.map((N) => [N.distance.toFixed(2), N])).values()
|
|
430
|
+
).map((N) => ({
|
|
431
|
+
...N.original,
|
|
432
432
|
// 优先保留原始数据
|
|
433
|
-
...
|
|
433
|
+
...N,
|
|
434
434
|
// 覆盖坐标等计算属性
|
|
435
|
-
coord:
|
|
435
|
+
coord: N.coord,
|
|
436
436
|
// 确保使用插值后的坐标
|
|
437
|
-
pixel:
|
|
438
|
-
distance:
|
|
437
|
+
pixel: N.pixel,
|
|
438
|
+
distance: N.distance
|
|
439
439
|
}));
|
|
440
440
|
};
|
|
441
441
|
function ae(i, c) {
|
|
442
442
|
for (let d = 1; d < i.length; d++) {
|
|
443
|
-
const
|
|
444
|
-
if (c >=
|
|
445
|
-
const
|
|
443
|
+
const p = i[d - 1], b = i[d];
|
|
444
|
+
if (c >= p.distance && c <= b.distance) {
|
|
445
|
+
const k = (c - p.distance) / (b.distance - p.distance), _ = p.pixel[0] + k * (b.pixel[0] - p.pixel[0]), N = p.pixel[1] + k * (b.pixel[1] - p.pixel[1]), z = e == null ? void 0 : e.getCoordinateFromPixel([_, N]);
|
|
446
446
|
return {
|
|
447
|
-
...
|
|
447
|
+
...p,
|
|
448
448
|
// 继承前一个点的属性(可调整)
|
|
449
|
-
coord:
|
|
450
|
-
pixel: [_,
|
|
449
|
+
coord: z,
|
|
450
|
+
pixel: [_, N],
|
|
451
451
|
distance: c,
|
|
452
452
|
original: void 0
|
|
453
453
|
// 明确标记为插值生成点
|
|
@@ -458,9 +458,9 @@ const useTrackManager = (e) => {
|
|
|
458
458
|
}
|
|
459
459
|
const ce = async (i, c) => {
|
|
460
460
|
await re(), await ge(i);
|
|
461
|
-
const d = ie(c),
|
|
462
|
-
|
|
463
|
-
const _ = ue(i, u,
|
|
461
|
+
const d = ie(c), p = d.map((k) => de(k));
|
|
462
|
+
s.get(i).getSource().addFeatures(p), he(i, d, c, u), d.forEach((k) => {
|
|
463
|
+
const _ = ue(i, u, k);
|
|
464
464
|
e.addOverlay(_);
|
|
465
465
|
});
|
|
466
466
|
}, de = (i) => {
|
|
@@ -472,10 +472,10 @@ const useTrackManager = (e) => {
|
|
|
472
472
|
let d = [
|
|
473
473
|
...fe(i, u)
|
|
474
474
|
];
|
|
475
|
-
return (i.index === 0 || i.index === l[i.id].length - 1) && (d = [...
|
|
475
|
+
return (i.index === 0 || i.index === l[i.id].length - 1) && (d = [...ve(i)], c.set("type", "track_begin")), i.state !== void 0 && i.state !== null && (d = [...ye(i)], c.set("type", "track_icon")), c.setStyle(d), c;
|
|
476
476
|
}, ue = (i, c, d) => {
|
|
477
|
-
const
|
|
478
|
-
|
|
477
|
+
const p = document.createElement("div");
|
|
478
|
+
p.className = "track-overlay-label", p.style.position = "relative", p.style.backgroundColor = "rgba(255,255,255,0.8)", p.style.border = `1px solid ${c}`, p.style.fontSize = "12px", p.innerHTML = `
|
|
479
479
|
<span>${d.time}</span>
|
|
480
480
|
<svg
|
|
481
481
|
style="position: absolute;left: -20px;top: 0;"
|
|
@@ -488,22 +488,22 @@ const useTrackManager = (e) => {
|
|
|
488
488
|
stroke="${c}"
|
|
489
489
|
stroke-width="1" />
|
|
490
490
|
`;
|
|
491
|
-
const
|
|
492
|
-
element:
|
|
491
|
+
const b = new Overlay({
|
|
492
|
+
element: p,
|
|
493
493
|
position: fromLonLat(d.center),
|
|
494
494
|
positioning: "top-left",
|
|
495
495
|
offset: [20, -20],
|
|
496
496
|
stopEvent: !1,
|
|
497
497
|
className: "track-label-time-overlay"
|
|
498
498
|
});
|
|
499
|
-
return
|
|
499
|
+
return b.set("class", "track-label-overlay"), b.set("trackId", i), b;
|
|
500
500
|
}, re = () => {
|
|
501
501
|
const i = e == null ? void 0 : e.getOverlays().getArray(), c = i == null ? void 0 : i.filter((d) => d.get("class") === "track-label-overlay");
|
|
502
502
|
c && c.length > 0 && c.forEach((d) => {
|
|
503
503
|
d.setPosition(void 0), d.dispose();
|
|
504
504
|
});
|
|
505
505
|
}, ge = (i) => {
|
|
506
|
-
const c =
|
|
506
|
+
const c = s.get(i).getSource();
|
|
507
507
|
c.forEachFeature((d) => {
|
|
508
508
|
d.get("type") !== "line" && c.removeFeature(d);
|
|
509
509
|
});
|
|
@@ -525,107 +525,107 @@ const useTrackManager = (e) => {
|
|
|
525
525
|
})
|
|
526
526
|
// textStyle,
|
|
527
527
|
]), ye = (i) => {
|
|
528
|
-
const c = "#E31818", d = "#1890FF",
|
|
528
|
+
const c = "#E31818", d = "#1890FF", p = "", b = new Style({
|
|
529
529
|
text: new Text({
|
|
530
530
|
font: "Normal 22px map-iconfont",
|
|
531
|
-
text: getIconFont(
|
|
531
|
+
text: getIconFont(p),
|
|
532
532
|
offsetY: -10,
|
|
533
533
|
fill: new Fill({
|
|
534
534
|
color: Number(i.state) === 0 ? c : Number(i.state) === 1 ? d : ""
|
|
535
535
|
})
|
|
536
536
|
}),
|
|
537
537
|
zIndex: 99
|
|
538
|
-
}), _ = getIconStyle(""),
|
|
539
|
-
return Number(i.state) === 0 ?
|
|
540
|
-
},
|
|
541
|
-
const
|
|
542
|
-
|
|
538
|
+
}), _ = getIconStyle(""), z = getIconStyle(""), H = [];
|
|
539
|
+
return Number(i.state) === 0 ? H.push(_) : Number(i.state) === 1 && H.push(z), H.push(b), H;
|
|
540
|
+
}, he = (i, c, d, p) => {
|
|
541
|
+
const b = c || [], k = c.length;
|
|
542
|
+
k || (b.push(d[0]), b.push(d[d.length - 1]));
|
|
543
543
|
const _ = [];
|
|
544
|
-
for (let
|
|
545
|
-
let
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
|
|
544
|
+
for (let z = 0; z < k - 1; z++) {
|
|
545
|
+
let H;
|
|
546
|
+
const Y = c[z], C = (c[z + 1].index + Y.index) / 2;
|
|
547
|
+
if (C % 2 === 0)
|
|
548
|
+
H = d[C].centerPoint;
|
|
549
549
|
else {
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
552
|
-
const [
|
|
553
|
-
|
|
550
|
+
const Z = d[Math.floor(C)], B = d[Math.ceil(C)];
|
|
551
|
+
if (Z && B) {
|
|
552
|
+
const [j, J] = Z.centerPoint, [I, ee] = B.centerPoint;
|
|
553
|
+
H = [(j + I) / 2, (J + ee) / 2];
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
|
-
if (
|
|
557
|
-
const
|
|
558
|
-
geometry: new Point(
|
|
556
|
+
if (H) {
|
|
557
|
+
const Z = new Feature({
|
|
558
|
+
geometry: new Point(H)
|
|
559
559
|
});
|
|
560
|
-
|
|
560
|
+
Z.set("type", "track_arrow"), Z.setStyle(
|
|
561
561
|
new Style({
|
|
562
562
|
text: new Text({
|
|
563
563
|
font: "700 12px map-iconfont",
|
|
564
564
|
text: getIconFont(""),
|
|
565
|
-
fill: new Fill({ color:
|
|
565
|
+
fill: new Fill({ color: p }),
|
|
566
566
|
// 设置箭头旋转 角度转为弧度
|
|
567
567
|
rotation: le(
|
|
568
|
-
c[
|
|
569
|
-
c[
|
|
568
|
+
c[z].center,
|
|
569
|
+
c[z + 1].center
|
|
570
570
|
) * (Math.PI / 180)
|
|
571
571
|
})
|
|
572
572
|
})
|
|
573
|
-
), _.push(
|
|
573
|
+
), _.push(Z);
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
const
|
|
577
|
-
|
|
576
|
+
const N = s.get(i).getSource();
|
|
577
|
+
N == null || N.addFeatures(_);
|
|
578
578
|
}, ne = (i) => {
|
|
579
|
-
var
|
|
580
|
-
const c = e.getView(), d = (
|
|
581
|
-
if (!
|
|
582
|
-
const
|
|
583
|
-
if (
|
|
579
|
+
var k, _;
|
|
580
|
+
const c = e.getView(), d = (k = s == null ? void 0 : s.get(i)) == null ? void 0 : k.getSource(), p = E || (i ? d == null ? void 0 : d.getFeatureById(i) : null);
|
|
581
|
+
if (!p) return;
|
|
582
|
+
const b = (_ = p == null ? void 0 : p.getGeometry()) == null ? void 0 : _.getExtent();
|
|
583
|
+
if (b != null && b.length)
|
|
584
584
|
try {
|
|
585
|
-
const
|
|
586
|
-
c.fit(
|
|
587
|
-
} catch (
|
|
588
|
-
console.log(
|
|
585
|
+
const N = buffer(b, Math.max(b[2] - b[0], b[3] - b[1]) * 0.02);
|
|
586
|
+
c.fit(N);
|
|
587
|
+
} catch (N) {
|
|
588
|
+
console.log(N);
|
|
589
589
|
}
|
|
590
|
-
},
|
|
591
|
-
const c = "",
|
|
590
|
+
}, ve = (i) => {
|
|
591
|
+
const c = "", b = i.index === 0 ? "#fcdc3f" : "#ff0000";
|
|
592
592
|
return [new Style({
|
|
593
593
|
text: new Text({
|
|
594
594
|
font: "Normal 14px map-iconfont",
|
|
595
595
|
text: getIconFont(c),
|
|
596
|
-
fill: new Fill({ color:
|
|
596
|
+
fill: new Fill({ color: b })
|
|
597
597
|
}),
|
|
598
598
|
zIndex: 101
|
|
599
599
|
})];
|
|
600
|
-
},
|
|
601
|
-
console.log("清除所有的轨迹-----"), U(),
|
|
600
|
+
}, me = () => {
|
|
601
|
+
console.log("清除所有的轨迹-----"), U(), s.forEach((c) => {
|
|
602
602
|
var d;
|
|
603
603
|
(d = c.getSource()) == null || d.clear(), e == null || e.removeLayer(c);
|
|
604
604
|
}), Object.keys(l).forEach((c) => {
|
|
605
|
-
|
|
606
|
-
}),
|
|
605
|
+
s.delete(c), delete l[c];
|
|
606
|
+
}), G = !1, re();
|
|
607
607
|
}, we = (i) => {
|
|
608
|
-
const c =
|
|
608
|
+
const c = s.get(i || n);
|
|
609
609
|
c == null || c.setVisible(!1);
|
|
610
610
|
const d = e.getOverlays().getArray();
|
|
611
|
-
for (let
|
|
612
|
-
const
|
|
613
|
-
|
|
611
|
+
for (let p = 0; p < d.length; ) {
|
|
612
|
+
const b = d[p];
|
|
613
|
+
b.get("class") === "track-label-overlay" ? (b.setPosition(void 0), e.removeOverlay(b)) : p++;
|
|
614
614
|
}
|
|
615
615
|
U();
|
|
616
616
|
}, pe = (i, c = LENGTH_UNIT.NM) => {
|
|
617
617
|
const d = {
|
|
618
618
|
id: i,
|
|
619
619
|
length: "--"
|
|
620
|
-
},
|
|
620
|
+
}, b = (l[i] || []).map(
|
|
621
621
|
(_) => transform([_.lon, _.lat], projection.data, projection.mercator)
|
|
622
|
-
),
|
|
623
|
-
return d.length = formatLength(
|
|
622
|
+
), k = new LineString(b);
|
|
623
|
+
return d.length = formatLength(k, c) || "--", d;
|
|
624
624
|
}, Le = (i, c) => {
|
|
625
625
|
xe(String(i), c);
|
|
626
626
|
}, xe = (i, c) => {
|
|
627
|
-
const d = l[String(i)],
|
|
628
|
-
|
|
627
|
+
const d = l[String(i)], p = d == null ? void 0 : d.map((b) => [b.lon, b.lat]);
|
|
628
|
+
p && ke(p, c);
|
|
629
629
|
}, te = new Style({
|
|
630
630
|
text: new Text({
|
|
631
631
|
font: "700 20px map-iconfont",
|
|
@@ -635,120 +635,120 @@ const useTrackManager = (e) => {
|
|
|
635
635
|
// 初始旋转角度
|
|
636
636
|
})
|
|
637
637
|
}), Me = (i, c) => {
|
|
638
|
-
var
|
|
639
|
-
const d = Number(50 * c),
|
|
640
|
-
if (
|
|
638
|
+
var C, Z;
|
|
639
|
+
const d = Number(50 * c), p = ((C = i.frameState) == null ? void 0 : C.time) ?? Date.now(), b = p - f;
|
|
640
|
+
if (F = (F + d * b / 1e6) % 2, f = p, F >= 1) {
|
|
641
641
|
U();
|
|
642
642
|
return;
|
|
643
643
|
}
|
|
644
|
-
const
|
|
645
|
-
|
|
644
|
+
const k = r.getCoordinateAt(
|
|
645
|
+
F > 1 ? 2 - F : F
|
|
646
646
|
), _ = r.getCoordinateAt(
|
|
647
|
-
|
|
648
|
-
),
|
|
649
|
-
|
|
650
|
-
),
|
|
647
|
+
F > 1 ? F - 0.01 : F
|
|
648
|
+
), N = r.getCoordinateAt(
|
|
649
|
+
F > 1 ? 2 - F : F + 0.01
|
|
650
|
+
), H = le(
|
|
651
651
|
mercatorToLonLat(_, "array"),
|
|
652
|
-
mercatorToLonLat(
|
|
652
|
+
mercatorToLonLat(N, "array")
|
|
653
653
|
) * Math.PI / 180;
|
|
654
|
-
(
|
|
655
|
-
const
|
|
656
|
-
|
|
654
|
+
(Z = te.getText()) == null || Z.setRotation(H), v.setCoordinates(k);
|
|
655
|
+
const Y = getVectorContext(i);
|
|
656
|
+
Y.setStyle(te), Y.drawGeometry(v), e == null || e.render();
|
|
657
657
|
}, be = () => {
|
|
658
658
|
var i;
|
|
659
|
-
|
|
659
|
+
O = !0, f = Date.now(), F = 0, v = ((i = w.getGeometry()) == null ? void 0 : i.clone()) || new Point([0, 0]), o && (y == null || y.on("postrender", o)), P == null || P.setGeometry(void 0);
|
|
660
660
|
}, U = () => {
|
|
661
|
-
|
|
661
|
+
O && (O = !1, P == null || P.setGeometry(void 0), o && y && y.un("postrender", o), y && (e == null || e.removeLayer(y)), y = null, P = null);
|
|
662
662
|
}, ke = (i, c) => {
|
|
663
|
-
|
|
663
|
+
O && U(), t = new Polyline({
|
|
664
664
|
factor: 1e6
|
|
665
665
|
}).writeGeometry(new LineString(i)), r = new Polyline({
|
|
666
666
|
factor: 1e6
|
|
667
667
|
}).readGeometry(t, {
|
|
668
668
|
dataProjection: projection.data,
|
|
669
669
|
featureProjection: projection.mercator
|
|
670
|
-
}),
|
|
670
|
+
}), w = new Feature({
|
|
671
671
|
type: "icon",
|
|
672
672
|
geometry: new Point(r.getFirstCoordinate())
|
|
673
673
|
});
|
|
674
|
-
const d =
|
|
675
|
-
|
|
674
|
+
const d = w.getGeometry();
|
|
675
|
+
v = d ? d.clone() : new Point([0, 0]), P = new Feature({
|
|
676
676
|
type: "geoMarker",
|
|
677
677
|
style: te,
|
|
678
|
-
geometry:
|
|
679
|
-
}),
|
|
678
|
+
geometry: v
|
|
679
|
+
}), y = new VectorLayer({
|
|
680
680
|
source: new VectorSource({
|
|
681
|
-
features: [
|
|
681
|
+
features: [P]
|
|
682
682
|
})
|
|
683
|
-
}), e == null || e.addLayer(
|
|
683
|
+
}), e == null || e.addLayer(y), o = (p) => Me(p, c), be();
|
|
684
684
|
}, le = (i, c, d) => {
|
|
685
|
-
function
|
|
686
|
-
return 180 * (
|
|
685
|
+
function p(C) {
|
|
686
|
+
return 180 * (C % (2 * Math.PI)) / Math.PI;
|
|
687
687
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
688
|
+
function b(C) {
|
|
689
|
+
return C % 360 * Math.PI / 180;
|
|
690
690
|
}
|
|
691
|
-
function
|
|
692
|
-
var
|
|
693
|
-
if (!
|
|
694
|
-
if (!Array.isArray(
|
|
695
|
-
if ((
|
|
696
|
-
return
|
|
697
|
-
if (
|
|
691
|
+
function k(C) {
|
|
692
|
+
var Z;
|
|
693
|
+
if (!C) throw new Error("Coordinate is required");
|
|
694
|
+
if (!Array.isArray(C)) {
|
|
695
|
+
if ((C == null ? void 0 : C.type) === "Feature" && (C == null ? void 0 : C.geometry) !== null && ((Z = C == null ? void 0 : C.geometry) == null ? void 0 : Z.type) === "Point")
|
|
696
|
+
return C == null ? void 0 : C.geometry.coordinates;
|
|
697
|
+
if (C.type === "Point") return (C == null ? void 0 : C.coordinates) || [];
|
|
698
698
|
}
|
|
699
|
-
if (Array.isArray(
|
|
700
|
-
return
|
|
699
|
+
if (Array.isArray(C) && C.length >= 2 && !Array.isArray(C[0]) && !Array.isArray(C[1]))
|
|
700
|
+
return C;
|
|
701
701
|
throw new Error(
|
|
702
702
|
"Coordinate must be GeoJSON Point or an Array of numbers"
|
|
703
703
|
);
|
|
704
704
|
}
|
|
705
|
-
function _(
|
|
706
|
-
if (
|
|
705
|
+
function _(C, Z, B = {}) {
|
|
706
|
+
if (B.final)
|
|
707
707
|
return function(Te, Se) {
|
|
708
708
|
return (_(Se, Te) + 180) % 360;
|
|
709
|
-
}(
|
|
710
|
-
const
|
|
711
|
-
return
|
|
709
|
+
}(C, Z);
|
|
710
|
+
const j = k(C), J = k(Z), I = b(j[0]), ee = b(J[0]), se = b(j[1]), oe = b(J[1]), Ce = Math.sin(ee - I) * Math.cos(oe), Ee = Math.cos(se) * Math.sin(oe) - Math.sin(se) * Math.cos(oe) * Math.cos(ee - I);
|
|
711
|
+
return p(Math.atan2(Ce, Ee));
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
return !isNaN(
|
|
713
|
+
function N(C) {
|
|
714
|
+
return !isNaN(C) && C !== null && !Array.isArray(C);
|
|
715
715
|
}
|
|
716
|
-
function
|
|
717
|
-
return
|
|
716
|
+
function z(C, Z = {}, B = {}) {
|
|
717
|
+
return C || console.log("Coordinates are required"), Array.isArray(C) || console.log("Coordinates must be an Array"), C.length < 2 && console.log("Coordinates must be at least 2 numbers long"), (!N(C[0]) || !N(C[1])) && console.log("Coordinates must contain numbers"), H({ type: "Point", coordinates: C }, Z, B);
|
|
718
718
|
}
|
|
719
|
-
function
|
|
720
|
-
const
|
|
719
|
+
function H(C, Z = {}, B = {}) {
|
|
720
|
+
const j = {
|
|
721
721
|
type: "Feature",
|
|
722
722
|
id: "",
|
|
723
723
|
properties: {},
|
|
724
724
|
bbox: {},
|
|
725
725
|
geometry: {}
|
|
726
726
|
};
|
|
727
|
-
return
|
|
727
|
+
return B.id !== void 0 && (j.id = B.id), B.bbox && (j.bbox = B.bbox), j.properties = Z, j.geometry = C, j;
|
|
728
728
|
}
|
|
729
|
-
const
|
|
730
|
-
return
|
|
729
|
+
const Y = _(z(i), z(c), d);
|
|
730
|
+
return Y < 0 ? 360 + Y : Y;
|
|
731
731
|
};
|
|
732
732
|
return {
|
|
733
|
-
render:
|
|
734
|
-
remove:
|
|
733
|
+
render: V,
|
|
734
|
+
remove: me,
|
|
735
735
|
play: Le,
|
|
736
736
|
setCenter: ne,
|
|
737
737
|
close: we,
|
|
738
738
|
getLength: pe,
|
|
739
|
-
handleTrackMapEvent:
|
|
740
|
-
reRenderTrackLine:
|
|
739
|
+
handleTrackMapEvent: X,
|
|
740
|
+
reRenderTrackLine: g
|
|
741
741
|
};
|
|
742
742
|
};
|
|
743
743
|
function useShipOverlay(e) {
|
|
744
|
-
const
|
|
744
|
+
const s = ref(null);
|
|
745
745
|
ref(null);
|
|
746
746
|
const l = computed(() => ({
|
|
747
747
|
"--overlay-color": e.color || "#FFF",
|
|
748
748
|
"--bg-color": e.selected ? e.color : "#ffffff",
|
|
749
749
|
position: "relative",
|
|
750
750
|
"pointer-events": "none"
|
|
751
|
-
})),
|
|
751
|
+
})), n = computed(() => ({
|
|
752
752
|
position: "relative",
|
|
753
753
|
"border-radius": "1px",
|
|
754
754
|
"background-color": "var(--bg-color)",
|
|
@@ -784,7 +784,7 @@ function useShipOverlay(e) {
|
|
|
784
784
|
left: "-20px"
|
|
785
785
|
}));
|
|
786
786
|
return () => h("div", {
|
|
787
|
-
ref:
|
|
787
|
+
ref: s,
|
|
788
788
|
class: "ship-overlay-container",
|
|
789
789
|
style: l.value
|
|
790
790
|
}, [
|
|
@@ -792,7 +792,7 @@ function useShipOverlay(e) {
|
|
|
792
792
|
"div",
|
|
793
793
|
{
|
|
794
794
|
class: "ship-overlay-content",
|
|
795
|
-
style:
|
|
795
|
+
style: n.value
|
|
796
796
|
},
|
|
797
797
|
[
|
|
798
798
|
h("div", {
|
|
@@ -849,43 +849,43 @@ function useShipOverlay(e) {
|
|
|
849
849
|
]);
|
|
850
850
|
}
|
|
851
851
|
ref([]);
|
|
852
|
-
function addOverlay(e,
|
|
853
|
-
if (
|
|
852
|
+
function addOverlay(e, s, l, n) {
|
|
853
|
+
if (s) {
|
|
854
854
|
const a = new Overlay({
|
|
855
855
|
element: l,
|
|
856
856
|
positioning: "top-left",
|
|
857
|
-
id: "label-" + (
|
|
857
|
+
id: "label-" + (n == null ? void 0 : n.id),
|
|
858
858
|
offset: [20, -20],
|
|
859
859
|
autoPan: !1,
|
|
860
|
-
position:
|
|
861
|
-
className:
|
|
860
|
+
position: s,
|
|
861
|
+
className: n.blinking ? "ship-label-overlay-blinking" : "ship-label-overlay"
|
|
862
862
|
});
|
|
863
863
|
a.set("class", "zh-map-ship-overlay"), e.addOverlay(a);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
const getShipDirectPath = (e) => {
|
|
867
|
-
const { spd:
|
|
868
|
-
return
|
|
869
|
-
}, createShipStyle = (e,
|
|
870
|
-
const { shipData: l } =
|
|
871
|
-
return initShipStyle(
|
|
867
|
+
const { spd: s, hdg: l, cog: n } = e;
|
|
868
|
+
return s ? l !== null && +l != 511 && n !== null ? n - +l >= 3 ? SHIP_DIRECT.right : n - +l <= -3 ? SHIP_DIRECT.left : SHIP_DIRECT.front : SHIP_DIRECT.front : "";
|
|
869
|
+
}, createShipStyle = (e, s) => {
|
|
870
|
+
const { shipData: l } = s.getProperties(), n = getShipType(e), a = getShipScale(e, l, n);
|
|
871
|
+
return initShipStyle(s, a, n);
|
|
872
872
|
}, getShipType = (e) => {
|
|
873
|
-
const
|
|
874
|
-
return
|
|
875
|
-
}, getShipScale = (e,
|
|
873
|
+
const s = e == null ? void 0 : e.getView().getZoom();
|
|
874
|
+
return s <= MAP_ZOOM.shipModelMax && s >= MAP_ZOOM.shipTriggleMin ? "ship" : "triangle";
|
|
875
|
+
}, getShipScale = (e, s, l) => {
|
|
876
876
|
if (l === "ship") {
|
|
877
|
-
const { len:
|
|
878
|
-
return Math.max(r,
|
|
877
|
+
const { len: n, wid: a } = s, o = 97, m = 20, t = 1 / (e == null ? void 0 : e.getView().getResolution()), r = n * t / o, w = a * t / m;
|
|
878
|
+
return Math.max(r, w);
|
|
879
879
|
}
|
|
880
880
|
return MAP_ZOOM.scaleNum;
|
|
881
|
-
}, initShipStyle = (e,
|
|
882
|
-
const { color:
|
|
881
|
+
}, initShipStyle = (e, s, l) => {
|
|
882
|
+
const { color: n, direct: a, isHighlight: o, shipData: m } = e.getProperties(), L = ((m == null ? void 0 : m.cog) - 90 + 360) % 360;
|
|
883
883
|
return new Style({
|
|
884
884
|
image: new Icon({
|
|
885
885
|
src: t(),
|
|
886
|
-
scale:
|
|
886
|
+
scale: s || MAP_ZOOM.scaleNum,
|
|
887
887
|
anchor: [0.5, 0.5],
|
|
888
|
-
rotation:
|
|
888
|
+
rotation: L * Math.PI / 180,
|
|
889
889
|
rotateWithView: !1
|
|
890
890
|
})
|
|
891
891
|
});
|
|
@@ -897,7 +897,7 @@ const getShipDirectPath = (e) => {
|
|
|
897
897
|
case "triangle":
|
|
898
898
|
return `<svg width="41" height="24" viewBox="0 0 41 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
899
899
|
<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"
|
|
900
|
-
fill="${
|
|
900
|
+
fill="${n}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "2" : "0.578947"}" />
|
|
901
901
|
<!--path船航向左边或者向前-->
|
|
902
902
|
${a === SHIP_DIRECT.left && `<path d="M30 12L40 12L40 8" stroke="${o ? "#FF2424" : "black"}" stroke-width="2"/>`}
|
|
903
903
|
<!--path船航向右边-->
|
|
@@ -909,7 +909,7 @@ const getShipDirectPath = (e) => {
|
|
|
909
909
|
case "ship":
|
|
910
910
|
return `<svg width="97" height="20" viewBox="0 0 97 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
911
911
|
<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"
|
|
912
|
-
fill="${
|
|
912
|
+
fill="${n}" stroke="${o ? "#FF2424" : "black"}" stroke-width="${o ? "4" : "0.578947"}"/>
|
|
913
913
|
${a === SHIP_DIRECT.left && `<path d="M86 10L96 10L96 6" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
914
914
|
${a === SHIP_DIRECT.right && `<path d="M86 10L96 10L96 14" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
915
915
|
${a === SHIP_DIRECT.front && `<path d="M86 10L96 10" stroke="${o ? "#FF2424" : "black"}" stroke-width="1.5"/>`}
|
|
@@ -919,53 +919,53 @@ const getShipDirectPath = (e) => {
|
|
|
919
919
|
return "";
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
|
-
}, selectedShipStyle = (e,
|
|
923
|
-
const l = selectedShipElement(e,
|
|
922
|
+
}, selectedShipStyle = (e, s) => {
|
|
923
|
+
const l = selectedShipElement(e, s), n = s.id, { lon: a, lat: o } = s, m = new Overlay({
|
|
924
924
|
element: l,
|
|
925
925
|
position: fromLonLat([a, o]),
|
|
926
|
-
id: "selected-" +
|
|
926
|
+
id: "selected-" + n,
|
|
927
927
|
positioning: "center-center",
|
|
928
928
|
offset: [0, 5],
|
|
929
929
|
className: "ship-selected-overlay"
|
|
930
930
|
});
|
|
931
|
-
return
|
|
932
|
-
}, selectedShipElement = (e,
|
|
933
|
-
const l = getShipType(e),
|
|
934
|
-
<svg style="transform:scale(${
|
|
931
|
+
return m.set("class", "ship-overlay-selected"), m;
|
|
932
|
+
}, selectedShipElement = (e, s) => {
|
|
933
|
+
const l = getShipType(e), n = getShipScale(e, s, l), a = l === "ship" ? 109 : 49, o = `
|
|
934
|
+
<svg style="transform:scale(${n});" xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 49 49" fill="none">
|
|
935
935
|
<path d="M1.99982 46.9998L1.99982 1.99982L46.9998 1.99982L46.9998 46.9998L1.99982 46.9998Z" fill="#FF2424" fill-opacity="0.2"/>
|
|
936
936
|
<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"/>
|
|
937
937
|
</svg>
|
|
938
|
-
`,
|
|
939
|
-
return
|
|
940
|
-
}, createLabelStyle = (e,
|
|
941
|
-
const { shipData: l, blinking:
|
|
942
|
-
a && o && addOverlay(e, fromLonLat([a, o]),
|
|
938
|
+
`, m = document.createElement("div");
|
|
939
|
+
return m.className = "ship-overlay-selected", m.innerHTML = o, m;
|
|
940
|
+
}, createLabelStyle = (e, s) => {
|
|
941
|
+
const { shipData: l, blinking: n } = s.getProperties(), { lon: a, lat: o } = l, m = createLabelElement(s);
|
|
942
|
+
a && o && addOverlay(e, fromLonLat([a, o]), m, { ...l, blinking: n });
|
|
943
943
|
}, createLabelElement = (e) => {
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
const l = e.getProperties(), { shipData:
|
|
944
|
+
const s = document.createElement("div");
|
|
945
|
+
s.className = "ship-overlay-box", s.style.position = "relative";
|
|
946
|
+
const l = e.getProperties(), { shipData: n, blinking: a, blinkingColor: o, name: m } = l, { lon: L, lat: t } = n, r = createVNode({
|
|
947
947
|
setup() {
|
|
948
948
|
return useShipOverlay({
|
|
949
949
|
selected: a,
|
|
950
|
-
name:
|
|
950
|
+
name: m,
|
|
951
951
|
color: o,
|
|
952
|
-
existDevice:
|
|
953
|
-
existMobile:
|
|
954
|
-
existWaterGauge:
|
|
952
|
+
existDevice: n == null ? void 0 : n.existDevice,
|
|
953
|
+
existMobile: n == null ? void 0 : n.existMobile,
|
|
954
|
+
existWaterGauge: n == null ? void 0 : n.existWaterGauge
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
957
|
});
|
|
958
|
-
return render(r,
|
|
958
|
+
return render(r, s), s;
|
|
959
959
|
}, getRightIcons = (e) => {
|
|
960
|
-
const
|
|
961
|
-
return e.existDevice &&
|
|
960
|
+
const s = [];
|
|
961
|
+
return e.existDevice && s.push(""), e.existMobile && s.push(""), e.existWaterGauge && s.push(""), s;
|
|
962
962
|
}, createLabelFeatureStyle = (e) => {
|
|
963
|
-
const { name:
|
|
964
|
-
<line x1="0" y1="0" x2="${10 +
|
|
963
|
+
const { name: s, rightIcons: l } = e.getProperties(), n = `${s} ${l.map((w) => getIconFont(w)).join(" ")} `, a = [20, -20], m = -Math.atan2(-a[1], a[0]), L = Math.sqrt(a[0] ** 2 + a[1] ** 2), t = `<svg viewBox="0 0 ${L + 10} 20" width="${L + 10}" height="20" xmlns="http://www.w3.org/2000/svg" >
|
|
964
|
+
<line x1="0" y1="0" x2="${10 + L}" y2="10" stroke="white" stroke-width="1"></line>
|
|
965
965
|
</svg>`;
|
|
966
966
|
return [new Style({
|
|
967
967
|
text: new Text({
|
|
968
|
-
text:
|
|
968
|
+
text: n,
|
|
969
969
|
fill: new Fill({ color: "#000000" }),
|
|
970
970
|
stroke: new Stroke({ color: "#ffffff", width: 1 }),
|
|
971
971
|
font: "Normal 12px map-iconfont",
|
|
@@ -978,18 +978,18 @@ const getShipDirectPath = (e) => {
|
|
|
978
978
|
src: `data:image/svg+xml;utf8,${encodeURIComponent(t)}`,
|
|
979
979
|
displacement: [16, -10],
|
|
980
980
|
anchor: [0.5, 0.5],
|
|
981
|
-
rotation:
|
|
981
|
+
rotation: m,
|
|
982
982
|
rotateWithView: !1
|
|
983
983
|
})
|
|
984
984
|
})];
|
|
985
985
|
}, useShipManager = (e) => {
|
|
986
|
-
let
|
|
987
|
-
const
|
|
988
|
-
source:
|
|
986
|
+
let s = null, l = null;
|
|
987
|
+
const n = new VectorSource(), a = new VectorImageLayer({
|
|
988
|
+
source: n,
|
|
989
989
|
className: "zh-map--ship-layer",
|
|
990
990
|
renderBuffer: 300,
|
|
991
991
|
zIndex: 101
|
|
992
|
-
}), o = new VectorSource(),
|
|
992
|
+
}), o = new VectorSource(), m = new VectorLayer({
|
|
993
993
|
source: o,
|
|
994
994
|
className: "zh-map--ship-label-layer",
|
|
995
995
|
zIndex: 102,
|
|
@@ -997,24 +997,24 @@ const getShipDirectPath = (e) => {
|
|
|
997
997
|
updateWhileAnimating: !1,
|
|
998
998
|
declutter: !0
|
|
999
999
|
});
|
|
1000
|
-
e == null || e.addLayer(a), e == null || e.addLayer(
|
|
1001
|
-
let
|
|
1002
|
-
const
|
|
1000
|
+
e == null || e.addLayer(a), e == null || e.addLayer(m);
|
|
1001
|
+
let L = "", t = {}, r = {};
|
|
1002
|
+
const w = (u) => {
|
|
1003
1003
|
if (!u || !e) return;
|
|
1004
|
-
const
|
|
1004
|
+
const x = (l == null ? void 0 : l.id) || (s == null ? void 0 : s.get("id"));
|
|
1005
1005
|
if (l) {
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1006
|
+
const g = u.filter((M) => M.id === x);
|
|
1007
|
+
g.length === 0 ? u.push(l) : l = g[0];
|
|
1008
1008
|
}
|
|
1009
|
-
|
|
1010
|
-
},
|
|
1011
|
-
const
|
|
1012
|
-
geometry: new Point(
|
|
1009
|
+
O(), f(!0), Q(u), P();
|
|
1010
|
+
}, v = (u) => {
|
|
1011
|
+
const x = (l == null ? void 0 : l.id) || (s == null ? void 0 : s.get("id")), g = fromLonLat([u == null ? void 0 : u.lon, u == null ? void 0 : u.lat]), M = u.fill || "#04C900", V = getShipDirectPath(u), D = new Feature({
|
|
1012
|
+
geometry: new Point(g),
|
|
1013
1013
|
// 船舶数据
|
|
1014
1014
|
shipData: u,
|
|
1015
1015
|
id: u.id,
|
|
1016
1016
|
name: u.cnname || "未命名船舶",
|
|
1017
|
-
selected: u.id ===
|
|
1017
|
+
selected: u.id === x,
|
|
1018
1018
|
// 图标
|
|
1019
1019
|
rightIcons: getRightIcons(u),
|
|
1020
1020
|
// 是否闪烁
|
|
@@ -1022,207 +1022,207 @@ const getShipDirectPath = (e) => {
|
|
|
1022
1022
|
// 闪烁颜色
|
|
1023
1023
|
blinkingColor: r[u.id] || "",
|
|
1024
1024
|
// 船舶颜色
|
|
1025
|
-
color:
|
|
1025
|
+
color: M,
|
|
1026
1026
|
// 船艏向的方向
|
|
1027
|
-
direct:
|
|
1027
|
+
direct: V,
|
|
1028
1028
|
// shipType,
|
|
1029
1029
|
// scale:scaleNum,
|
|
1030
1030
|
// rotation,
|
|
1031
1031
|
// 高亮
|
|
1032
1032
|
isHighlight: !1
|
|
1033
1033
|
});
|
|
1034
|
-
return
|
|
1035
|
-
},
|
|
1034
|
+
return D.set("clickGeometry", new Circle(g)), D;
|
|
1035
|
+
}, P = async () => {
|
|
1036
1036
|
if (!l || !e) return;
|
|
1037
|
-
let
|
|
1038
|
-
if (console.log("selectedOverlay----------",
|
|
1039
|
-
const
|
|
1040
|
-
await
|
|
1037
|
+
let x = e.getOverlays().getArray().find((g) => g.get("class") == "ship-overlay-selected");
|
|
1038
|
+
if (console.log("selectedOverlay----------", x), x) {
|
|
1039
|
+
const g = selectedShipElement(e, l);
|
|
1040
|
+
await x.setElement(g), await x.setPosition(fromLonLat([l.lon, l.lat]));
|
|
1041
1041
|
} else
|
|
1042
|
-
|
|
1042
|
+
x = selectedShipStyle(e, l), x && e.addOverlay(x);
|
|
1043
1043
|
setTimeout(() => {
|
|
1044
|
-
var
|
|
1045
|
-
|
|
1044
|
+
var g;
|
|
1045
|
+
x && ((g = x.get("element")) != null && g.parentElement) && (x.get("element").parentElement.style.display = "block");
|
|
1046
1046
|
}, 20);
|
|
1047
|
-
},
|
|
1048
|
-
e &&
|
|
1049
|
-
},
|
|
1050
|
-
const
|
|
1051
|
-
if (
|
|
1052
|
-
for (let
|
|
1053
|
-
if (!u &&
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1047
|
+
}, O = () => {
|
|
1048
|
+
e && n && (n.clear(), o.clear(), f());
|
|
1049
|
+
}, f = (u) => {
|
|
1050
|
+
const x = e.getOverlays().getArray().filter((g) => g.get("class") == "zh-map-ship-overlay");
|
|
1051
|
+
if (x && x.length > 0) {
|
|
1052
|
+
for (let g = 0; g < x.length; g++)
|
|
1053
|
+
if (!u && x[g].get("class") !== "ship-overlay-selected") {
|
|
1054
|
+
const M = x[g];
|
|
1055
|
+
M.setPosition(void 0), e.removeOverlay(M), M.dispose();
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
|
-
},
|
|
1059
|
-
t = u, r =
|
|
1060
|
-
const
|
|
1061
|
-
for (const
|
|
1062
|
-
const
|
|
1063
|
-
if ($ &&
|
|
1064
|
-
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1058
|
+
}, y = (u, x) => {
|
|
1059
|
+
t = u, r = x;
|
|
1060
|
+
const g = e.getOverlays().getArray(), M = n.getFeatures();
|
|
1061
|
+
for (const V in t) {
|
|
1062
|
+
const D = t[V], $ = g.find((S) => S.getId() === "label-" + V), R = M.find((S) => V === S.get("id"));
|
|
1063
|
+
if ($ && R) {
|
|
1064
|
+
R.set("blinking", D), R.set("blinkingColor", r[V] || "");
|
|
1065
|
+
const S = $.getElement(), A = createLabelElement(R), X = A.querySelector(".ship-overlay-line"), K = S == null ? void 0 : S.querySelector(".ship-overlay-line");
|
|
1066
|
+
S && S !== A && (K && X && X.replaceWith(K), $.setElement(A));
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
|
-
},
|
|
1069
|
+
}, F = (u) => {
|
|
1070
1070
|
if (!e) return;
|
|
1071
|
-
const
|
|
1072
|
-
u.forEach((
|
|
1073
|
-
$.set(
|
|
1071
|
+
const x = n.getFeatures(), g = o.getFeatures(), M = s ? s.get("id") : "", V = x.filter((S) => S.get("id") !== M), D = g == null ? void 0 : g.filter((S) => S.get("id") !== M), $ = /* @__PURE__ */ new Map();
|
|
1072
|
+
u.forEach((S) => {
|
|
1073
|
+
$.set(S.id, !0);
|
|
1074
1074
|
});
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
const
|
|
1078
|
-
if (!$.has(
|
|
1079
|
-
|
|
1075
|
+
const R = e.getOverlays().getArray();
|
|
1076
|
+
V.forEach((S) => {
|
|
1077
|
+
const A = S.get("id");
|
|
1078
|
+
if (!$.has(A))
|
|
1079
|
+
S.setStyle([]);
|
|
1080
1080
|
else {
|
|
1081
|
-
const K =
|
|
1082
|
-
(K == null ? void 0 : K.length) == 0 &&
|
|
1081
|
+
const K = S.getStyle();
|
|
1082
|
+
(K == null ? void 0 : K.length) == 0 && S.setStyle(createShipStyle(e, S));
|
|
1083
1083
|
}
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1086
|
-
}),
|
|
1087
|
-
const
|
|
1088
|
-
if (!$.has(
|
|
1089
|
-
|
|
1084
|
+
const X = R.find((K) => K.getId() === "label-" + A);
|
|
1085
|
+
X && X.setPosition(void 0);
|
|
1086
|
+
}), D.forEach((S) => {
|
|
1087
|
+
const A = S.get("id");
|
|
1088
|
+
if (!$.has(A))
|
|
1089
|
+
S.setStyle([]);
|
|
1090
1090
|
else {
|
|
1091
|
-
const
|
|
1092
|
-
(
|
|
1091
|
+
const X = S.getStyle();
|
|
1092
|
+
(X == null ? void 0 : X.length) == 0 && S.setStyle(createLabelFeatureStyle(S));
|
|
1093
1093
|
}
|
|
1094
1094
|
});
|
|
1095
|
-
},
|
|
1095
|
+
}, E = (u) => {
|
|
1096
1096
|
if (u) {
|
|
1097
1097
|
console.log("选中", u);
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1098
|
+
const x = n.getFeatures().find((g) => g.get("id") === u.id);
|
|
1099
|
+
x && (s = x), l = u, P();
|
|
1100
1100
|
} else
|
|
1101
|
-
console.log("取消选中"), l = null,
|
|
1102
|
-
},
|
|
1101
|
+
console.log("取消选中"), l = null, s = null, q();
|
|
1102
|
+
}, T = debounce((u, x, g) => {
|
|
1103
1103
|
if (u) {
|
|
1104
|
-
const
|
|
1105
|
-
if (e.getTargetElement().style.cursor =
|
|
1106
|
-
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1104
|
+
const M = u.get("shipData"), V = u.get("id");
|
|
1105
|
+
if (e.getTargetElement().style.cursor = V ? "pointer" : "", x === "click" && (E(M), g && g(V)), x === "hover") {
|
|
1106
|
+
L && L !== V && G(), L = V;
|
|
1107
|
+
const D = n.getFeatures().find(($) => $.get("id") === L);
|
|
1108
|
+
D == null || D.set("isHighlight", !0), D == null || D.setStyle(createShipStyle(e, D));
|
|
1109
1109
|
}
|
|
1110
1110
|
} else
|
|
1111
|
-
e.getTargetElement().style.cursor = "",
|
|
1112
|
-
}, 10),
|
|
1113
|
-
const u =
|
|
1114
|
-
|
|
1115
|
-
},
|
|
1111
|
+
e.getTargetElement().style.cursor = "", G();
|
|
1112
|
+
}, 10), G = () => {
|
|
1113
|
+
const u = L ? n.getFeatures().find((x) => x.get("id") === L) : null;
|
|
1114
|
+
L = null, u == null || u.set("isHighlight", !1), u == null || u.setStyle(createShipStyle(e, u));
|
|
1115
|
+
}, q = () => {
|
|
1116
1116
|
try {
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1117
|
+
const x = e.getOverlays().getArray().find((g) => g.get("class") == "ship-overlay-selected");
|
|
1118
|
+
x && x.setPosition(void 0);
|
|
1119
1119
|
} catch (u) {
|
|
1120
1120
|
console.log(u);
|
|
1121
1121
|
}
|
|
1122
|
-
},
|
|
1123
|
-
const
|
|
1124
|
-
geometry: new Point(
|
|
1122
|
+
}, W = (u) => {
|
|
1123
|
+
const x = fromLonLat([u == null ? void 0 : u.lon, u == null ? void 0 : u.lat]), g = new Feature({
|
|
1124
|
+
geometry: new Point(x),
|
|
1125
1125
|
name: u.cnname || "未命名船舶",
|
|
1126
1126
|
// 图标
|
|
1127
1127
|
rightIcons: getRightIcons(u)
|
|
1128
1128
|
});
|
|
1129
|
-
|
|
1130
|
-
const
|
|
1131
|
-
return
|
|
1132
|
-
},
|
|
1133
|
-
const
|
|
1134
|
-
u.forEach((
|
|
1135
|
-
const
|
|
1136
|
-
if (
|
|
1137
|
-
if (t[
|
|
1138
|
-
createLabelStyle(e,
|
|
1129
|
+
g.set("id", u.id);
|
|
1130
|
+
const M = createLabelFeatureStyle(g);
|
|
1131
|
+
return g.setStyle(M), g;
|
|
1132
|
+
}, Q = (u) => {
|
|
1133
|
+
const x = e.getView().getZoom();
|
|
1134
|
+
u.forEach((g) => {
|
|
1135
|
+
const M = v(g);
|
|
1136
|
+
if (M.setStyle(createShipStyle(e, M)), n.addFeature(M), (l == null ? void 0 : l.id) == g.id || x >= MAP_ZOOM.shipModelMin)
|
|
1137
|
+
if (t[g.id])
|
|
1138
|
+
createLabelStyle(e, M);
|
|
1139
1139
|
else {
|
|
1140
|
-
const
|
|
1141
|
-
o.addFeature(
|
|
1140
|
+
const V = W(g);
|
|
1141
|
+
o.addFeature(V);
|
|
1142
1142
|
}
|
|
1143
1143
|
});
|
|
1144
1144
|
};
|
|
1145
1145
|
return {
|
|
1146
|
-
render:
|
|
1147
|
-
selected:
|
|
1148
|
-
filter:
|
|
1149
|
-
blinking:
|
|
1150
|
-
clear:
|
|
1151
|
-
handleShipMapEvent:
|
|
1146
|
+
render: w,
|
|
1147
|
+
selected: E,
|
|
1148
|
+
filter: F,
|
|
1149
|
+
blinking: y,
|
|
1150
|
+
clear: O,
|
|
1151
|
+
handleShipMapEvent: T
|
|
1152
1152
|
};
|
|
1153
1153
|
}, useLayerManager = (e) => {
|
|
1154
|
-
const
|
|
1154
|
+
const s = () => e == null ? void 0 : e.getLayers(), l = ref("vector"), n = () => l.value, a = (t) => {
|
|
1155
1155
|
l.value = t;
|
|
1156
|
-
const r =
|
|
1157
|
-
r && (r == null || r.getArray().forEach((
|
|
1158
|
-
(
|
|
1156
|
+
const r = s();
|
|
1157
|
+
r && (r == null || r.getArray().forEach((w) => {
|
|
1158
|
+
(w.className_ === "vector" || w.className_ === "satellite") && w.setVisible(w.className_ === t);
|
|
1159
1159
|
}));
|
|
1160
1160
|
}, o = ref(!1);
|
|
1161
1161
|
return {
|
|
1162
|
-
getLayers:
|
|
1162
|
+
getLayers: s,
|
|
1163
1163
|
getGreenTileVisible: () => o.value,
|
|
1164
1164
|
setGreenTileVisible: (t) => {
|
|
1165
1165
|
if (t !== o.value) {
|
|
1166
1166
|
if (t) {
|
|
1167
|
-
const r =
|
|
1168
|
-
if (!r.getArray().find((
|
|
1169
|
-
const
|
|
1167
|
+
const r = s();
|
|
1168
|
+
if (!r.getArray().find((v) => v.className_ === "greenTile")) {
|
|
1169
|
+
const v = new TileLayer({
|
|
1170
1170
|
source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
|
|
1171
1171
|
visible: t,
|
|
1172
1172
|
zIndex: 2,
|
|
1173
1173
|
className: "greenTile"
|
|
1174
1174
|
});
|
|
1175
|
-
r.push(
|
|
1175
|
+
r.push(v);
|
|
1176
1176
|
}
|
|
1177
1177
|
} else {
|
|
1178
|
-
const r =
|
|
1179
|
-
|
|
1178
|
+
const r = s(), w = r.getArray().find((v) => v.className_ === "greenTile");
|
|
1179
|
+
w && r.remove(w);
|
|
1180
1180
|
}
|
|
1181
1181
|
o.value = t;
|
|
1182
1182
|
}
|
|
1183
1183
|
},
|
|
1184
|
-
getShowLayerType:
|
|
1184
|
+
getShowLayerType: n,
|
|
1185
1185
|
setShowLayerType: a
|
|
1186
1186
|
};
|
|
1187
1187
|
}, usePropsManager = () => {
|
|
1188
1188
|
const e = ref();
|
|
1189
1189
|
return {
|
|
1190
|
-
setProps: (
|
|
1191
|
-
e.value =
|
|
1190
|
+
setProps: (n) => {
|
|
1191
|
+
e.value = n;
|
|
1192
1192
|
},
|
|
1193
1193
|
getProps: () => e.value
|
|
1194
1194
|
};
|
|
1195
1195
|
}, usePositionManager = (e) => {
|
|
1196
|
-
const
|
|
1197
|
-
let l,
|
|
1198
|
-
const
|
|
1199
|
-
if (!(!
|
|
1200
|
-
if (
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1196
|
+
const s = "zh-map-location-layer";
|
|
1197
|
+
let l, n, a = null, o = null;
|
|
1198
|
+
const m = (f) => {
|
|
1199
|
+
if (!(!f || f.length === 0)) {
|
|
1200
|
+
if (n || (n = new VectorSource()), n.clear(), o) {
|
|
1201
|
+
const y = f.find((F) => F.id === o.id);
|
|
1202
|
+
y ? o = y : f.push(o);
|
|
1203
1203
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1204
|
+
f.forEach((y) => {
|
|
1205
|
+
L(y);
|
|
1206
1206
|
}), l || (l = new VectorLayer({
|
|
1207
|
-
className:
|
|
1208
|
-
source:
|
|
1207
|
+
className: s,
|
|
1208
|
+
source: n,
|
|
1209
1209
|
zIndex: 100
|
|
1210
1210
|
}), e == null || e.addLayer(l));
|
|
1211
1211
|
}
|
|
1212
|
-
},
|
|
1213
|
-
const
|
|
1214
|
-
geometry: new Point(fromLonLat([Number(
|
|
1212
|
+
}, L = (f) => {
|
|
1213
|
+
const y = getZoom(), [F, E] = f.latLon.split(","), T = new Feature({
|
|
1214
|
+
geometry: new Point(fromLonLat([Number(F), Number(E)]))
|
|
1215
1215
|
});
|
|
1216
|
-
|
|
1217
|
-
}, t = (
|
|
1218
|
-
const
|
|
1216
|
+
T.setStyle(t(f, y, f.id === (o == null ? void 0 : o.id))), T.set("loactionData", f), n.addFeature(T);
|
|
1217
|
+
}, t = (f, y, F) => {
|
|
1218
|
+
const E = {
|
|
1219
1219
|
image: new Icon({
|
|
1220
|
-
src:
|
|
1221
|
-
scale: 0.5 *
|
|
1220
|
+
src: F && f.selectedPath || f.defaultPath,
|
|
1221
|
+
scale: 0.5 * y / 10
|
|
1222
1222
|
})
|
|
1223
1223
|
};
|
|
1224
|
-
return
|
|
1225
|
-
text:
|
|
1224
|
+
return f.name && (E.text = new Text({
|
|
1225
|
+
text: f.name,
|
|
1226
1226
|
font: "12px sans-serif",
|
|
1227
1227
|
fill: new Fill({
|
|
1228
1228
|
color: "#000000"
|
|
@@ -1231,57 +1231,60 @@ const getShipDirectPath = (e) => {
|
|
|
1231
1231
|
color: "#FFFFFF"
|
|
1232
1232
|
}),
|
|
1233
1233
|
offsetY: 30
|
|
1234
|
-
})), new Style(
|
|
1234
|
+
})), new Style(E);
|
|
1235
1235
|
}, r = () => {
|
|
1236
1236
|
if (a) {
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
|
|
1237
|
+
const f = a.get("loactionData").id;
|
|
1238
|
+
n.getFeatures().forEach((y) => {
|
|
1239
|
+
y.get("loactionData").id !== f && n.removeFeature(y);
|
|
1240
1240
|
});
|
|
1241
1241
|
} else
|
|
1242
|
-
|
|
1243
|
-
},
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
|
|
1242
|
+
n.clear();
|
|
1243
|
+
}, w = () => {
|
|
1244
|
+
const f = a.get("loactionData"), y = getZoom();
|
|
1245
|
+
n.getFeatures().forEach((E) => {
|
|
1246
|
+
E.get("loactionData").id === f.id && (E == null || E.setStyle(t(f, y, !1)));
|
|
1247
1247
|
}), o = null, a = null;
|
|
1248
|
-
},
|
|
1249
|
-
|
|
1250
|
-
},
|
|
1248
|
+
}, v = (f) => {
|
|
1249
|
+
f ? (P(), O(f)) : clearSelectedPort();
|
|
1250
|
+
}, P = () => {
|
|
1251
1251
|
if (a) {
|
|
1252
|
-
const
|
|
1253
|
-
a.setStyle(t(
|
|
1252
|
+
const f = a.get("loactionData"), y = getZoom();
|
|
1253
|
+
a.setStyle(t(f, y, !1));
|
|
1254
1254
|
}
|
|
1255
|
-
},
|
|
1256
|
-
const
|
|
1257
|
-
o =
|
|
1255
|
+
}, O = (f) => {
|
|
1256
|
+
const y = n.getFeatures();
|
|
1257
|
+
o = f, a = y.find((F) => F.get("loactionData").id === f.id);
|
|
1258
1258
|
};
|
|
1259
1259
|
return {
|
|
1260
|
-
render:
|
|
1261
|
-
selected:
|
|
1262
|
-
clearSelected:
|
|
1260
|
+
render: m,
|
|
1261
|
+
selected: v,
|
|
1262
|
+
clearSelected: w,
|
|
1263
1263
|
clear: r
|
|
1264
1264
|
};
|
|
1265
1265
|
}, disableDoubleClickZoom = (e) => {
|
|
1266
|
-
e.getInteractions().forEach((
|
|
1267
|
-
|
|
1266
|
+
e.getInteractions().forEach((s) => {
|
|
1267
|
+
s instanceof DoubleClickZoom && s.setActive(!1);
|
|
1268
1268
|
});
|
|
1269
1269
|
}, enableDoubleClickZoom = (e) => {
|
|
1270
|
-
e.getInteractions().forEach((
|
|
1271
|
-
|
|
1270
|
+
e.getInteractions().forEach((s) => {
|
|
1271
|
+
s instanceof DoubleClickZoom && s.setActive(!0);
|
|
1272
1272
|
});
|
|
1273
|
-
},
|
|
1274
|
-
const l =
|
|
1275
|
-
|
|
1273
|
+
}, changeCursor = (e, s) => {
|
|
1274
|
+
const l = e.getViewport();
|
|
1275
|
+
l && (l.style.cursor = s);
|
|
1276
|
+
}, useDrawLineManager = (e, s) => {
|
|
1277
|
+
const l = ref([]), n = ref("km"), a = (g) => {
|
|
1278
|
+
n.value = g;
|
|
1276
1279
|
};
|
|
1277
1280
|
let o;
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1281
|
+
const m = ref(!1), L = () => {
|
|
1282
|
+
w(), disableDoubleClickZoom(e), changeCursor(e, "crosshair"), e.on("pointermove", O), e.getViewport().addEventListener("mouseout", () => {
|
|
1280
1283
|
o && o.classList.add("hidden");
|
|
1281
|
-
}),
|
|
1284
|
+
}), y(), m.value = !0;
|
|
1282
1285
|
};
|
|
1283
1286
|
let t, r;
|
|
1284
|
-
const
|
|
1287
|
+
const w = () => {
|
|
1285
1288
|
t = new VectorSource(), r = new VectorLayer({
|
|
1286
1289
|
source: t,
|
|
1287
1290
|
zIndex: 1e3,
|
|
@@ -1294,18 +1297,15 @@ const getShipDirectPath = (e) => {
|
|
|
1294
1297
|
}
|
|
1295
1298
|
}), e == null || e.addLayer(r);
|
|
1296
1299
|
};
|
|
1297
|
-
let
|
|
1298
|
-
const
|
|
1299
|
-
if (
|
|
1300
|
+
let v, P;
|
|
1301
|
+
const O = (g) => {
|
|
1302
|
+
if (g.dragging)
|
|
1300
1303
|
return;
|
|
1301
1304
|
let M = "点击选择起点";
|
|
1302
|
-
|
|
1303
|
-
}, v = (S) => {
|
|
1304
|
-
const M = e == null ? void 0 : e.getTargetElement();
|
|
1305
|
-
M && (M.style.cursor = S);
|
|
1305
|
+
v && (M = "单击继续,双击结束"), o && (o.innerHTML = M, P.setPosition(g.coordinate), o.classList.remove("hidden"));
|
|
1306
1306
|
};
|
|
1307
1307
|
let f;
|
|
1308
|
-
const
|
|
1308
|
+
const y = () => {
|
|
1309
1309
|
f = new Draw({
|
|
1310
1310
|
source: t,
|
|
1311
1311
|
type: "LineString",
|
|
@@ -1330,108 +1330,108 @@ const getShipDirectPath = (e) => {
|
|
|
1330
1330
|
}),
|
|
1331
1331
|
// 添加条件函数,判断是否应该出发点绘制
|
|
1332
1332
|
condition: (M) => M.originalEvent.target.tagName !== "DIV"
|
|
1333
|
-
}), e == null || e.addInteraction(f),
|
|
1334
|
-
let
|
|
1333
|
+
}), e == null || e.addInteraction(f), G(), q();
|
|
1334
|
+
let g;
|
|
1335
1335
|
f.on("drawstart", function(M) {
|
|
1336
|
-
var
|
|
1337
|
-
|
|
1338
|
-
let
|
|
1339
|
-
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1336
|
+
var D;
|
|
1337
|
+
v = M.feature, v.set("randomId", F());
|
|
1338
|
+
let V;
|
|
1339
|
+
g = (D = v.getGeometry()) == null ? void 0 : D.on("change", function($) {
|
|
1340
|
+
const R = $.target, S = computedDistance(R, n.value);
|
|
1341
|
+
V = R.getLastCoordinate(), E && S && (E.innerHTML = S), T.setPosition(V);
|
|
1342
1342
|
});
|
|
1343
1343
|
}), f.on("drawend", function() {
|
|
1344
|
-
var M,
|
|
1345
|
-
if (
|
|
1346
|
-
const
|
|
1347
|
-
l.value.push({ id:
|
|
1344
|
+
var M, V, D;
|
|
1345
|
+
if (E && (E.className = "ol-tooltip ol-tooltip-static ol-tooltip-measure"), E != null && E.innerHTML) {
|
|
1346
|
+
const $ = (v == null ? void 0 : v.get("randomId")) || F();
|
|
1347
|
+
l.value.push({ id: $, value: E == null ? void 0 : E.innerHTML }), E.innerHTML = `${E.innerHTML}<div class="ol-tooltip-delete-button" data-id="${$}"><i class="map-iconfont icon-delete"></i></div>`;
|
|
1348
1348
|
}
|
|
1349
|
-
(M = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || M.addEventListener("click", (
|
|
1350
|
-
var
|
|
1351
|
-
|
|
1352
|
-
const
|
|
1353
|
-
|
|
1354
|
-
}),
|
|
1349
|
+
(M = document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button")) == null || M.addEventListener("click", ($) => {
|
|
1350
|
+
var S;
|
|
1351
|
+
$.preventDefault(), $.stopPropagation();
|
|
1352
|
+
const R = (S = $.target) == null ? void 0 : S.getAttribute("data-id");
|
|
1353
|
+
R && Q(R);
|
|
1354
|
+
}), T.setOffset([0, -7]), v = null, E = null, G(), g && unByKey(g), (D = (V = s.getProps()) == null ? void 0 : V.lineDrawEnd) == null || D.call(V, l.value);
|
|
1355
1355
|
});
|
|
1356
|
-
},
|
|
1357
|
-
let
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1360
|
-
element:
|
|
1356
|
+
}, F = () => Math.random().toString(36).substring(2, 9);
|
|
1357
|
+
let E, T;
|
|
1358
|
+
const G = () => {
|
|
1359
|
+
E != null && E.parentNode && E.parentNode.removeChild(E), E = document.createElement("div"), E.className = "ol-tooltip ol-tooltip-measure", T = new Overlay({
|
|
1360
|
+
element: E,
|
|
1361
1361
|
offset: [0, -15],
|
|
1362
1362
|
positioning: "bottom-center",
|
|
1363
1363
|
stopEvent: !1,
|
|
1364
1364
|
insertFirst: !1
|
|
1365
|
-
}), e == null || e.addOverlay(
|
|
1366
|
-
},
|
|
1367
|
-
o != null && o.parentNode && o.parentNode.removeChild(o), o = document.createElement("div"), o.className = "ol-tooltip hidden",
|
|
1365
|
+
}), e == null || e.addOverlay(T);
|
|
1366
|
+
}, q = () => {
|
|
1367
|
+
o != null && o.parentNode && o.parentNode.removeChild(o), o = document.createElement("div"), o.className = "ol-tooltip hidden", P = new Overlay({
|
|
1368
1368
|
element: o,
|
|
1369
1369
|
offset: [15, 0],
|
|
1370
1370
|
positioning: "center-left"
|
|
1371
|
-
}), e == null || e.addOverlay(
|
|
1372
|
-
},
|
|
1373
|
-
l.value.forEach((
|
|
1374
|
-
var
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
}),
|
|
1380
|
-
},
|
|
1381
|
-
var
|
|
1382
|
-
const M = l.value.findIndex((
|
|
1371
|
+
}), e == null || e.addOverlay(P);
|
|
1372
|
+
}, W = () => {
|
|
1373
|
+
l.value.forEach((g, M) => {
|
|
1374
|
+
var $, R;
|
|
1375
|
+
const V = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
|
|
1376
|
+
V[M] && ((R = ($ = V[M]) == null ? void 0 : $.parentNode) == null || R.removeChild(V[M]));
|
|
1377
|
+
const D = t.getFeatures();
|
|
1378
|
+
D[M] && t.removeFeature(D[M]);
|
|
1379
|
+
}), u(), enableDoubleClickZoom(e), m.value = !1;
|
|
1380
|
+
}, Q = (g) => {
|
|
1381
|
+
var V, D, $, R;
|
|
1382
|
+
const M = l.value.findIndex((S) => S.id === g);
|
|
1383
1383
|
if (M !== -1) {
|
|
1384
1384
|
l.value.splice(M, 1);
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1387
|
-
const
|
|
1388
|
-
|
|
1385
|
+
const S = document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");
|
|
1386
|
+
S[M] && ((D = (V = S[M]) == null ? void 0 : V.parentNode) == null || D.removeChild(S[M]));
|
|
1387
|
+
const A = t.getFeatures();
|
|
1388
|
+
A[M] && t.removeFeature(A[M]);
|
|
1389
1389
|
}
|
|
1390
|
-
(
|
|
1391
|
-
},
|
|
1392
|
-
if (l.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((
|
|
1390
|
+
(R = ($ = s.getProps()) == null ? void 0 : $.lineDrawEnd) == null || R.call($, l.value);
|
|
1391
|
+
}, u = () => {
|
|
1392
|
+
if (l.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((g) => {
|
|
1393
1393
|
var M;
|
|
1394
|
-
(M =
|
|
1394
|
+
(M = g == null ? void 0 : g.parentNode) == null || M.removeChild(g);
|
|
1395
1395
|
}), t.clear(), f) {
|
|
1396
|
-
const
|
|
1397
|
-
|
|
1396
|
+
const g = e.getInteractions().getArray().find((M) => getUid(M) === getUid(f));
|
|
1397
|
+
g && e.removeInteraction(g);
|
|
1398
1398
|
}
|
|
1399
|
-
e.removeLayer(r), o != null && o.parentNode && o.parentNode.removeChild(o),
|
|
1399
|
+
e.removeLayer(r), o != null && o.parentNode && o.parentNode.removeChild(o), E != null && E.parentNode && E.parentNode.removeChild(E);
|
|
1400
1400
|
};
|
|
1401
1401
|
return {
|
|
1402
|
-
open:
|
|
1403
|
-
close:
|
|
1404
|
-
deleteLine:
|
|
1402
|
+
open: L,
|
|
1403
|
+
close: W,
|
|
1404
|
+
deleteLine: Q,
|
|
1405
1405
|
setUnit: a,
|
|
1406
|
-
getState: () =>
|
|
1406
|
+
getState: () => m.value
|
|
1407
1407
|
};
|
|
1408
|
-
}, computedDistance = (e,
|
|
1409
|
-
const
|
|
1408
|
+
}, computedDistance = (e, s) => {
|
|
1409
|
+
const n = getLength(e);
|
|
1410
1410
|
let a = "";
|
|
1411
|
-
switch (
|
|
1411
|
+
switch (s) {
|
|
1412
1412
|
case "m":
|
|
1413
|
-
a = `${Math.round(
|
|
1413
|
+
a = `${Math.round(n * 100) / 100} m`;
|
|
1414
1414
|
break;
|
|
1415
1415
|
case "km":
|
|
1416
|
-
a = `${Math.round(
|
|
1416
|
+
a = `${Math.round(n / 1e3 * 100) / 100} km`;
|
|
1417
1417
|
break;
|
|
1418
1418
|
case "nm":
|
|
1419
|
-
a = `${Math.round(
|
|
1419
|
+
a = `${Math.round(n / 1.852 * 100) / 100} nm`;
|
|
1420
1420
|
break;
|
|
1421
1421
|
}
|
|
1422
1422
|
return a;
|
|
1423
|
-
}, useDrawPolygonManager = (e,
|
|
1424
|
-
let l;
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1427
|
-
},
|
|
1428
|
-
|
|
1423
|
+
}, useDrawPolygonManager = (e, s) => {
|
|
1424
|
+
let l, n;
|
|
1425
|
+
const a = () => {
|
|
1426
|
+
o(), changeCursor(e, "crosshair");
|
|
1427
|
+
}, o = () => {
|
|
1428
|
+
t(), E(), q(), O();
|
|
1429
1429
|
};
|
|
1430
|
-
let
|
|
1431
|
-
const
|
|
1432
|
-
if (
|
|
1433
|
-
const
|
|
1434
|
-
source:
|
|
1430
|
+
let m = null, L = null;
|
|
1431
|
+
const t = () => {
|
|
1432
|
+
if (m && L) return;
|
|
1433
|
+
const u = new VectorSource(), x = new VectorLayer({
|
|
1434
|
+
source: u,
|
|
1435
1435
|
style: new Style({
|
|
1436
1436
|
stroke: new Stroke({
|
|
1437
1437
|
color: "#fbcc33",
|
|
@@ -1439,45 +1439,45 @@ const getShipDirectPath = (e) => {
|
|
|
1439
1439
|
})
|
|
1440
1440
|
})
|
|
1441
1441
|
});
|
|
1442
|
-
|
|
1443
|
-
|
|
1442
|
+
m = x, L = u, e.on("pointermove", w), e.addLayer(x), e.on(["dblclick"], function(g) {
|
|
1443
|
+
v && (g.stopPropagation(), g.preventDefault());
|
|
1444
1444
|
});
|
|
1445
1445
|
};
|
|
1446
|
-
let
|
|
1447
|
-
const
|
|
1448
|
-
if (
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1446
|
+
let r;
|
|
1447
|
+
const w = (u) => {
|
|
1448
|
+
if (u.dragging) return;
|
|
1449
|
+
const x = r ? "单击继续,双击结束" : "点击选择起点";
|
|
1450
|
+
T && (T.innerHTML = x, G.setPosition(u.coordinate));
|
|
1451
1451
|
};
|
|
1452
|
-
let
|
|
1453
|
-
const
|
|
1452
|
+
let v, P = !1;
|
|
1453
|
+
const O = () => {
|
|
1454
1454
|
if (l) {
|
|
1455
|
-
|
|
1455
|
+
T != null && T.parentNode && T.parentNode.removeChild(T);
|
|
1456
1456
|
const u = l.getGeometry();
|
|
1457
1457
|
if (!u) return;
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
<span class="text">面积:${
|
|
1461
|
-
`),
|
|
1462
|
-
const
|
|
1463
|
-
if (
|
|
1464
|
-
const
|
|
1465
|
-
|
|
1458
|
+
const x = f(u, "nm");
|
|
1459
|
+
y && (y.innerHTML = `
|
|
1460
|
+
<span class="text">面积:${x}${P ? '<span class="error pl-12">超出可以绘画的距离</span>' : ""}</span>
|
|
1461
|
+
`), y && (y.innerHTML += '<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');
|
|
1462
|
+
const g = u.getCoordinates(), M = g[0][g[0].length - 2];
|
|
1463
|
+
if (F.setPosition(M), m) {
|
|
1464
|
+
const D = m.getSource();
|
|
1465
|
+
D && l && (D.clear(), D.addFeature(l));
|
|
1466
1466
|
}
|
|
1467
1467
|
setTimeout(() => {
|
|
1468
|
-
var
|
|
1469
|
-
(
|
|
1470
|
-
var $,
|
|
1471
|
-
console.log("delete"),
|
|
1468
|
+
var D;
|
|
1469
|
+
(D = document.querySelector(".delete-icon")) == null || D.addEventListener("click", () => {
|
|
1470
|
+
var $, R;
|
|
1471
|
+
console.log("delete"), W(), (R = ($ = s.getProps()) == null ? void 0 : $.areaDrawEnd) == null || R.call($, []);
|
|
1472
1472
|
});
|
|
1473
1473
|
}, 0);
|
|
1474
|
-
const
|
|
1475
|
-
e == null || e.getView().setCenter(
|
|
1474
|
+
const V = getCenter(l.getGeometry().getExtent());
|
|
1475
|
+
e == null || e.getView().setCenter(V);
|
|
1476
1476
|
return;
|
|
1477
1477
|
}
|
|
1478
|
-
|
|
1478
|
+
v = new Draw({
|
|
1479
1479
|
type: "Polygon",
|
|
1480
|
-
source:
|
|
1480
|
+
source: L,
|
|
1481
1481
|
trace: !0,
|
|
1482
1482
|
style: [new Style({
|
|
1483
1483
|
stroke: new Stroke({
|
|
@@ -1496,30 +1496,28 @@ const getShipDirectPath = (e) => {
|
|
|
1496
1496
|
})
|
|
1497
1497
|
}),
|
|
1498
1498
|
geometry: function(u) {
|
|
1499
|
-
const
|
|
1500
|
-
return new MultiPoint(
|
|
1499
|
+
const x = u.getGeometry().getCoordinates();
|
|
1500
|
+
return new MultiPoint(x);
|
|
1501
1501
|
}
|
|
1502
1502
|
})]
|
|
1503
|
-
}), e == null || e.addInteraction(
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
const R = '<span class="error pl-4">超出可以绘画的距离</span>';
|
|
1511
|
-
v && (v.innerHTML = `
|
|
1503
|
+
}), e == null || e.addInteraction(v), v.on("drawstart", (u) => {
|
|
1504
|
+
var x;
|
|
1505
|
+
r = u.feature, n = (x = r.getGeometry()) == null ? void 0 : x.on("change", (g) => {
|
|
1506
|
+
const M = g.target, V = f(M, "nm"), $ = M.getCoordinates()[0], R = new LineString([$[$.length - 2], $[$.length - 1]]), S = computedDistance(R, "nm");
|
|
1507
|
+
if (P = Number(getLength(R) / 1e3) > 150, !V) return;
|
|
1508
|
+
const A = '<span class="error pl-4">超出可以绘画的距离</span>';
|
|
1509
|
+
y && (y.innerHTML = `
|
|
1512
1510
|
<div class="text">
|
|
1513
|
-
面积:${
|
|
1514
|
-
${
|
|
1511
|
+
面积:${V}
|
|
1512
|
+
${P ? A : ""}
|
|
1515
1513
|
</div>
|
|
1516
|
-
`),
|
|
1514
|
+
`), T && (T.innerHTML = `
|
|
1517
1515
|
<div class="text">
|
|
1518
|
-
面积:${
|
|
1516
|
+
面积:${V}
|
|
1519
1517
|
</div>
|
|
1520
|
-
<div class="text ${
|
|
1521
|
-
线段 ${$.length - 2}: ${
|
|
1522
|
-
${
|
|
1518
|
+
<div class="text ${P ? "error" : ""}">
|
|
1519
|
+
线段 ${$.length - 2}: ${S}
|
|
1520
|
+
${P ? A : ""}
|
|
1523
1521
|
|
|
1524
1522
|
</div>
|
|
1525
1523
|
<div>
|
|
@@ -1527,85 +1525,85 @@ const getShipDirectPath = (e) => {
|
|
|
1527
1525
|
</div>
|
|
1528
1526
|
`);
|
|
1529
1527
|
});
|
|
1530
|
-
}),
|
|
1531
|
-
var
|
|
1528
|
+
}), v.on("drawend", (u) => {
|
|
1529
|
+
var V, D, $, R;
|
|
1532
1530
|
if (!u.feature.getGeometry()) return;
|
|
1533
|
-
l = u.feature,
|
|
1534
|
-
const
|
|
1535
|
-
if (
|
|
1536
|
-
const
|
|
1537
|
-
($ = (
|
|
1531
|
+
l = u.feature, y && (y.innerHTML += '<span class="delete-icon"><i class="map-iconfont icon-delete" /></div>'), F.setOffset([10, 0]);
|
|
1532
|
+
const g = u.feature.getGeometry().getCoordinates(), M = g[0][g[0].length - 2];
|
|
1533
|
+
if (F.setPosition(M), T != null && T.parentNode && T.parentNode.removeChild(T), (V = s.getProps()) != null && V.areaDrawEnd) {
|
|
1534
|
+
const S = g[0].map((A) => transform(A, projection.mercator, projection.data));
|
|
1535
|
+
($ = (D = s.getProps()) == null ? void 0 : D.areaDrawEnd) == null || $.call(D, S);
|
|
1538
1536
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
})),
|
|
1542
|
-
var
|
|
1543
|
-
|
|
1537
|
+
v && (v.setActive(!1), e == null || e.removeInteraction(v), (e == null ? void 0 : e.getInteractions()).forEach((A) => {
|
|
1538
|
+
A instanceof Draw && (A.setActive(!1), e == null || e.removeInteraction(A));
|
|
1539
|
+
})), n && unByKey(n), (R = document.querySelector(".delete-icon")) == null || R.addEventListener("click", () => {
|
|
1540
|
+
var S, A;
|
|
1541
|
+
W(), (A = (S = s.getProps()) == null ? void 0 : S.areaDrawEnd) == null || A.call(S, []);
|
|
1544
1542
|
});
|
|
1545
1543
|
});
|
|
1546
|
-
},
|
|
1547
|
-
const
|
|
1548
|
-
switch (
|
|
1544
|
+
}, f = (u, x) => {
|
|
1545
|
+
const g = getArea(u);
|
|
1546
|
+
switch (x) {
|
|
1549
1547
|
case "km":
|
|
1550
|
-
return
|
|
1548
|
+
return g > 1e4 ? Math.round(g / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(g * 100) / 100 + " m<sup>2</sup>";
|
|
1551
1549
|
case "nm":
|
|
1552
|
-
return
|
|
1550
|
+
return g > 1e4 ? Math.round(g / 1e6 / Math.pow(1.852, 2) * 100) / 100 + " nm<sup>2</sup>" : Math.round(g * 100) / 100 + " m<sup>2</sup>";
|
|
1553
1551
|
}
|
|
1554
1552
|
};
|
|
1555
|
-
let
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
element:
|
|
1553
|
+
let y, F;
|
|
1554
|
+
const E = () => {
|
|
1555
|
+
y != null && y.parentNode && y.parentNode.removeChild(y), y = document.createElement("div"), y.style.display = "flex", y.className = "ol-tooltip ol-tooltip-draw-polygon", F = new Overlay({
|
|
1556
|
+
element: y,
|
|
1559
1557
|
offset: [0, -15],
|
|
1560
1558
|
positioning: "bottom-center",
|
|
1561
1559
|
stopEvent: !1,
|
|
1562
1560
|
insertFirst: !1
|
|
1563
|
-
}), e == null || e.addOverlay(
|
|
1561
|
+
}), e == null || e.addOverlay(F);
|
|
1564
1562
|
};
|
|
1565
|
-
let
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1568
|
-
element:
|
|
1563
|
+
let T, G;
|
|
1564
|
+
const q = () => {
|
|
1565
|
+
T != null && T.parentNode && T.parentNode.removeChild(T), T = document.createElement("div"), T.className = "ol-tooltip ol-help-tooltip", G = new Overlay({
|
|
1566
|
+
element: T,
|
|
1569
1567
|
offset: [15, 0],
|
|
1570
1568
|
positioning: "center-left"
|
|
1571
|
-
}), e == null || e.addOverlay(
|
|
1572
|
-
},
|
|
1573
|
-
|
|
1569
|
+
}), e == null || e.addOverlay(G);
|
|
1570
|
+
}, W = () => {
|
|
1571
|
+
L == null || L.clear(), l = null, E(), q(), O();
|
|
1574
1572
|
};
|
|
1575
1573
|
return {
|
|
1576
|
-
open:
|
|
1574
|
+
open: a,
|
|
1577
1575
|
close: () => {
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
})),
|
|
1576
|
+
L == null || L.clear(), L = null, m && (e.removeLayer(m), m = null), r = null, v && (v.setActive(!1), (e == null ? void 0 : e.getInteractions()).forEach((x) => {
|
|
1577
|
+
x instanceof Draw && (x.setActive(!1), e == null || e.removeInteraction(x));
|
|
1578
|
+
}), v = null), n && unByKey(n), T != null && T.parentElement && T.parentElement.removeChild(T), y != null && y.parentElement && y.parentElement.removeChild(y), G && e.removeOverlay(G), F && e.removeOverlay(F), changeCursor(e, "pointer");
|
|
1581
1579
|
},
|
|
1582
|
-
reset:
|
|
1580
|
+
reset: W
|
|
1583
1581
|
};
|
|
1584
1582
|
}, PORT_LAYER_CLASS_NAME = "zh-map-port-layer", usePortManager = (e) => {
|
|
1585
|
-
const
|
|
1586
|
-
let l,
|
|
1587
|
-
const
|
|
1583
|
+
const s = e.getInstall();
|
|
1584
|
+
let l, n, a = null, o = null;
|
|
1585
|
+
const m = (f) => {
|
|
1588
1586
|
if (!(!f || f.length === 0)) {
|
|
1589
|
-
if (
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1587
|
+
if (n || (n = new VectorSource()), n.clear(), o) {
|
|
1588
|
+
const y = f.find((F) => F.id === o.id);
|
|
1589
|
+
y ? o = y : f.push(o);
|
|
1592
1590
|
}
|
|
1593
|
-
f.forEach((
|
|
1594
|
-
|
|
1591
|
+
f.forEach((y) => {
|
|
1592
|
+
L(y);
|
|
1595
1593
|
}), l || (l = new VectorLayer({
|
|
1596
1594
|
className: PORT_LAYER_CLASS_NAME,
|
|
1597
|
-
source:
|
|
1595
|
+
source: n,
|
|
1598
1596
|
zIndex: 100
|
|
1599
|
-
}),
|
|
1597
|
+
}), s.addLayer(l));
|
|
1600
1598
|
}
|
|
1601
|
-
},
|
|
1602
|
-
const
|
|
1603
|
-
geometry: new Point(fromLonLat([Number(
|
|
1599
|
+
}, L = (f) => {
|
|
1600
|
+
const y = e.getZoom(), [F, E] = f.latLon.split(","), T = new Feature({
|
|
1601
|
+
geometry: new Point(fromLonLat([Number(F), Number(E)]))
|
|
1604
1602
|
});
|
|
1605
|
-
|
|
1606
|
-
}, t = (f,
|
|
1607
|
-
const
|
|
1608
|
-
<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="${
|
|
1603
|
+
T.setStyle(t(f, y, f.id === (o == null ? void 0 : o.id))), T.set("portData", f), n.addFeature(T);
|
|
1604
|
+
}, t = (f, y, F) => {
|
|
1605
|
+
const E = (G) => `<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1606
|
+
<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="${G}"/>
|
|
1609
1607
|
<g clip-path="url(#clip0_10059_122082)">
|
|
1610
1608
|
<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"/>
|
|
1611
1609
|
</g>
|
|
@@ -1615,138 +1613,136 @@ const getShipDirectPath = (e) => {
|
|
|
1615
1613
|
</clipPath>
|
|
1616
1614
|
</defs>
|
|
1617
1615
|
</svg>
|
|
1618
|
-
`,
|
|
1616
|
+
`, T = () => `data:image/svg+xml;utf8,${encodeURIComponent(E(F ? "#FF5733" : "#3370FF"))}`;
|
|
1619
1617
|
return new Style({
|
|
1620
1618
|
text: new Text({
|
|
1621
1619
|
text: f.shortName,
|
|
1622
1620
|
font: "12px sans-serif",
|
|
1623
1621
|
fill: new Fill({
|
|
1624
|
-
color:
|
|
1622
|
+
color: F ? "#ffffff" : "#000000"
|
|
1625
1623
|
}),
|
|
1626
1624
|
backgroundFill: new Fill({
|
|
1627
|
-
color:
|
|
1625
|
+
color: F ? "#FF5733" : "#FFFFFF"
|
|
1628
1626
|
}),
|
|
1629
1627
|
offsetY: 30
|
|
1630
1628
|
}),
|
|
1631
1629
|
image: new Icon({
|
|
1632
|
-
src:
|
|
1633
|
-
scale: 0.5 *
|
|
1634
|
-
})
|
|
1630
|
+
src: T(),
|
|
1631
|
+
scale: 0.5 * y / 10
|
|
1632
|
+
}),
|
|
1633
|
+
zIndex: F ? 110 : 100
|
|
1635
1634
|
});
|
|
1636
1635
|
}, r = () => {
|
|
1637
1636
|
if (a) {
|
|
1638
1637
|
console.log("清除非选中的港口");
|
|
1639
1638
|
const f = a.get("portData").id;
|
|
1640
|
-
|
|
1641
|
-
|
|
1639
|
+
n.getFeatures().forEach((y) => {
|
|
1640
|
+
y.get("portData").id !== f && n.removeFeature(y);
|
|
1642
1641
|
});
|
|
1643
1642
|
} else
|
|
1644
|
-
console.log("清除所有港口",
|
|
1645
|
-
},
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
}, m = (f) => {
|
|
1651
|
-
f ? (N(), D(f)) : g();
|
|
1652
|
-
}, N = () => {
|
|
1643
|
+
console.log("清除所有港口", n), n == null || n.clear();
|
|
1644
|
+
}, w = (f) => {
|
|
1645
|
+
if (!f)
|
|
1646
|
+
return v();
|
|
1647
|
+
(a == null ? void 0 : a.get("portData").id) !== f.id && (v(), P(f));
|
|
1648
|
+
}, v = () => {
|
|
1653
1649
|
if (a) {
|
|
1654
|
-
const f = a == null ? void 0 : a.get("portData"),
|
|
1655
|
-
a.setStyle(t(f,
|
|
1650
|
+
const f = a == null ? void 0 : a.get("portData"), y = e.getZoom();
|
|
1651
|
+
a.setStyle(t(f, y, !1));
|
|
1656
1652
|
}
|
|
1657
|
-
},
|
|
1658
|
-
const
|
|
1659
|
-
o = f, a =
|
|
1653
|
+
}, P = (f) => {
|
|
1654
|
+
const y = n.getFeatures();
|
|
1655
|
+
o = f, a = y.find((F) => F.get("portData").id === f.id), a.setStyle(t(f, e.getZoom(), !0));
|
|
1660
1656
|
};
|
|
1661
1657
|
return {
|
|
1662
|
-
render:
|
|
1658
|
+
render: m,
|
|
1663
1659
|
clear: r,
|
|
1664
|
-
selected:
|
|
1660
|
+
selected: w,
|
|
1665
1661
|
handlePortHover: (f) => {
|
|
1666
|
-
const
|
|
1667
|
-
f && f.get("portData") &&
|
|
1662
|
+
const y = s == null ? void 0 : s.getTargetElement();
|
|
1663
|
+
f && f.get("portData") && y && (y.style.cursor = "pointer");
|
|
1668
1664
|
}
|
|
1669
1665
|
};
|
|
1670
|
-
}, useEventManager = (e,
|
|
1671
|
-
const
|
|
1672
|
-
|
|
1666
|
+
}, useEventManager = (e, s, l, n, a, o) => {
|
|
1667
|
+
const m = e.getInstall();
|
|
1668
|
+
m.on("moveend", () => {
|
|
1673
1669
|
var t, r;
|
|
1674
|
-
const
|
|
1675
|
-
(r = (t =
|
|
1676
|
-
}),
|
|
1677
|
-
const t =
|
|
1678
|
-
|
|
1679
|
-
}),
|
|
1670
|
+
const L = e.getZoom();
|
|
1671
|
+
(r = (t = s.getProps()).mapMoveEnd) == null || r.call(t, L), l.reRenderTrackLine();
|
|
1672
|
+
}), m.on("pointermove", (L) => {
|
|
1673
|
+
const t = m.getEventPixel(L.originalEvent), r = m.forEachFeatureAtPixel(t, (w) => w);
|
|
1674
|
+
n.handleShipMapEvent(r, "hover"), l.handleTrackMapEvent(r, "hover", L), r && a.handlePortHover(r);
|
|
1675
|
+
}), m.on("movestart", () => {
|
|
1680
1676
|
console.log("movestart-----------------------");
|
|
1681
|
-
}),
|
|
1682
|
-
var
|
|
1677
|
+
}), m.on("click", debounce((L) => {
|
|
1678
|
+
var w, v, P;
|
|
1683
1679
|
if (console.log("1", o.getState()), o.getState()) return;
|
|
1684
|
-
const t =
|
|
1680
|
+
const t = m.getEventPixel(L.originalEvent), r = m.forEachFeatureAtPixel(
|
|
1685
1681
|
t,
|
|
1686
|
-
(
|
|
1687
|
-
if (
|
|
1688
|
-
return
|
|
1682
|
+
(O) => {
|
|
1683
|
+
if (O != null && O.get("shipData") || O != null && O.get("portData"))
|
|
1684
|
+
return O;
|
|
1689
1685
|
}
|
|
1690
1686
|
);
|
|
1691
1687
|
if (console.log("2", r), !!r) {
|
|
1692
|
-
if (
|
|
1693
|
-
|
|
1688
|
+
if (L.preventDefault(), L.stopPropagation(), r.get("shipData"))
|
|
1689
|
+
n.handleShipMapEvent(r, "click", (w = s.getProps()) == null ? void 0 : w.selectShip);
|
|
1694
1690
|
else if (r.get("portData")) {
|
|
1695
|
-
const
|
|
1696
|
-
a.selected(
|
|
1691
|
+
const O = r.get("portData");
|
|
1692
|
+
a.selected(O), (P = (v = s.getProps()) == null ? void 0 : v.selectPort) == null || P.call(v, O);
|
|
1697
1693
|
}
|
|
1698
1694
|
}
|
|
1699
1695
|
}, 150));
|
|
1700
1696
|
}, useMapController = () => {
|
|
1701
1697
|
const e = reactive([]);
|
|
1702
1698
|
return {
|
|
1703
|
-
createInstance: (
|
|
1699
|
+
createInstance: (n, a) => {
|
|
1704
1700
|
const o = useMapInitializer();
|
|
1705
|
-
o.initMap(
|
|
1706
|
-
const
|
|
1707
|
-
t.setProps(a),
|
|
1708
|
-
const r = useTrackManager(
|
|
1709
|
-
useEventManager(o, t, r,
|
|
1710
|
-
const
|
|
1711
|
-
const
|
|
1712
|
-
return [
|
|
1713
|
-
},
|
|
1701
|
+
o.initMap(n, a);
|
|
1702
|
+
const m = o.getInstall(), L = useLayerManager(m), t = usePropsManager();
|
|
1703
|
+
t.setProps(a), L.setShowLayerType(a.layerType), L.setGreenTileVisible(a.showGreenLayer);
|
|
1704
|
+
const r = useTrackManager(m), w = useCarTrackManager(m, r), v = useShipManager(m), P = usePositionManager(m), O = useDrawLineManager(m, t), f = useDrawPolygonManager(m, t), y = usePortManager(o);
|
|
1705
|
+
useEventManager(o, t, r, v, y, O);
|
|
1706
|
+
const F = () => {
|
|
1707
|
+
const T = m.getView().calculateExtent(o.getSize()), G = transform([T[0], T[1]], projection.mercator, projection.data), q = transform([T[2], T[3]], projection.mercator, projection.data);
|
|
1708
|
+
return [G[0], G[1], q[0], q[1]];
|
|
1709
|
+
}, E = {
|
|
1714
1710
|
id: Symbol("map-instance"),
|
|
1715
1711
|
innerMap: null,
|
|
1716
1712
|
map: o.getInstall(),
|
|
1717
1713
|
destroy: () => {
|
|
1718
|
-
e.splice(e.indexOf(
|
|
1714
|
+
e.splice(e.indexOf(E), 1);
|
|
1719
1715
|
},
|
|
1720
1716
|
methods: {
|
|
1721
1717
|
...o,
|
|
1722
|
-
layer:
|
|
1723
|
-
ship:
|
|
1718
|
+
layer: L,
|
|
1719
|
+
ship: v,
|
|
1724
1720
|
track: r,
|
|
1725
|
-
carTrack:
|
|
1721
|
+
carTrack: w,
|
|
1726
1722
|
port: {
|
|
1727
|
-
render:
|
|
1728
|
-
clear:
|
|
1729
|
-
selected:
|
|
1723
|
+
render: y.render,
|
|
1724
|
+
clear: y.clear,
|
|
1725
|
+
selected: y.selected
|
|
1730
1726
|
},
|
|
1731
|
-
position:
|
|
1732
|
-
drawLine:
|
|
1733
|
-
drawPolygon:
|
|
1727
|
+
position: P,
|
|
1728
|
+
drawLine: O,
|
|
1729
|
+
drawPolygon: f,
|
|
1734
1730
|
// 子模块
|
|
1735
1731
|
utils: {
|
|
1736
|
-
getCalculateExtent:
|
|
1732
|
+
getCalculateExtent: F,
|
|
1737
1733
|
convertSixHundredThousandToLatLng,
|
|
1738
1734
|
calculateCirclePoints
|
|
1739
1735
|
}
|
|
1740
1736
|
}
|
|
1741
1737
|
};
|
|
1742
|
-
return e.push(
|
|
1738
|
+
return e.push(E), E;
|
|
1743
1739
|
},
|
|
1744
|
-
destroyInstance: (
|
|
1745
|
-
const a = e.findIndex((o) => o.id ===
|
|
1740
|
+
destroyInstance: (n) => {
|
|
1741
|
+
const a = e.findIndex((o) => o.id === n);
|
|
1746
1742
|
a > -1 && (e[a].destroy(), e.splice(a, 1));
|
|
1747
1743
|
},
|
|
1748
1744
|
destroyAll: () => {
|
|
1749
|
-
e.forEach((
|
|
1745
|
+
e.forEach((n) => n.destroy()), e.splice(0, e.length);
|
|
1750
1746
|
},
|
|
1751
1747
|
getAllInstances: () => [...e]
|
|
1752
1748
|
};
|
|
@@ -1769,18 +1765,18 @@ const getShipDirectPath = (e) => {
|
|
|
1769
1765
|
selectPort: { type: Function, default: () => {
|
|
1770
1766
|
} }
|
|
1771
1767
|
},
|
|
1772
|
-
setup(e, { expose:
|
|
1773
|
-
const l = ref(),
|
|
1768
|
+
setup(e, { expose: s }) {
|
|
1769
|
+
const l = ref(), n = ref(), a = useMapController(), o = ref(), m = e, L = ref({
|
|
1774
1770
|
getInstall() {
|
|
1775
1771
|
}
|
|
1776
1772
|
});
|
|
1777
1773
|
return onMounted(() => {
|
|
1778
1774
|
var t;
|
|
1779
|
-
o.value = a.createInstance(l.value,
|
|
1775
|
+
o.value = a.createInstance(l.value, m), console.log(" instance.value?.methods", o.value.map), L.value = o.value.methods, (t = n.value) == null || t.setScaleLine(o.value.map, m.scaleLineUnit);
|
|
1780
1776
|
}), onUnmounted(() => {
|
|
1781
1777
|
var t, r;
|
|
1782
1778
|
a.destroyInstance((t = o == null ? void 0 : o.value) == null ? void 0 : t.id), (r = o.value) == null || r.destroy();
|
|
1783
|
-
}),
|
|
1779
|
+
}), s({
|
|
1784
1780
|
getZoom: () => {
|
|
1785
1781
|
var t;
|
|
1786
1782
|
return (t = o.value) == null ? void 0 : t.methods.getZoom();
|
|
@@ -1798,16 +1794,16 @@ const getShipDirectPath = (e) => {
|
|
|
1798
1794
|
return (t = o.value) == null ? void 0 : t.methods.getView();
|
|
1799
1795
|
},
|
|
1800
1796
|
setCenter: (t, r) => {
|
|
1801
|
-
var
|
|
1802
|
-
return (
|
|
1797
|
+
var w;
|
|
1798
|
+
return (w = o.value) == null ? void 0 : w.methods.setCenter(t, r);
|
|
1803
1799
|
},
|
|
1804
1800
|
getSize: () => {
|
|
1805
1801
|
var t;
|
|
1806
1802
|
return (t = o.value) == null ? void 0 : t.methods.getSize();
|
|
1807
1803
|
},
|
|
1808
1804
|
getCenter: (t, r) => {
|
|
1809
|
-
var
|
|
1810
|
-
return (
|
|
1805
|
+
var w;
|
|
1806
|
+
return (w = o.value) == null ? void 0 : w.methods.getCenter();
|
|
1811
1807
|
},
|
|
1812
1808
|
layer: {
|
|
1813
1809
|
setGreenTileVisible: (t) => {
|
|
@@ -1980,8 +1976,8 @@ const getShipDirectPath = (e) => {
|
|
|
1980
1976
|
return (r = o.value) == null ? void 0 : r.methods.utils.convertSixHundredThousandToLatLng(...t);
|
|
1981
1977
|
},
|
|
1982
1978
|
calculateCirclePoints: (t, r) => {
|
|
1983
|
-
var
|
|
1984
|
-
return (
|
|
1979
|
+
var w;
|
|
1980
|
+
return (w = o.value) == null ? void 0 : w.methods.utils.calculateCirclePoints(t, r);
|
|
1985
1981
|
}
|
|
1986
1982
|
}
|
|
1987
1983
|
}), (t, r) => (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
@@ -1993,7 +1989,7 @@ const getShipDirectPath = (e) => {
|
|
|
1993
1989
|
}, null, 512),
|
|
1994
1990
|
createVNode(ScaleLine, {
|
|
1995
1991
|
ref_key: "scaleLineRef",
|
|
1996
|
-
ref:
|
|
1992
|
+
ref: n
|
|
1997
1993
|
}, null, 512),
|
|
1998
1994
|
createVNode(ZoomControl, {
|
|
1999
1995
|
ref: "zoomControlRef",
|