zhihao-ui 1.3.15 → 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.
- package/dist/es/{Map-DbqPHi5v.js → Map-LV2xwnK-.js} +797 -792
- package/dist/es/index.js +1 -1
- package/dist/index.css +1 -1
- package/dist/types/components/Map/Map.vue.d.ts +4 -4
- package/dist/types/components/Map/index.d.ts +12 -12
- package/dist/types/components/Map/utils/cursor.d.ts +3 -2
- package/dist/types/components/Map/utils/events.d.ts +4 -2
- package/dist/umd/index.css +1 -1
- package/dist/umd/index.umd.cjs +27 -27
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -309,48 +309,48 @@ const useTrackManager = (e) => {
|
|
|
309
309
|
renderBuffer: 1024
|
|
310
310
|
// 增大渲染缓冲区
|
|
311
311
|
});
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
var
|
|
315
|
-
const
|
|
316
|
-
c.getVisible() !==
|
|
317
|
-
}),
|
|
318
|
-
},
|
|
319
|
-
const i =
|
|
320
|
-
if (!
|
|
321
|
-
const
|
|
322
|
-
|
|
312
|
+
}, $ = (i) => {
|
|
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
|
-
await
|
|
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
|
-
|
|
353
|
-
},
|
|
352
|
+
L && L.setPosition(void 0);
|
|
353
|
+
}, K = (i) => {
|
|
354
354
|
if (!(i != null && i.time)) return;
|
|
355
355
|
let c = "";
|
|
356
356
|
return i != null && i.stayTime && (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) => {
|
|
@@ -474,8 +474,8 @@ const useTrackManager = (e) => {
|
|
|
474
474
|
];
|
|
475
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
590
|
}, ve = (i) => {
|
|
591
|
-
const c = "",
|
|
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,198 +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
|
-
|
|
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 (
|
|
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
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1081
|
+
const K = S.getStyle();
|
|
1082
|
+
(K == null ? void 0 : K.length) == 0 && S.setStyle(createShipStyle(e, S));
|
|
1083
|
+
}
|
|
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
|
+
else {
|
|
1091
|
+
const X = S.getStyle();
|
|
1092
|
+
(X == null ? void 0 : X.length) == 0 && S.setStyle(createLabelFeatureStyle(S));
|
|
1084
1093
|
}
|
|
1085
1094
|
});
|
|
1086
|
-
},
|
|
1095
|
+
}, E = (u) => {
|
|
1087
1096
|
if (u) {
|
|
1088
1097
|
console.log("选中", u);
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1098
|
+
const x = n.getFeatures().find((g) => g.get("id") === u.id);
|
|
1099
|
+
x && (s = x), l = u, P();
|
|
1091
1100
|
} else
|
|
1092
|
-
console.log("取消选中"), l = null,
|
|
1093
|
-
},
|
|
1101
|
+
console.log("取消选中"), l = null, s = null, q();
|
|
1102
|
+
}, T = debounce((u, x, g) => {
|
|
1094
1103
|
if (u) {
|
|
1095
|
-
const
|
|
1096
|
-
if (e.getTargetElement().style.cursor =
|
|
1097
|
-
|
|
1098
|
-
const
|
|
1099
|
-
|
|
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));
|
|
1100
1109
|
}
|
|
1101
1110
|
} else
|
|
1102
|
-
e.getTargetElement().style.cursor = "",
|
|
1103
|
-
}, 10),
|
|
1104
|
-
const u =
|
|
1105
|
-
|
|
1106
|
-
},
|
|
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 = () => {
|
|
1107
1116
|
try {
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1117
|
+
const x = e.getOverlays().getArray().find((g) => g.get("class") == "ship-overlay-selected");
|
|
1118
|
+
x && x.setPosition(void 0);
|
|
1110
1119
|
} catch (u) {
|
|
1111
1120
|
console.log(u);
|
|
1112
1121
|
}
|
|
1113
|
-
},
|
|
1114
|
-
const
|
|
1115
|
-
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),
|
|
1116
1125
|
name: u.cnname || "未命名船舶",
|
|
1117
1126
|
// 图标
|
|
1118
1127
|
rightIcons: getRightIcons(u)
|
|
1119
1128
|
});
|
|
1120
|
-
|
|
1121
|
-
const
|
|
1122
|
-
return
|
|
1123
|
-
},
|
|
1124
|
-
const
|
|
1125
|
-
u.forEach((
|
|
1126
|
-
const
|
|
1127
|
-
if (
|
|
1128
|
-
if (t[
|
|
1129
|
-
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);
|
|
1130
1139
|
else {
|
|
1131
|
-
const
|
|
1132
|
-
o.addFeature(
|
|
1140
|
+
const V = W(g);
|
|
1141
|
+
o.addFeature(V);
|
|
1133
1142
|
}
|
|
1134
1143
|
});
|
|
1135
1144
|
};
|
|
1136
1145
|
return {
|
|
1137
|
-
render:
|
|
1138
|
-
selected:
|
|
1139
|
-
filter:
|
|
1140
|
-
blinking:
|
|
1141
|
-
clear:
|
|
1142
|
-
handleShipMapEvent:
|
|
1146
|
+
render: w,
|
|
1147
|
+
selected: E,
|
|
1148
|
+
filter: F,
|
|
1149
|
+
blinking: y,
|
|
1150
|
+
clear: O,
|
|
1151
|
+
handleShipMapEvent: T
|
|
1143
1152
|
};
|
|
1144
1153
|
}, useLayerManager = (e) => {
|
|
1145
|
-
const
|
|
1154
|
+
const s = () => e == null ? void 0 : e.getLayers(), l = ref("vector"), n = () => l.value, a = (t) => {
|
|
1146
1155
|
l.value = t;
|
|
1147
|
-
const r =
|
|
1148
|
-
r && (r == null || r.getArray().forEach((
|
|
1149
|
-
(
|
|
1156
|
+
const r = s();
|
|
1157
|
+
r && (r == null || r.getArray().forEach((w) => {
|
|
1158
|
+
(w.className_ === "vector" || w.className_ === "satellite") && w.setVisible(w.className_ === t);
|
|
1150
1159
|
}));
|
|
1151
1160
|
}, o = ref(!1);
|
|
1152
1161
|
return {
|
|
1153
|
-
getLayers:
|
|
1162
|
+
getLayers: s,
|
|
1154
1163
|
getGreenTileVisible: () => o.value,
|
|
1155
1164
|
setGreenTileVisible: (t) => {
|
|
1156
1165
|
if (t !== o.value) {
|
|
1157
1166
|
if (t) {
|
|
1158
|
-
const r =
|
|
1159
|
-
if (!r.getArray().find((
|
|
1160
|
-
const
|
|
1167
|
+
const r = s();
|
|
1168
|
+
if (!r.getArray().find((v) => v.className_ === "greenTile")) {
|
|
1169
|
+
const v = new TileLayer({
|
|
1161
1170
|
source: new XYZ({ url: BASE_MAP_LINK.greenTile }),
|
|
1162
1171
|
visible: t,
|
|
1163
1172
|
zIndex: 2,
|
|
1164
1173
|
className: "greenTile"
|
|
1165
1174
|
});
|
|
1166
|
-
r.push(
|
|
1175
|
+
r.push(v);
|
|
1167
1176
|
}
|
|
1168
1177
|
} else {
|
|
1169
|
-
const r =
|
|
1170
|
-
|
|
1178
|
+
const r = s(), w = r.getArray().find((v) => v.className_ === "greenTile");
|
|
1179
|
+
w && r.remove(w);
|
|
1171
1180
|
}
|
|
1172
1181
|
o.value = t;
|
|
1173
1182
|
}
|
|
1174
1183
|
},
|
|
1175
|
-
getShowLayerType:
|
|
1184
|
+
getShowLayerType: n,
|
|
1176
1185
|
setShowLayerType: a
|
|
1177
1186
|
};
|
|
1178
1187
|
}, usePropsManager = () => {
|
|
1179
1188
|
const e = ref();
|
|
1180
1189
|
return {
|
|
1181
|
-
setProps: (
|
|
1182
|
-
e.value =
|
|
1190
|
+
setProps: (n) => {
|
|
1191
|
+
e.value = n;
|
|
1183
1192
|
},
|
|
1184
1193
|
getProps: () => e.value
|
|
1185
1194
|
};
|
|
1186
1195
|
}, usePositionManager = (e) => {
|
|
1187
|
-
const
|
|
1188
|
-
let l,
|
|
1189
|
-
const
|
|
1190
|
-
if (!(!
|
|
1191
|
-
if (
|
|
1192
|
-
const
|
|
1193
|
-
|
|
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);
|
|
1194
1203
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1204
|
+
f.forEach((y) => {
|
|
1205
|
+
L(y);
|
|
1197
1206
|
}), l || (l = new VectorLayer({
|
|
1198
|
-
className:
|
|
1199
|
-
source:
|
|
1207
|
+
className: s,
|
|
1208
|
+
source: n,
|
|
1200
1209
|
zIndex: 100
|
|
1201
1210
|
}), e == null || e.addLayer(l));
|
|
1202
1211
|
}
|
|
1203
|
-
},
|
|
1204
|
-
const
|
|
1205
|
-
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)]))
|
|
1206
1215
|
});
|
|
1207
|
-
|
|
1208
|
-
}, t = (
|
|
1209
|
-
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 = {
|
|
1210
1219
|
image: new Icon({
|
|
1211
|
-
src:
|
|
1212
|
-
scale: 0.5 *
|
|
1220
|
+
src: F && f.selectedPath || f.defaultPath,
|
|
1221
|
+
scale: 0.5 * y / 10
|
|
1213
1222
|
})
|
|
1214
1223
|
};
|
|
1215
|
-
return
|
|
1216
|
-
text:
|
|
1224
|
+
return f.name && (E.text = new Text({
|
|
1225
|
+
text: f.name,
|
|
1217
1226
|
font: "12px sans-serif",
|
|
1218
1227
|
fill: new Fill({
|
|
1219
1228
|
color: "#000000"
|
|
@@ -1222,57 +1231,60 @@ const getShipDirectPath = (e) => {
|
|
|
1222
1231
|
color: "#FFFFFF"
|
|
1223
1232
|
}),
|
|
1224
1233
|
offsetY: 30
|
|
1225
|
-
})), new Style(
|
|
1234
|
+
})), new Style(E);
|
|
1226
1235
|
}, r = () => {
|
|
1227
1236
|
if (a) {
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1230
|
-
|
|
1237
|
+
const f = a.get("loactionData").id;
|
|
1238
|
+
n.getFeatures().forEach((y) => {
|
|
1239
|
+
y.get("loactionData").id !== f && n.removeFeature(y);
|
|
1231
1240
|
});
|
|
1232
1241
|
} else
|
|
1233
|
-
|
|
1234
|
-
},
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1237
|
-
|
|
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)));
|
|
1238
1247
|
}), o = null, a = null;
|
|
1239
|
-
},
|
|
1240
|
-
|
|
1241
|
-
},
|
|
1248
|
+
}, v = (f) => {
|
|
1249
|
+
f ? (P(), O(f)) : clearSelectedPort();
|
|
1250
|
+
}, P = () => {
|
|
1242
1251
|
if (a) {
|
|
1243
|
-
const
|
|
1244
|
-
a.setStyle(t(
|
|
1252
|
+
const f = a.get("loactionData"), y = getZoom();
|
|
1253
|
+
a.setStyle(t(f, y, !1));
|
|
1245
1254
|
}
|
|
1246
|
-
},
|
|
1247
|
-
const
|
|
1248
|
-
o =
|
|
1255
|
+
}, O = (f) => {
|
|
1256
|
+
const y = n.getFeatures();
|
|
1257
|
+
o = f, a = y.find((F) => F.get("loactionData").id === f.id);
|
|
1249
1258
|
};
|
|
1250
1259
|
return {
|
|
1251
|
-
render:
|
|
1252
|
-
selected:
|
|
1253
|
-
clearSelected:
|
|
1260
|
+
render: m,
|
|
1261
|
+
selected: v,
|
|
1262
|
+
clearSelected: w,
|
|
1254
1263
|
clear: r
|
|
1255
1264
|
};
|
|
1256
|
-
}, disableDoubleClickZoom = () => {
|
|
1257
|
-
|
|
1258
|
-
|
|
1265
|
+
}, disableDoubleClickZoom = (e) => {
|
|
1266
|
+
e.getInteractions().forEach((s) => {
|
|
1267
|
+
s instanceof DoubleClickZoom && s.setActive(!1);
|
|
1259
1268
|
});
|
|
1260
|
-
}, enableDoubleClickZoom = () => {
|
|
1261
|
-
|
|
1262
|
-
|
|
1269
|
+
}, enableDoubleClickZoom = (e) => {
|
|
1270
|
+
e.getInteractions().forEach((s) => {
|
|
1271
|
+
s instanceof DoubleClickZoom && s.setActive(!0);
|
|
1263
1272
|
});
|
|
1264
|
-
},
|
|
1265
|
-
const l =
|
|
1266
|
-
|
|
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;
|
|
1267
1279
|
};
|
|
1268
1280
|
let o;
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1281
|
+
const m = ref(!1), L = () => {
|
|
1282
|
+
w(), disableDoubleClickZoom(e), changeCursor(e, "crosshair"), e.on("pointermove", O), e.getViewport().addEventListener("mouseout", () => {
|
|
1271
1283
|
o && o.classList.add("hidden");
|
|
1272
|
-
}),
|
|
1284
|
+
}), y(), m.value = !0;
|
|
1273
1285
|
};
|
|
1274
1286
|
let t, r;
|
|
1275
|
-
const
|
|
1287
|
+
const w = () => {
|
|
1276
1288
|
t = new VectorSource(), r = new VectorLayer({
|
|
1277
1289
|
source: t,
|
|
1278
1290
|
zIndex: 1e3,
|
|
@@ -1285,19 +1297,16 @@ const getShipDirectPath = (e) => {
|
|
|
1285
1297
|
}
|
|
1286
1298
|
}), e == null || e.addLayer(r);
|
|
1287
1299
|
};
|
|
1288
|
-
let
|
|
1289
|
-
const
|
|
1290
|
-
if (
|
|
1300
|
+
let v, P;
|
|
1301
|
+
const O = (g) => {
|
|
1302
|
+
if (g.dragging)
|
|
1291
1303
|
return;
|
|
1292
|
-
let
|
|
1293
|
-
|
|
1294
|
-
}, v = (P) => {
|
|
1295
|
-
const x = e == null ? void 0 : e.getTargetElement();
|
|
1296
|
-
x && (x.style.cursor = P);
|
|
1304
|
+
let M = "点击选择起点";
|
|
1305
|
+
v && (M = "单击继续,双击结束"), o && (o.innerHTML = M, P.setPosition(g.coordinate), o.classList.remove("hidden"));
|
|
1297
1306
|
};
|
|
1298
|
-
let
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1307
|
+
let f;
|
|
1308
|
+
const y = () => {
|
|
1309
|
+
f = new Draw({
|
|
1301
1310
|
source: t,
|
|
1302
1311
|
type: "LineString",
|
|
1303
1312
|
style: new Style({
|
|
@@ -1320,109 +1329,109 @@ const getShipDirectPath = (e) => {
|
|
|
1320
1329
|
})
|
|
1321
1330
|
}),
|
|
1322
1331
|
// 添加条件函数,判断是否应该出发点绘制
|
|
1323
|
-
condition: (
|
|
1324
|
-
}), e == null || e.addInteraction(
|
|
1325
|
-
let
|
|
1326
|
-
|
|
1332
|
+
condition: (M) => M.originalEvent.target.tagName !== "DIV"
|
|
1333
|
+
}), e == null || e.addInteraction(f), G(), q();
|
|
1334
|
+
let g;
|
|
1335
|
+
f.on("drawstart", function(M) {
|
|
1327
1336
|
var D;
|
|
1328
|
-
|
|
1329
|
-
let
|
|
1330
|
-
|
|
1331
|
-
const
|
|
1332
|
-
|
|
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);
|
|
1333
1342
|
});
|
|
1334
|
-
}),
|
|
1335
|
-
var
|
|
1336
|
-
if (
|
|
1337
|
-
const
|
|
1338
|
-
l.value.push({ id:
|
|
1343
|
+
}), f.on("drawend", function() {
|
|
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>`;
|
|
1339
1348
|
}
|
|
1340
|
-
(
|
|
1341
|
-
var
|
|
1342
|
-
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1345
|
-
}),
|
|
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);
|
|
1346
1355
|
});
|
|
1347
|
-
},
|
|
1348
|
-
let
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1351
|
-
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,
|
|
1352
1361
|
offset: [0, -15],
|
|
1353
1362
|
positioning: "bottom-center",
|
|
1354
1363
|
stopEvent: !1,
|
|
1355
1364
|
insertFirst: !1
|
|
1356
|
-
}), e == null || e.addOverlay(
|
|
1357
|
-
},
|
|
1358
|
-
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({
|
|
1359
1368
|
element: o,
|
|
1360
1369
|
offset: [15, 0],
|
|
1361
1370
|
positioning: "center-left"
|
|
1362
|
-
}), e == null || e.addOverlay(
|
|
1363
|
-
},
|
|
1364
|
-
l.value.forEach((
|
|
1365
|
-
var
|
|
1366
|
-
const
|
|
1367
|
-
|
|
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]));
|
|
1368
1377
|
const D = t.getFeatures();
|
|
1369
|
-
D[
|
|
1370
|
-
}),
|
|
1371
|
-
},
|
|
1372
|
-
var
|
|
1373
|
-
const
|
|
1374
|
-
if (
|
|
1375
|
-
l.value.splice(
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
const
|
|
1379
|
-
|
|
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
|
+
if (M !== -1) {
|
|
1384
|
+
l.value.splice(M, 1);
|
|
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]);
|
|
1380
1389
|
}
|
|
1381
|
-
(
|
|
1382
|
-
},
|
|
1383
|
-
if (l.value = [], document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach((
|
|
1384
|
-
var
|
|
1385
|
-
(
|
|
1386
|
-
}), t.clear(),
|
|
1387
|
-
const
|
|
1388
|
-
|
|
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
|
+
var M;
|
|
1394
|
+
(M = g == null ? void 0 : g.parentNode) == null || M.removeChild(g);
|
|
1395
|
+
}), t.clear(), f) {
|
|
1396
|
+
const g = e.getInteractions().getArray().find((M) => getUid(M) === getUid(f));
|
|
1397
|
+
g && e.removeInteraction(g);
|
|
1389
1398
|
}
|
|
1390
|
-
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);
|
|
1391
1400
|
};
|
|
1392
1401
|
return {
|
|
1393
|
-
open:
|
|
1394
|
-
close:
|
|
1395
|
-
deleteLine:
|
|
1402
|
+
open: L,
|
|
1403
|
+
close: W,
|
|
1404
|
+
deleteLine: Q,
|
|
1396
1405
|
setUnit: a,
|
|
1397
|
-
getState: () =>
|
|
1406
|
+
getState: () => m.value
|
|
1398
1407
|
};
|
|
1399
|
-
}, computedDistance = (e,
|
|
1400
|
-
const
|
|
1408
|
+
}, computedDistance = (e, s) => {
|
|
1409
|
+
const n = getLength(e);
|
|
1401
1410
|
let a = "";
|
|
1402
|
-
switch (
|
|
1411
|
+
switch (s) {
|
|
1403
1412
|
case "m":
|
|
1404
|
-
a = `${Math.round(
|
|
1413
|
+
a = `${Math.round(n * 100) / 100} m`;
|
|
1405
1414
|
break;
|
|
1406
1415
|
case "km":
|
|
1407
|
-
a = `${Math.round(
|
|
1416
|
+
a = `${Math.round(n / 1e3 * 100) / 100} km`;
|
|
1408
1417
|
break;
|
|
1409
1418
|
case "nm":
|
|
1410
|
-
a = `${Math.round(
|
|
1419
|
+
a = `${Math.round(n / 1.852 * 100) / 100} nm`;
|
|
1411
1420
|
break;
|
|
1412
1421
|
}
|
|
1413
1422
|
return a;
|
|
1414
|
-
}, useDrawPolygonManager = (e,
|
|
1415
|
-
let l;
|
|
1416
|
-
const
|
|
1417
|
-
|
|
1418
|
-
},
|
|
1419
|
-
|
|
1423
|
+
}, useDrawPolygonManager = (e, s) => {
|
|
1424
|
+
let l, n;
|
|
1425
|
+
const a = () => {
|
|
1426
|
+
o(), changeCursor(e, "crosshair");
|
|
1427
|
+
}, o = () => {
|
|
1428
|
+
t(), E(), q(), O();
|
|
1420
1429
|
};
|
|
1421
|
-
let
|
|
1422
|
-
const
|
|
1423
|
-
if (
|
|
1424
|
-
const
|
|
1425
|
-
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,
|
|
1426
1435
|
style: new Style({
|
|
1427
1436
|
stroke: new Stroke({
|
|
1428
1437
|
color: "#fbcc33",
|
|
@@ -1430,45 +1439,45 @@ const getShipDirectPath = (e) => {
|
|
|
1430
1439
|
})
|
|
1431
1440
|
})
|
|
1432
1441
|
});
|
|
1433
|
-
|
|
1434
|
-
|
|
1442
|
+
m = x, L = u, e.on("pointermove", w), e.addLayer(x), e.on(["dblclick"], function(g) {
|
|
1443
|
+
v && (g.stopPropagation(), g.preventDefault());
|
|
1435
1444
|
});
|
|
1436
1445
|
};
|
|
1437
|
-
let
|
|
1438
|
-
const
|
|
1439
|
-
if (
|
|
1440
|
-
const
|
|
1441
|
-
|
|
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));
|
|
1442
1451
|
};
|
|
1443
|
-
let
|
|
1444
|
-
const
|
|
1452
|
+
let v, P = !1;
|
|
1453
|
+
const O = () => {
|
|
1445
1454
|
if (l) {
|
|
1446
|
-
|
|
1455
|
+
T != null && T.parentNode && T.parentNode.removeChild(T);
|
|
1447
1456
|
const u = l.getGeometry();
|
|
1448
1457
|
if (!u) return;
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1451
|
-
<span class="text">面积:${
|
|
1452
|
-
`),
|
|
1453
|
-
const
|
|
1454
|
-
if (
|
|
1455
|
-
const
|
|
1456
|
-
|
|
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));
|
|
1457
1466
|
}
|
|
1458
1467
|
setTimeout(() => {
|
|
1459
|
-
var
|
|
1460
|
-
(
|
|
1461
|
-
var
|
|
1462
|
-
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($, []);
|
|
1463
1472
|
});
|
|
1464
1473
|
}, 0);
|
|
1465
|
-
const
|
|
1466
|
-
e == null || e.getView().setCenter(
|
|
1474
|
+
const V = getCenter(l.getGeometry().getExtent());
|
|
1475
|
+
e == null || e.getView().setCenter(V);
|
|
1467
1476
|
return;
|
|
1468
1477
|
}
|
|
1469
|
-
|
|
1478
|
+
v = new Draw({
|
|
1470
1479
|
type: "Polygon",
|
|
1471
|
-
source:
|
|
1480
|
+
source: L,
|
|
1472
1481
|
trace: !0,
|
|
1473
1482
|
style: [new Style({
|
|
1474
1483
|
stroke: new Stroke({
|
|
@@ -1487,30 +1496,28 @@ const getShipDirectPath = (e) => {
|
|
|
1487
1496
|
})
|
|
1488
1497
|
}),
|
|
1489
1498
|
geometry: function(u) {
|
|
1490
|
-
const
|
|
1491
|
-
return new MultiPoint(
|
|
1499
|
+
const x = u.getGeometry().getCoordinates();
|
|
1500
|
+
return new MultiPoint(x);
|
|
1492
1501
|
}
|
|
1493
1502
|
})]
|
|
1494
|
-
}), e == null || e.addInteraction(
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1501
|
-
const R = '<span class="error pl-4">超出可以绘画的距离</span>';
|
|
1502
|
-
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 = `
|
|
1503
1510
|
<div class="text">
|
|
1504
|
-
面积:${
|
|
1505
|
-
${
|
|
1511
|
+
面积:${V}
|
|
1512
|
+
${P ? A : ""}
|
|
1506
1513
|
</div>
|
|
1507
|
-
`),
|
|
1514
|
+
`), T && (T.innerHTML = `
|
|
1508
1515
|
<div class="text">
|
|
1509
|
-
面积:${
|
|
1516
|
+
面积:${V}
|
|
1510
1517
|
</div>
|
|
1511
|
-
<div class="text ${
|
|
1512
|
-
线段 ${
|
|
1513
|
-
${
|
|
1518
|
+
<div class="text ${P ? "error" : ""}">
|
|
1519
|
+
线段 ${$.length - 2}: ${S}
|
|
1520
|
+
${P ? A : ""}
|
|
1514
1521
|
|
|
1515
1522
|
</div>
|
|
1516
1523
|
<div>
|
|
@@ -1518,85 +1525,85 @@ const getShipDirectPath = (e) => {
|
|
|
1518
1525
|
</div>
|
|
1519
1526
|
`);
|
|
1520
1527
|
});
|
|
1521
|
-
}),
|
|
1522
|
-
var
|
|
1528
|
+
}), v.on("drawend", (u) => {
|
|
1529
|
+
var V, D, $, R;
|
|
1523
1530
|
if (!u.feature.getGeometry()) return;
|
|
1524
|
-
l = u.feature,
|
|
1525
|
-
const
|
|
1526
|
-
if (
|
|
1527
|
-
const
|
|
1528
|
-
(
|
|
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);
|
|
1529
1536
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
})),
|
|
1533
|
-
var
|
|
1534
|
-
|
|
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, []);
|
|
1535
1542
|
});
|
|
1536
1543
|
});
|
|
1537
|
-
},
|
|
1538
|
-
const
|
|
1539
|
-
switch (
|
|
1544
|
+
}, f = (u, x) => {
|
|
1545
|
+
const g = getArea(u);
|
|
1546
|
+
switch (x) {
|
|
1540
1547
|
case "km":
|
|
1541
|
-
return
|
|
1548
|
+
return g > 1e4 ? Math.round(g / 1e6 * 100) / 100 + " km<sup>2</sup>" : Math.round(g * 100) / 100 + " m<sup>2</sup>";
|
|
1542
1549
|
case "nm":
|
|
1543
|
-
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>";
|
|
1544
1551
|
}
|
|
1545
1552
|
};
|
|
1546
|
-
let
|
|
1547
|
-
const
|
|
1548
|
-
|
|
1549
|
-
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,
|
|
1550
1557
|
offset: [0, -15],
|
|
1551
1558
|
positioning: "bottom-center",
|
|
1552
1559
|
stopEvent: !1,
|
|
1553
1560
|
insertFirst: !1
|
|
1554
|
-
}), e == null || e.addOverlay(
|
|
1561
|
+
}), e == null || e.addOverlay(F);
|
|
1555
1562
|
};
|
|
1556
|
-
let
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1559
|
-
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,
|
|
1560
1567
|
offset: [15, 0],
|
|
1561
1568
|
positioning: "center-left"
|
|
1562
|
-
}), e == null || e.addOverlay(
|
|
1563
|
-
},
|
|
1564
|
-
|
|
1569
|
+
}), e == null || e.addOverlay(G);
|
|
1570
|
+
}, W = () => {
|
|
1571
|
+
L == null || L.clear(), l = null, E(), q(), O();
|
|
1565
1572
|
};
|
|
1566
1573
|
return {
|
|
1567
|
-
open:
|
|
1574
|
+
open: a,
|
|
1568
1575
|
close: () => {
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
})),
|
|
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");
|
|
1572
1579
|
},
|
|
1573
|
-
reset:
|
|
1580
|
+
reset: W
|
|
1574
1581
|
};
|
|
1575
1582
|
}, PORT_LAYER_CLASS_NAME = "zh-map-port-layer", usePortManager = (e) => {
|
|
1576
|
-
const
|
|
1577
|
-
let l,
|
|
1578
|
-
const
|
|
1579
|
-
if (!(!
|
|
1580
|
-
if (
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1583
|
+
const s = e.getInstall();
|
|
1584
|
+
let l, n, a = null, o = null;
|
|
1585
|
+
const m = (f) => {
|
|
1586
|
+
if (!(!f || f.length === 0)) {
|
|
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);
|
|
1583
1590
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1591
|
+
f.forEach((y) => {
|
|
1592
|
+
L(y);
|
|
1586
1593
|
}), l || (l = new VectorLayer({
|
|
1587
1594
|
className: PORT_LAYER_CLASS_NAME,
|
|
1588
|
-
source:
|
|
1595
|
+
source: n,
|
|
1589
1596
|
zIndex: 100
|
|
1590
|
-
}),
|
|
1597
|
+
}), s.addLayer(l));
|
|
1591
1598
|
}
|
|
1592
|
-
},
|
|
1593
|
-
const
|
|
1594
|
-
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)]))
|
|
1595
1602
|
});
|
|
1596
|
-
|
|
1597
|
-
}, t = (
|
|
1598
|
-
const
|
|
1599
|
-
<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}"/>
|
|
1600
1607
|
<g clip-path="url(#clip0_10059_122082)">
|
|
1601
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"/>
|
|
1602
1609
|
</g>
|
|
@@ -1606,138 +1613,136 @@ const getShipDirectPath = (e) => {
|
|
|
1606
1613
|
</clipPath>
|
|
1607
1614
|
</defs>
|
|
1608
1615
|
</svg>
|
|
1609
|
-
`,
|
|
1616
|
+
`, T = () => `data:image/svg+xml;utf8,${encodeURIComponent(E(F ? "#FF5733" : "#3370FF"))}`;
|
|
1610
1617
|
return new Style({
|
|
1611
1618
|
text: new Text({
|
|
1612
|
-
text:
|
|
1619
|
+
text: f.shortName,
|
|
1613
1620
|
font: "12px sans-serif",
|
|
1614
1621
|
fill: new Fill({
|
|
1615
|
-
color:
|
|
1622
|
+
color: F ? "#ffffff" : "#000000"
|
|
1616
1623
|
}),
|
|
1617
1624
|
backgroundFill: new Fill({
|
|
1618
|
-
color:
|
|
1625
|
+
color: F ? "#FF5733" : "#FFFFFF"
|
|
1619
1626
|
}),
|
|
1620
1627
|
offsetY: 30
|
|
1621
1628
|
}),
|
|
1622
1629
|
image: new Icon({
|
|
1623
|
-
src:
|
|
1624
|
-
scale: 0.5 *
|
|
1625
|
-
})
|
|
1630
|
+
src: T(),
|
|
1631
|
+
scale: 0.5 * y / 10
|
|
1632
|
+
}),
|
|
1633
|
+
zIndex: F ? 110 : 100
|
|
1626
1634
|
});
|
|
1627
1635
|
}, r = () => {
|
|
1628
1636
|
if (a) {
|
|
1629
1637
|
console.log("清除非选中的港口");
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
|
|
1638
|
+
const f = a.get("portData").id;
|
|
1639
|
+
n.getFeatures().forEach((y) => {
|
|
1640
|
+
y.get("portData").id !== f && n.removeFeature(y);
|
|
1633
1641
|
});
|
|
1634
1642
|
} else
|
|
1635
|
-
console.log("清除所有港口"),
|
|
1636
|
-
},
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
}, m = (g) => {
|
|
1642
|
-
g ? (F(), V(g)) : f();
|
|
1643
|
-
}, F = () => {
|
|
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 = () => {
|
|
1644
1649
|
if (a) {
|
|
1645
|
-
const
|
|
1646
|
-
a.setStyle(t(
|
|
1650
|
+
const f = a == null ? void 0 : a.get("portData"), y = e.getZoom();
|
|
1651
|
+
a.setStyle(t(f, y, !1));
|
|
1647
1652
|
}
|
|
1648
|
-
},
|
|
1649
|
-
const
|
|
1650
|
-
o =
|
|
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));
|
|
1651
1656
|
};
|
|
1652
1657
|
return {
|
|
1653
|
-
render:
|
|
1658
|
+
render: m,
|
|
1654
1659
|
clear: r,
|
|
1655
|
-
selected:
|
|
1656
|
-
handlePortHover: (
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1660
|
+
selected: w,
|
|
1661
|
+
handlePortHover: (f) => {
|
|
1662
|
+
const y = s == null ? void 0 : s.getTargetElement();
|
|
1663
|
+
f && f.get("portData") && y && (y.style.cursor = "pointer");
|
|
1659
1664
|
}
|
|
1660
1665
|
};
|
|
1661
|
-
}, useEventManager = (e,
|
|
1662
|
-
const
|
|
1663
|
-
|
|
1666
|
+
}, useEventManager = (e, s, l, n, a, o) => {
|
|
1667
|
+
const m = e.getInstall();
|
|
1668
|
+
m.on("moveend", () => {
|
|
1664
1669
|
var t, r;
|
|
1665
|
-
const
|
|
1666
|
-
(r = (t =
|
|
1667
|
-
}),
|
|
1668
|
-
const t =
|
|
1669
|
-
|
|
1670
|
-
}),
|
|
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", () => {
|
|
1671
1676
|
console.log("movestart-----------------------");
|
|
1672
|
-
}),
|
|
1673
|
-
var
|
|
1677
|
+
}), m.on("click", debounce((L) => {
|
|
1678
|
+
var w, v, P;
|
|
1674
1679
|
if (console.log("1", o.getState()), o.getState()) return;
|
|
1675
|
-
const t =
|
|
1680
|
+
const t = m.getEventPixel(L.originalEvent), r = m.forEachFeatureAtPixel(
|
|
1676
1681
|
t,
|
|
1677
|
-
(
|
|
1678
|
-
if (
|
|
1679
|
-
return
|
|
1682
|
+
(O) => {
|
|
1683
|
+
if (O != null && O.get("shipData") || O != null && O.get("portData"))
|
|
1684
|
+
return O;
|
|
1680
1685
|
}
|
|
1681
1686
|
);
|
|
1682
1687
|
if (console.log("2", r), !!r) {
|
|
1683
|
-
if (
|
|
1684
|
-
|
|
1688
|
+
if (L.preventDefault(), L.stopPropagation(), r.get("shipData"))
|
|
1689
|
+
n.handleShipMapEvent(r, "click", (w = s.getProps()) == null ? void 0 : w.selectShip);
|
|
1685
1690
|
else if (r.get("portData")) {
|
|
1686
|
-
const
|
|
1687
|
-
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);
|
|
1688
1693
|
}
|
|
1689
1694
|
}
|
|
1690
1695
|
}, 150));
|
|
1691
1696
|
}, useMapController = () => {
|
|
1692
1697
|
const e = reactive([]);
|
|
1693
1698
|
return {
|
|
1694
|
-
createInstance: (
|
|
1699
|
+
createInstance: (n, a) => {
|
|
1695
1700
|
const o = useMapInitializer();
|
|
1696
|
-
o.initMap(
|
|
1697
|
-
const
|
|
1698
|
-
t.setProps(a),
|
|
1699
|
-
const r = useTrackManager(
|
|
1700
|
-
useEventManager(o, t, r,
|
|
1701
|
-
const
|
|
1702
|
-
const
|
|
1703
|
-
return [
|
|
1704
|
-
},
|
|
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 = {
|
|
1705
1710
|
id: Symbol("map-instance"),
|
|
1706
1711
|
innerMap: null,
|
|
1707
1712
|
map: o.getInstall(),
|
|
1708
1713
|
destroy: () => {
|
|
1709
|
-
e.splice(e.indexOf(
|
|
1714
|
+
e.splice(e.indexOf(E), 1);
|
|
1710
1715
|
},
|
|
1711
1716
|
methods: {
|
|
1712
1717
|
...o,
|
|
1713
|
-
layer:
|
|
1714
|
-
ship:
|
|
1718
|
+
layer: L,
|
|
1719
|
+
ship: v,
|
|
1715
1720
|
track: r,
|
|
1716
|
-
carTrack:
|
|
1721
|
+
carTrack: w,
|
|
1717
1722
|
port: {
|
|
1718
|
-
render:
|
|
1719
|
-
clear:
|
|
1720
|
-
selected:
|
|
1723
|
+
render: y.render,
|
|
1724
|
+
clear: y.clear,
|
|
1725
|
+
selected: y.selected
|
|
1721
1726
|
},
|
|
1722
|
-
position:
|
|
1723
|
-
drawLine:
|
|
1724
|
-
drawPolygon:
|
|
1727
|
+
position: P,
|
|
1728
|
+
drawLine: O,
|
|
1729
|
+
drawPolygon: f,
|
|
1725
1730
|
// 子模块
|
|
1726
1731
|
utils: {
|
|
1727
|
-
getCalculateExtent:
|
|
1732
|
+
getCalculateExtent: F,
|
|
1728
1733
|
convertSixHundredThousandToLatLng,
|
|
1729
1734
|
calculateCirclePoints
|
|
1730
1735
|
}
|
|
1731
1736
|
}
|
|
1732
1737
|
};
|
|
1733
|
-
return e.push(
|
|
1738
|
+
return e.push(E), E;
|
|
1734
1739
|
},
|
|
1735
|
-
destroyInstance: (
|
|
1736
|
-
const a = e.findIndex((o) => o.id ===
|
|
1740
|
+
destroyInstance: (n) => {
|
|
1741
|
+
const a = e.findIndex((o) => o.id === n);
|
|
1737
1742
|
a > -1 && (e[a].destroy(), e.splice(a, 1));
|
|
1738
1743
|
},
|
|
1739
1744
|
destroyAll: () => {
|
|
1740
|
-
e.forEach((
|
|
1745
|
+
e.forEach((n) => n.destroy()), e.splice(0, e.length);
|
|
1741
1746
|
},
|
|
1742
1747
|
getAllInstances: () => [...e]
|
|
1743
1748
|
};
|
|
@@ -1760,18 +1765,18 @@ const getShipDirectPath = (e) => {
|
|
|
1760
1765
|
selectPort: { type: Function, default: () => {
|
|
1761
1766
|
} }
|
|
1762
1767
|
},
|
|
1763
|
-
setup(e, { expose:
|
|
1764
|
-
const l = ref(),
|
|
1768
|
+
setup(e, { expose: s }) {
|
|
1769
|
+
const l = ref(), n = ref(), a = useMapController(), o = ref(), m = e, L = ref({
|
|
1765
1770
|
getInstall() {
|
|
1766
1771
|
}
|
|
1767
1772
|
});
|
|
1768
1773
|
return onMounted(() => {
|
|
1769
1774
|
var t;
|
|
1770
|
-
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);
|
|
1771
1776
|
}), onUnmounted(() => {
|
|
1772
1777
|
var t, r;
|
|
1773
1778
|
a.destroyInstance((t = o == null ? void 0 : o.value) == null ? void 0 : t.id), (r = o.value) == null || r.destroy();
|
|
1774
|
-
}),
|
|
1779
|
+
}), s({
|
|
1775
1780
|
getZoom: () => {
|
|
1776
1781
|
var t;
|
|
1777
1782
|
return (t = o.value) == null ? void 0 : t.methods.getZoom();
|
|
@@ -1789,16 +1794,16 @@ const getShipDirectPath = (e) => {
|
|
|
1789
1794
|
return (t = o.value) == null ? void 0 : t.methods.getView();
|
|
1790
1795
|
},
|
|
1791
1796
|
setCenter: (t, r) => {
|
|
1792
|
-
var
|
|
1793
|
-
return (
|
|
1797
|
+
var w;
|
|
1798
|
+
return (w = o.value) == null ? void 0 : w.methods.setCenter(t, r);
|
|
1794
1799
|
},
|
|
1795
1800
|
getSize: () => {
|
|
1796
1801
|
var t;
|
|
1797
1802
|
return (t = o.value) == null ? void 0 : t.methods.getSize();
|
|
1798
1803
|
},
|
|
1799
1804
|
getCenter: (t, r) => {
|
|
1800
|
-
var
|
|
1801
|
-
return (
|
|
1805
|
+
var w;
|
|
1806
|
+
return (w = o.value) == null ? void 0 : w.methods.getCenter();
|
|
1802
1807
|
},
|
|
1803
1808
|
layer: {
|
|
1804
1809
|
setGreenTileVisible: (t) => {
|
|
@@ -1883,9 +1888,9 @@ const getShipDirectPath = (e) => {
|
|
|
1883
1888
|
var r;
|
|
1884
1889
|
return (r = o.value) == null ? void 0 : r.methods.carTrack.setCenter(...t);
|
|
1885
1890
|
},
|
|
1886
|
-
closeTrack: (
|
|
1887
|
-
var
|
|
1888
|
-
return (
|
|
1891
|
+
closeTrack: () => {
|
|
1892
|
+
var t;
|
|
1893
|
+
return (t = o.value) == null ? void 0 : t.methods.carTrack.closeTrack();
|
|
1889
1894
|
},
|
|
1890
1895
|
playTrack: (...t) => {
|
|
1891
1896
|
var r;
|
|
@@ -1962,17 +1967,17 @@ const getShipDirectPath = (e) => {
|
|
|
1962
1967
|
},
|
|
1963
1968
|
// 子模块
|
|
1964
1969
|
utils: {
|
|
1965
|
-
getCalculateExtent: () => {
|
|
1966
|
-
var
|
|
1967
|
-
return (
|
|
1970
|
+
getCalculateExtent: (...t) => {
|
|
1971
|
+
var r;
|
|
1972
|
+
return (r = o.value) == null ? void 0 : r.methods.utils.getCalculateExtent(...t);
|
|
1968
1973
|
},
|
|
1969
|
-
convertSixHundredThousandToLatLng: () => {
|
|
1970
|
-
var
|
|
1971
|
-
return (
|
|
1974
|
+
convertSixHundredThousandToLatLng: (...t) => {
|
|
1975
|
+
var r;
|
|
1976
|
+
return (r = o.value) == null ? void 0 : r.methods.utils.convertSixHundredThousandToLatLng(...t);
|
|
1972
1977
|
},
|
|
1973
|
-
calculateCirclePoints: () => {
|
|
1974
|
-
var
|
|
1975
|
-
return (
|
|
1978
|
+
calculateCirclePoints: (t, r) => {
|
|
1979
|
+
var w;
|
|
1980
|
+
return (w = o.value) == null ? void 0 : w.methods.utils.calculateCirclePoints(t, r);
|
|
1976
1981
|
}
|
|
1977
1982
|
}
|
|
1978
1983
|
}), (t, r) => (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
@@ -1984,7 +1989,7 @@ const getShipDirectPath = (e) => {
|
|
|
1984
1989
|
}, null, 512),
|
|
1985
1990
|
createVNode(ScaleLine, {
|
|
1986
1991
|
ref_key: "scaleLineRef",
|
|
1987
|
-
ref:
|
|
1992
|
+
ref: n
|
|
1988
1993
|
}, null, 512),
|
|
1989
1994
|
createVNode(ZoomControl, {
|
|
1990
1995
|
ref: "zoomControlRef",
|
|
@@ -1992,7 +1997,7 @@ const getShipDirectPath = (e) => {
|
|
|
1992
1997
|
}, null, 8, ["map-instance"])
|
|
1993
1998
|
]));
|
|
1994
1999
|
}
|
|
1995
|
-
}), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
2000
|
+
}), Map$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-117d7b5a"]]), ZhMap = withInstall(Map$1);
|
|
1996
2001
|
export {
|
|
1997
2002
|
ZhMap as Z
|
|
1998
2003
|
};
|