qm-map-maplibre-gl 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -0
- package/dist/context/mapContext.d.ts +6 -0
- package/dist/index.d.ts +20 -0
- package/dist/maplibregl/MapWrapper.d.ts +56 -0
- package/dist/maplibregl/layer/BaseLayer.d.ts +11 -0
- package/dist/maplibregl/layer/LayerGroupWrapper.d.ts +18 -0
- package/dist/maplibregl/layer/LayerWrapper.d.ts +12 -0
- package/dist/maplibregl/typings/TEvent.d.ts +25 -0
- package/dist/maplibregl/typings/TLayerOptions.d.ts +29 -0
- package/dist/maplibregl/typings/TMapOptions.d.ts +4 -0
- package/dist/qm-map.css +2 -0
- package/dist/qm-map.es.js +1547 -0
- package/dist/qm-map.umd.js +28 -0
- package/dist/utils.d.ts +36 -0
- package/dist/widget/BaseWidget/index.d.ts +24 -0
- package/dist/widget/Draw/constant.d.ts +57 -0
- package/dist/widget/Draw/index.d.ts +17 -0
- package/dist/widget/LayerList/index.d.ts +5 -0
- package/dist/widget/LayerList/tree/index.d.ts +16 -0
- package/dist/widget/Legend/index.d.ts +5 -0
- package/dist/widget/MapWidget/index.d.ts +16 -0
- package/dist/widget/PopupPanel/index.d.ts +10 -0
- package/dist/widget/PopupWrapper/index.d.ts +16 -0
- package/dist/widget/Print/MapGenerator/CrosshairManager.d.ts +8 -0
- package/dist/widget/Print/MapGenerator/ImageExporter.d.ts +4 -0
- package/dist/widget/Print/MapGenerator/MapGenerator.d.ts +26 -0
- package/dist/widget/Print/MapGenerator/MarkersManager.d.ts +22 -0
- package/dist/widget/Print/MapGenerator/NorthIconManager.d.ts +44 -0
- package/dist/widget/Print/MapGenerator/PDFGenerator.d.ts +10 -0
- package/dist/widget/Print/MapGenerator/PrintableAreaManager.d.ts +12 -0
- package/dist/widget/Print/MapGenerator/SVGExporter.d.ts +3 -0
- package/dist/widget/Print/MapGenerator/types.d.ts +58 -0
- package/dist/widget/Print/index.d.ts +5 -0
- package/dist/widget/Swipe/MapCompare/index.d.ts +43 -0
- package/dist/widget/Swipe/MapCompare/sync-maps.d.ts +6 -0
- package/dist/widget/Swipe/index.d.ts +5 -0
- package/dist/widget/Swipe/modal/index.d.ts +31 -0
- package/package.json +63 -0
|
@@ -0,0 +1,1547 @@
|
|
|
1
|
+
import { createContext as e, memo as t, useCallback as n, useContext as r, useEffect as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
|
+
import { LngLatBounds as u, Map as d } from "maplibre-gl";
|
|
4
|
+
import { createPortal as f } from "react-dom";
|
|
5
|
+
import p from "@mapbox/mapbox-gl-draw";
|
|
6
|
+
import m from "@turf/area";
|
|
7
|
+
//#region src/gis/widget/BaseWidget/index.tsx
|
|
8
|
+
var h = {
|
|
9
|
+
Swipe: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNjcyMTk3MzE2MzYyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9Ijk2NTIiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTUzNy4xIDkxMC4yYzAgNy44IDcuOSAwIDAgMHogbS00OS4yIDBjLTcuOSAwIDAgNy44IDAgMHogbTQzOC40LTY1Mi40Yy0yLjctMi41LTYuNC00LTEwLjEtNC0yLjggMC01LjQgM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jIuMDhoNTgzLjIxMlY3Mi4yM0E3Mi4yMjYgNzIuMjI2IDAgMCAwIDczNS4xMDI2NCAwLjAwNXogbTE0Ny4xNTMgMjg5LjU4djc0LjkyN0gxNDUuODE2NjR2LTc0LjkyN0g3Mi4yMzk2NEE3My41NzYgNzMuNTc2IDAgMCAwIDAuMDEzNjQgMzY0LjUxMnY1MTMuMDFBNzIuOTAxIDcyLjkwMSAwIDAgMCA3MS41NjQ2NCA5NTEuMWg3NC4yNTJWNjU3LjQ2OEg4NzcuNTMwNjR2MjkyLjk1Nmg3NC4yNTJhNzMuNTc2IDczLjU3NiAwIDAgMCA3Mi4yMjYtNzIuOTAydi01MTMuMDFhNzQuOTI2IDc0LjkyNiAwIDAgMC03NC4yNTEtNzQuOTI3eiBtMCAyMjIuNzU1SDY1Ny40NzY2NHYtNzQuMjUySDg3Ny41MzA2NHoiIHAtaWQ9IjE2OTAiPjwvcGF0aD48L3N2Zz4="
|
|
13
|
+
}, g = t((e) => {
|
|
14
|
+
let { position: t, children: n, name: r, icon: i, width: a, height: s, openHandle: u } = e, [d, f] = o(!1), [p, m] = o(!1);
|
|
15
|
+
return /* @__PURE__ */ l("div", {
|
|
16
|
+
className: "maplibregl-control",
|
|
17
|
+
style: {
|
|
18
|
+
width: d ? a ?? 30 : 30,
|
|
19
|
+
height: d ? s ?? 30 : 30,
|
|
20
|
+
...t
|
|
21
|
+
},
|
|
22
|
+
children: [/* @__PURE__ */ l("div", {
|
|
23
|
+
className: "maplibregl-bar",
|
|
24
|
+
children: [/* @__PURE__ */ c("div", {
|
|
25
|
+
className: "maplibregl-bar-button",
|
|
26
|
+
onClick: () => {
|
|
27
|
+
u ? (u(!p), m(!p)) : f(!d);
|
|
28
|
+
},
|
|
29
|
+
title: r ?? "",
|
|
30
|
+
style: { backgroundImage: `url(${i})` }
|
|
31
|
+
}), r && /* @__PURE__ */ c("div", {
|
|
32
|
+
className: "maplibregl-bar-title",
|
|
33
|
+
children: r
|
|
34
|
+
})]
|
|
35
|
+
}), d && n]
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/gis/utils.ts
|
|
40
|
+
function _(e, t = /* @__PURE__ */ new WeakMap()) {
|
|
41
|
+
if (typeof e != "object" || !e) return e;
|
|
42
|
+
if (t.has(e)) return t.get(e);
|
|
43
|
+
let n;
|
|
44
|
+
return e instanceof Date ? n = new Date(e.getTime()) : e instanceof RegExp ? (n = new RegExp(e.source, e.flags), n.lastIndex = e.lastIndex) : e instanceof Map ? (n = /* @__PURE__ */ new Map(), t.set(e, n), e.forEach((e, r) => {
|
|
45
|
+
n.set(_(r, t), _(e, t));
|
|
46
|
+
})) : e instanceof Set ? (n = /* @__PURE__ */ new Set(), t.set(e, n), e.forEach((e) => {
|
|
47
|
+
n.add(_(e, t));
|
|
48
|
+
})) : Array.isArray(e) ? (n = [], t.set(e, n), e.forEach((e, r) => {
|
|
49
|
+
n[r] = _(e, t);
|
|
50
|
+
})) : (n = Object.create(Object.getPrototypeOf(e)), t.set(e, n), Reflect.ownKeys(e).forEach((r) => {
|
|
51
|
+
let i = e[r];
|
|
52
|
+
n[r] = _(i, t);
|
|
53
|
+
})), n;
|
|
54
|
+
}
|
|
55
|
+
var v = (e, t) => {
|
|
56
|
+
let n = null;
|
|
57
|
+
return (r) => {
|
|
58
|
+
n && clearTimeout(n), n = setTimeout(() => {
|
|
59
|
+
e(r);
|
|
60
|
+
}, t);
|
|
61
|
+
};
|
|
62
|
+
}, y = (e, t) => {
|
|
63
|
+
Array.isArray(t) && t.length > 0 && t.forEach((t) => {
|
|
64
|
+
e.push(t), t.layers instanceof Array && y(e, t.layers);
|
|
65
|
+
});
|
|
66
|
+
}, b = (e, t) => {
|
|
67
|
+
t[0] instanceof Array ? t.forEach((t) => {
|
|
68
|
+
t[0] instanceof Array ? b(e, t) : e.extend(t);
|
|
69
|
+
}) : e.extend(t);
|
|
70
|
+
}, x = (e) => {
|
|
71
|
+
let t = new u();
|
|
72
|
+
return b(t, e.geometry.coordinates), t;
|
|
73
|
+
}, S = class {
|
|
74
|
+
_options;
|
|
75
|
+
get options() {
|
|
76
|
+
return this._options;
|
|
77
|
+
}
|
|
78
|
+
constructor(e) {
|
|
79
|
+
this._options = e;
|
|
80
|
+
}
|
|
81
|
+
onAdd(e, t) {
|
|
82
|
+
if (this._options.isAdd === !1) {
|
|
83
|
+
this._options.isAdd = !1;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
t = e.findValidBeforeId(this._options.id), this.add(e, t), this._options.isAdd = !0;
|
|
87
|
+
}
|
|
88
|
+
onRemove(e, t) {
|
|
89
|
+
if (this._options.isAdd) return;
|
|
90
|
+
e.getLayer(this._options.id) && e.removeLayer(this._options.id);
|
|
91
|
+
let n = this._options.id + "-ds";
|
|
92
|
+
t && e.removeSource(n), this._options.isAdd = !1;
|
|
93
|
+
}
|
|
94
|
+
}, C = class extends S {
|
|
95
|
+
constructor(e) {
|
|
96
|
+
super(e), this._options = e;
|
|
97
|
+
}
|
|
98
|
+
add(e, t) {
|
|
99
|
+
let { id: n, source: r } = this._options, i = this._options.id + "-ds";
|
|
100
|
+
typeof r == "string" && (i = r), !e.getSource(i) && r && typeof r != "string" && e.addSource(i, r);
|
|
101
|
+
let a = e.getLayer(n), o = e.getSource(i);
|
|
102
|
+
if (!a && o) {
|
|
103
|
+
let n = {
|
|
104
|
+
...this._options,
|
|
105
|
+
source: i
|
|
106
|
+
};
|
|
107
|
+
e.addLayer(n, t);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, w = class e {
|
|
111
|
+
_options;
|
|
112
|
+
get options() {
|
|
113
|
+
return this._options;
|
|
114
|
+
}
|
|
115
|
+
_layers = [];
|
|
116
|
+
get layers() {
|
|
117
|
+
return this._layers;
|
|
118
|
+
}
|
|
119
|
+
constructor(t) {
|
|
120
|
+
this._options = t, t.layers.forEach((t) => {
|
|
121
|
+
let n;
|
|
122
|
+
n = "layers" in t ? new e(t) : new C(t), this._layers.push(n);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
onAdd(e, t) {
|
|
126
|
+
this._layers.forEach((n) => {
|
|
127
|
+
e.addLayerWrapper(n, t);
|
|
128
|
+
}), this.updateOptions();
|
|
129
|
+
}
|
|
130
|
+
onRemove(e) {
|
|
131
|
+
this._layers.forEach((t) => {
|
|
132
|
+
e.removeLayerWrapper(t, !1);
|
|
133
|
+
}), this.updateOptions();
|
|
134
|
+
}
|
|
135
|
+
updateOptions() {
|
|
136
|
+
let e = this._layers.findIndex((e) => e.options.isAdd) > -1;
|
|
137
|
+
this._options.isAdd = e;
|
|
138
|
+
}
|
|
139
|
+
}, T = {
|
|
140
|
+
MAPINITED: "MAPINITED",
|
|
141
|
+
MAPCLICKED: "MAPCLICKED",
|
|
142
|
+
MAPLAYERCHANGED: "MAPLAYERCHANGED",
|
|
143
|
+
MAPDESTRORY: "MAPDESTRORY"
|
|
144
|
+
}, E = class extends d {
|
|
145
|
+
_id;
|
|
146
|
+
get id() {
|
|
147
|
+
return this._id;
|
|
148
|
+
}
|
|
149
|
+
_options;
|
|
150
|
+
get options() {
|
|
151
|
+
return this._options;
|
|
152
|
+
}
|
|
153
|
+
_mapLayerSetting;
|
|
154
|
+
get mapLayerSetting() {
|
|
155
|
+
return this._mapLayerSetting;
|
|
156
|
+
}
|
|
157
|
+
_images = [];
|
|
158
|
+
get images() {
|
|
159
|
+
return this._images;
|
|
160
|
+
}
|
|
161
|
+
_layers = [];
|
|
162
|
+
get layers() {
|
|
163
|
+
return this._layers;
|
|
164
|
+
}
|
|
165
|
+
constructor(e) {
|
|
166
|
+
super(e), this._options = e, this._id = e.id, this._mapLayerSetting = [], this.fire(T.MAPINITED, { map: this });
|
|
167
|
+
}
|
|
168
|
+
getLayerWrapper(e, t) {
|
|
169
|
+
for (let n of e) if (n.options.id === t) return n;
|
|
170
|
+
else if ("layers" in n) {
|
|
171
|
+
let e = this.getLayerWrapper(n.layers, t);
|
|
172
|
+
if (e) return e;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
addLayerWrapper(e, t) {
|
|
176
|
+
e.onAdd(this, t), this.fire(T.MAPLAYERCHANGED, {
|
|
177
|
+
map: this,
|
|
178
|
+
layer: e
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
removeLayerWrapper(e, t) {
|
|
182
|
+
e.onRemove(this, t), this.fire(T.MAPLAYERCHANGED, {
|
|
183
|
+
map: this,
|
|
184
|
+
layer: e
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
load(e) {
|
|
188
|
+
this._mapLayerSetting = e, e.forEach((e) => {
|
|
189
|
+
let t;
|
|
190
|
+
t = "layers" in e ? new w(e) : new C(e), this.addLayerWrapper(t), this._layers.push(t);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
selectFeature(e) {
|
|
194
|
+
this.clearSelect();
|
|
195
|
+
let t = "location-ds";
|
|
196
|
+
this.addSource(t, {
|
|
197
|
+
type: "geojson",
|
|
198
|
+
data: e
|
|
199
|
+
}), this.addLayer({
|
|
200
|
+
id: "location-lyr",
|
|
201
|
+
type: "line",
|
|
202
|
+
paint: {
|
|
203
|
+
"line-color": "#00ffff",
|
|
204
|
+
"line-width": 2
|
|
205
|
+
},
|
|
206
|
+
source: t
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
clearSelect() {
|
|
210
|
+
let e = "location-lyr";
|
|
211
|
+
this.getLayer(e) && (this.removeLayer(e), this.removeSource("location-ds"));
|
|
212
|
+
}
|
|
213
|
+
findValidBeforeId(e) {
|
|
214
|
+
let t = this.getLayerList(), n = t.findIndex((t) => t.options.id === e);
|
|
215
|
+
if (n > -1) for (let e = n; e < t.length; e++) {
|
|
216
|
+
let n = this.getLayer(t[e].options.id);
|
|
217
|
+
if (n) return n.id;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
getLayerList() {
|
|
221
|
+
let e = [];
|
|
222
|
+
return y(e, this.layers), e;
|
|
223
|
+
}
|
|
224
|
+
destory() {
|
|
225
|
+
this.fire(T.MAPDESTRORY, { map: this }), this.remove();
|
|
226
|
+
}
|
|
227
|
+
}, D = e({ map: null }), O = () => {
|
|
228
|
+
let e = r(D);
|
|
229
|
+
if (!e) throw Error("只能在函数组件中使用");
|
|
230
|
+
return e;
|
|
231
|
+
};
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/gis/widget/MapWidget/index.tsx
|
|
234
|
+
function k(e) {
|
|
235
|
+
let { mapOptions: t, mapLayerSettting: n, children: r, onMapLoad: s, className: l } = e, u = a(null), [d, f] = o(!1), { current: p } = a({ map: null });
|
|
236
|
+
return i(() => {
|
|
237
|
+
let e = new E({
|
|
238
|
+
pitch: 0,
|
|
239
|
+
bearing: 0,
|
|
240
|
+
doubleClickZoom: !1,
|
|
241
|
+
attributionControl: !1,
|
|
242
|
+
renderWorldCopies: !1,
|
|
243
|
+
trackResize: !0,
|
|
244
|
+
...t,
|
|
245
|
+
container: u.current,
|
|
246
|
+
style: {
|
|
247
|
+
version: 8,
|
|
248
|
+
glyphs: "/font/{fontstack}/{range}.pbf",
|
|
249
|
+
sources: {},
|
|
250
|
+
layers: []
|
|
251
|
+
}
|
|
252
|
+
}), r = () => {
|
|
253
|
+
e.load(_(n)), f(!0), s?.(e), p && (p.map = e);
|
|
254
|
+
};
|
|
255
|
+
e.on("load", r), e.on("click", () => {
|
|
256
|
+
console.log("center:", e.getCenter(), "zoom:", e.getZoom());
|
|
257
|
+
});
|
|
258
|
+
let i = v(() => {
|
|
259
|
+
e.resize();
|
|
260
|
+
}, 10);
|
|
261
|
+
return new ResizeObserver(i).observe(u?.current), () => {
|
|
262
|
+
e.off("load", r);
|
|
263
|
+
};
|
|
264
|
+
}, []), /* @__PURE__ */ c("div", {
|
|
265
|
+
ref: u,
|
|
266
|
+
className: l ?? "map-wrapper",
|
|
267
|
+
id: "map-wrapper",
|
|
268
|
+
children: d && p && /* @__PURE__ */ c(D.Provider, {
|
|
269
|
+
value: p,
|
|
270
|
+
children: r
|
|
271
|
+
})
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
var A = t(k), j = (e, t) => {
|
|
275
|
+
for (let n of e) {
|
|
276
|
+
if (n.key === t) return n;
|
|
277
|
+
if (n.children) {
|
|
278
|
+
let e = j(n.children, t);
|
|
279
|
+
if (e) return e;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}, M = (e) => {
|
|
284
|
+
let t = [];
|
|
285
|
+
return e.children && e.children.length > 0 && e.children.forEach((e) => {
|
|
286
|
+
t.push(e.key), t.push(...M(e));
|
|
287
|
+
}), t;
|
|
288
|
+
}, N = (e) => !e.children || e.children.length === 0, ee = (e, t) => t.includes(e.key), te = (e, t) => {
|
|
289
|
+
if (N(e)) return !1;
|
|
290
|
+
let n = M(e);
|
|
291
|
+
if (n.length === 0) return !1;
|
|
292
|
+
let r = n.filter((e) => t.includes(e));
|
|
293
|
+
return r.length > 0 && r.length < n.length;
|
|
294
|
+
}, P = t((e) => {
|
|
295
|
+
let { node: t, level: n, checkedKeys: r, checkable: i, onCheck: a } = e, [s, u] = o(!0), d = !N(t), f = ee(t, r), p = te(t, r);
|
|
296
|
+
return /* @__PURE__ */ l("div", {
|
|
297
|
+
className: "qm-tree-node",
|
|
298
|
+
children: [/* @__PURE__ */ l("div", {
|
|
299
|
+
className: "qm-tree-node-content",
|
|
300
|
+
style: { paddingLeft: n * 18 },
|
|
301
|
+
children: [
|
|
302
|
+
/* @__PURE__ */ c("span", {
|
|
303
|
+
className: `qm-tree-switcher ${d ? "" : "qm-tree-switcher-noop"} ${s ? "qm-tree-switcher-expanded" : ""}`,
|
|
304
|
+
onClick: () => {
|
|
305
|
+
d && u(!s);
|
|
306
|
+
},
|
|
307
|
+
children: d && /* @__PURE__ */ c("svg", {
|
|
308
|
+
viewBox: "0 0 1024 1024",
|
|
309
|
+
width: "12",
|
|
310
|
+
height: "12",
|
|
311
|
+
fill: "currentColor",
|
|
312
|
+
children: /* @__PURE__ */ c("path", { d: "M715.8 493.5L435.6 213.3c-12.4-12.4-32.8-12.4-45.2 0s-12.4 32.8 0 45.2l245.8 245.8-245.8 245.8c-12.4 12.4-12.4 32.8 0 45.2 6.2 6.2 14.3 9.3 22.6 9.3s16.4-3.1 22.6-9.3l280.2-280.2c12.4-12.4 12.4-32.8 0-45.2z" })
|
|
313
|
+
})
|
|
314
|
+
}),
|
|
315
|
+
i && /* @__PURE__ */ c("span", {
|
|
316
|
+
className: `qm-tree-checkbox ${f ? "qm-tree-checkbox-checked" : ""} ${p ? "qm-tree-checkbox-indeterminate" : ""}`,
|
|
317
|
+
onClick: () => {
|
|
318
|
+
a(t.key);
|
|
319
|
+
},
|
|
320
|
+
children: /* @__PURE__ */ l("span", {
|
|
321
|
+
className: "qm-tree-checkbox-inner",
|
|
322
|
+
children: [f && /* @__PURE__ */ c("svg", {
|
|
323
|
+
viewBox: "0 0 1024 1024",
|
|
324
|
+
width: "10",
|
|
325
|
+
height: "10",
|
|
326
|
+
fill: "white",
|
|
327
|
+
children: /* @__PURE__ */ c("path", { d: "M912 224l-448 448-192-192-64 64 256 256 512-512z" })
|
|
328
|
+
}), p && /* @__PURE__ */ c("span", { className: "qm-tree-checkbox-indeterminate-icon" })]
|
|
329
|
+
})
|
|
330
|
+
}),
|
|
331
|
+
/* @__PURE__ */ c("span", {
|
|
332
|
+
className: "qm-tree-node-title",
|
|
333
|
+
title: typeof t.title == "string" ? t.title : "",
|
|
334
|
+
children: t.title
|
|
335
|
+
})
|
|
336
|
+
]
|
|
337
|
+
}), d && s && /* @__PURE__ */ c("div", {
|
|
338
|
+
className: "qm-tree-children",
|
|
339
|
+
children: t.children.map((e) => /* @__PURE__ */ c(P, {
|
|
340
|
+
node: e,
|
|
341
|
+
level: n + 1,
|
|
342
|
+
checkedKeys: r,
|
|
343
|
+
checkable: i,
|
|
344
|
+
onCheck: a
|
|
345
|
+
}, e.key))
|
|
346
|
+
})]
|
|
347
|
+
});
|
|
348
|
+
}), F = t((e) => {
|
|
349
|
+
let { treeData: t, checkable: r = !1, checkedKeys: i, onCheck: a, style: s } = e, [l, u] = o([]), d = i !== void 0, f = d ? i : l, p = (e, n) => {
|
|
350
|
+
let r = j(t, n);
|
|
351
|
+
if (!r) return e;
|
|
352
|
+
let i = e.includes(n), a;
|
|
353
|
+
if (i) {
|
|
354
|
+
let t = M(r), i = new Set([n, ...t]);
|
|
355
|
+
a = e.filter((e) => !i.has(e));
|
|
356
|
+
} else {
|
|
357
|
+
let t = M(r);
|
|
358
|
+
a = Array.from(new Set([
|
|
359
|
+
...e,
|
|
360
|
+
n,
|
|
361
|
+
...t
|
|
362
|
+
]));
|
|
363
|
+
}
|
|
364
|
+
return a;
|
|
365
|
+
}, m = n((e) => {
|
|
366
|
+
if (d) {
|
|
367
|
+
let t = p(f, e);
|
|
368
|
+
a?.(t);
|
|
369
|
+
} else u((t) => {
|
|
370
|
+
let n = p(t, e);
|
|
371
|
+
return a?.(n), n;
|
|
372
|
+
});
|
|
373
|
+
}, [
|
|
374
|
+
f,
|
|
375
|
+
t,
|
|
376
|
+
d,
|
|
377
|
+
a
|
|
378
|
+
]);
|
|
379
|
+
return /* @__PURE__ */ c("div", {
|
|
380
|
+
className: "qm-tree",
|
|
381
|
+
style: s,
|
|
382
|
+
children: t.map((e) => /* @__PURE__ */ c(P, {
|
|
383
|
+
node: e,
|
|
384
|
+
level: 0,
|
|
385
|
+
checkedKeys: f,
|
|
386
|
+
checkable: r,
|
|
387
|
+
onCheck: m
|
|
388
|
+
}, e.key))
|
|
389
|
+
});
|
|
390
|
+
}), I = t((e) => {
|
|
391
|
+
let [t, r] = o([]), { map: a } = O(), [s, l] = o([]), u = n((e, t) => {
|
|
392
|
+
let n, r = [];
|
|
393
|
+
return e.forEach((e) => {
|
|
394
|
+
n = void 0, n = "layers" in e && e.options.type === "logicGroup" ? {
|
|
395
|
+
title: e.options.name,
|
|
396
|
+
key: e.options.id,
|
|
397
|
+
selectable: !1,
|
|
398
|
+
children: u(e.layers, t)
|
|
399
|
+
} : {
|
|
400
|
+
title: e.options.name,
|
|
401
|
+
key: e.options.id,
|
|
402
|
+
selectable: !1
|
|
403
|
+
}, n && r.push(n), e.options.isAdd && e.options.type !== "logicGroup" && t.push(e.options.id);
|
|
404
|
+
}), r;
|
|
405
|
+
}, []), d = (e) => {
|
|
406
|
+
r(e);
|
|
407
|
+
let n = new Set([...t, ...e]), i = new Set([...n].filter((e) => !t.includes(e))), o = new Set([...n].filter((t) => !e.includes(t)));
|
|
408
|
+
i.forEach((e) => {
|
|
409
|
+
let t = a?.getLayerWrapper(a.layers, e);
|
|
410
|
+
t && "layers" in t ? (t.layers.forEach((e) => {
|
|
411
|
+
e.options.isAdd = !0;
|
|
412
|
+
}), a?.addLayerWrapper(t)) : t && (t.options.isAdd = !0, a?.addLayerWrapper(t));
|
|
413
|
+
}), o.forEach((e) => {
|
|
414
|
+
let t = a?.getLayerWrapper(a.layers, e);
|
|
415
|
+
t && "layers" in t ? (t.layers.forEach((e) => {
|
|
416
|
+
e.options.isAdd = !1;
|
|
417
|
+
}), a?.removeLayerWrapper(t)) : t && (t.options.isAdd = !1, a?.removeLayerWrapper(t));
|
|
418
|
+
}), a.layers.forEach((e) => {
|
|
419
|
+
f(e);
|
|
420
|
+
});
|
|
421
|
+
}, f = (e) => {
|
|
422
|
+
"layers" in e && e.layers.findIndex((e) => e.options.type === "logicGroup") > -1 ? e.layers.forEach((e) => {
|
|
423
|
+
f(e);
|
|
424
|
+
}) : "layers" in e && e.options.type === "logicGroup" && (e.layers.findIndex((e) => e.options.isAdd) === -1 ? e.options.isAdd = !1 : e.options.isAdd = !0);
|
|
425
|
+
};
|
|
426
|
+
return i(() => {
|
|
427
|
+
let e = () => {
|
|
428
|
+
let e = [];
|
|
429
|
+
l(a ? u(a.layers, e) : []), r(e);
|
|
430
|
+
}, t = v(() => {
|
|
431
|
+
e();
|
|
432
|
+
}, 300);
|
|
433
|
+
return a?.on(T.MAPLAYERCHANGED, t), e(), () => {
|
|
434
|
+
a?.off(T.MAPLAYERCHANGED, t);
|
|
435
|
+
};
|
|
436
|
+
}, []), /* @__PURE__ */ c(g, {
|
|
437
|
+
name: "图层控制",
|
|
438
|
+
position: e.position,
|
|
439
|
+
icon: h.LayerList,
|
|
440
|
+
width: 200,
|
|
441
|
+
height: t.length * 28 < 280 ? 280 : t.length * 28,
|
|
442
|
+
children: /* @__PURE__ */ c(F, {
|
|
443
|
+
checkable: !0,
|
|
444
|
+
checkedKeys: t,
|
|
445
|
+
onCheck: (e) => d(e),
|
|
446
|
+
treeData: s,
|
|
447
|
+
style: {
|
|
448
|
+
fontSize: 12,
|
|
449
|
+
maxHeight: 400,
|
|
450
|
+
overflowX: "hidden",
|
|
451
|
+
overflowY: "auto"
|
|
452
|
+
}
|
|
453
|
+
})
|
|
454
|
+
});
|
|
455
|
+
}), L = t((e) => {
|
|
456
|
+
let { map: t } = O(), [r, a] = o(), [s, u] = o(0), d = n((e, n, r) => {
|
|
457
|
+
let i;
|
|
458
|
+
e.forEach((e) => {
|
|
459
|
+
if (i = void 0, "layers" in e && !e.options.legend) d(e.layers, n, r);
|
|
460
|
+
else if (e.options.legend && (e.options.isAdd || "layers" in e && e.layers.filter((e) => e.options.isAdd).length)) {
|
|
461
|
+
let { title: r, items: a } = e.options.legend;
|
|
462
|
+
if (a) i = /* @__PURE__ */ l("div", {
|
|
463
|
+
className: "maplibregl-legend-group",
|
|
464
|
+
children: [/* @__PURE__ */ c("div", {
|
|
465
|
+
className: "maplibregl-legend-tilte",
|
|
466
|
+
children: r || e.options.name
|
|
467
|
+
}), a?.map((e) => {
|
|
468
|
+
n.push(26);
|
|
469
|
+
let r = t?.images.find((t) => t.id === e.imageId);
|
|
470
|
+
return /* @__PURE__ */ l("div", {
|
|
471
|
+
className: "maplibregl-legend-item",
|
|
472
|
+
children: [r ? /* @__PURE__ */ c("img", {
|
|
473
|
+
src: r.data,
|
|
474
|
+
alt: "",
|
|
475
|
+
className: "maplibregl-legend-item-img"
|
|
476
|
+
}) : /* @__PURE__ */ c("div", {
|
|
477
|
+
className: "maplibregl-legend-item-geo",
|
|
478
|
+
style: e.style
|
|
479
|
+
}), /* @__PURE__ */ c("div", {
|
|
480
|
+
className: "maplibregl-legend-item-text",
|
|
481
|
+
children: e.text
|
|
482
|
+
})]
|
|
483
|
+
}, e.text);
|
|
484
|
+
})]
|
|
485
|
+
}, e.options.id), n.push(50);
|
|
486
|
+
else {
|
|
487
|
+
let { style: a, imageId: o, text: s } = e.options.legend, u = t?.images.find((e) => e.id === o);
|
|
488
|
+
n.push(26), i = /* @__PURE__ */ l("div", {
|
|
489
|
+
className: "maplibregl-legend-item",
|
|
490
|
+
children: [u ? /* @__PURE__ */ c("img", {
|
|
491
|
+
src: u.data,
|
|
492
|
+
alt: "",
|
|
493
|
+
className: "maplibregl-legend-item-img"
|
|
494
|
+
}) : /* @__PURE__ */ c("div", {
|
|
495
|
+
className: "maplibregl-legend-item-geo",
|
|
496
|
+
style: a
|
|
497
|
+
}), /* @__PURE__ */ c("div", {
|
|
498
|
+
className: "maplibregl-legend-item-text",
|
|
499
|
+
children: s || e.options.name
|
|
500
|
+
})]
|
|
501
|
+
}, s || r || e.options.id);
|
|
502
|
+
}
|
|
503
|
+
} else i = void 0;
|
|
504
|
+
i && r.push(i);
|
|
505
|
+
});
|
|
506
|
+
}, []);
|
|
507
|
+
return i(() => {
|
|
508
|
+
let e = () => {
|
|
509
|
+
let e = [], n = [];
|
|
510
|
+
d(t.layers, e, n), a(n), u(e.reduce((e, t) => e + t, 0) + 40);
|
|
511
|
+
}, n = v(() => {
|
|
512
|
+
e();
|
|
513
|
+
}, 200);
|
|
514
|
+
return t?.on(T.MAPLAYERCHANGED, n), e(), () => {
|
|
515
|
+
t?.off(T.MAPLAYERCHANGED, n);
|
|
516
|
+
};
|
|
517
|
+
}, []), /* @__PURE__ */ c(g, {
|
|
518
|
+
name: "图例",
|
|
519
|
+
position: e.position,
|
|
520
|
+
icon: h.Legend,
|
|
521
|
+
width: 180,
|
|
522
|
+
height: s,
|
|
523
|
+
children: /* @__PURE__ */ c("div", {
|
|
524
|
+
className: "maplibregl-legend",
|
|
525
|
+
children: r
|
|
526
|
+
})
|
|
527
|
+
});
|
|
528
|
+
}), R = {
|
|
529
|
+
JPEG: "jpg",
|
|
530
|
+
PNG: "png",
|
|
531
|
+
PDF: "pdf",
|
|
532
|
+
SVG: "svg"
|
|
533
|
+
}, z = { mm: "mm" }, B = {
|
|
534
|
+
A2: [594, 420],
|
|
535
|
+
A3: [420, 297],
|
|
536
|
+
A4: [297, 210],
|
|
537
|
+
A5: [210, 148],
|
|
538
|
+
A6: [148, 105],
|
|
539
|
+
B2: [707, 500],
|
|
540
|
+
B3: [500, 353],
|
|
541
|
+
B4: [353, 250],
|
|
542
|
+
B5: [250, 176],
|
|
543
|
+
B6: [176, 125],
|
|
544
|
+
Letter: [279, 216]
|
|
545
|
+
}, V = {
|
|
546
|
+
横向: "landscape",
|
|
547
|
+
纵向: "portrait"
|
|
548
|
+
}, H = {
|
|
549
|
+
72: 72,
|
|
550
|
+
96: 96,
|
|
551
|
+
200: 200,
|
|
552
|
+
300: 300,
|
|
553
|
+
400: 400
|
|
554
|
+
}, U = class {
|
|
555
|
+
map;
|
|
556
|
+
svgCanvas;
|
|
557
|
+
constructor(e) {
|
|
558
|
+
this.map = e, this.svgCanvas = null;
|
|
559
|
+
}
|
|
560
|
+
create() {
|
|
561
|
+
if (!this.map) return;
|
|
562
|
+
let e = this.map.getCanvasContainer(), t = this.map.getCanvas().clientWidth, n = this.map.getCanvas().clientHeight, r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
563
|
+
r.setAttribute("class", "qm-print-crosshair"), r.style.cssText = `position:absolute;top:0;left:0;width:${t}px;height:${n}px;pointer-events:none;`;
|
|
564
|
+
let i = t / 2, a = n / 2, o = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
565
|
+
o.setAttribute("x1", `${i}`), o.setAttribute("y1", "0"), o.setAttribute("x2", `${i}`), o.setAttribute("y2", `${n}`), o.setAttribute("stroke", "#dddddd"), o.setAttribute("stroke-width", "2"), o.setAttribute("stroke-dasharray", "5,5");
|
|
566
|
+
let s = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
567
|
+
s.setAttribute("x1", "0"), s.setAttribute("y1", `${a}`), s.setAttribute("x2", `${t}`), s.setAttribute("y2", `${a}`), s.setAttribute("stroke", "#dddddd"), s.setAttribute("stroke-width", "2"), s.setAttribute("stroke-dasharray", "5,5"), r.appendChild(o), r.appendChild(s), e.appendChild(r), this.svgCanvas = r;
|
|
568
|
+
}
|
|
569
|
+
destroy() {
|
|
570
|
+
this.svgCanvas?.remove(), this.svgCanvas = null, this.map = null;
|
|
571
|
+
}
|
|
572
|
+
}, W = class {
|
|
573
|
+
map;
|
|
574
|
+
svgCanvas;
|
|
575
|
+
path;
|
|
576
|
+
constructor(e) {
|
|
577
|
+
this.map = e, this.svgCanvas = null, this.path = null;
|
|
578
|
+
}
|
|
579
|
+
updateArea(e, t, n = z.mm) {
|
|
580
|
+
if (!this.map || !this.svgCanvas) return;
|
|
581
|
+
let r = this.map.getCanvas().clientWidth, i = this.map.getCanvas().clientHeight, a = this.toPixels(e, n), o = this.toPixels(t, n), s = r / a, c = i / o, l = Math.min(s, c, 1), u = a * l, d = o * l, f = (r - u) / 2, p = (i - d) / 2, m = f + u, h = p + d, g = `M 0 0 L ${r} 0 L ${r} ${i} L 0 ${i} Z M ${f} ${p} L ${m} ${p} L ${m} ${h} L ${f} ${h} Z`;
|
|
582
|
+
this.path?.setAttribute("d", g);
|
|
583
|
+
}
|
|
584
|
+
create() {
|
|
585
|
+
if (!this.map) return;
|
|
586
|
+
let e = this.map.getCanvasContainer(), t = this.map.getCanvas().clientWidth, n = this.map.getCanvas().clientHeight, r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
587
|
+
r.style.cssText = `position:absolute;top:0;left:0;width:${t}px;height:${n}px;pointer-events:none;`;
|
|
588
|
+
let i = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
589
|
+
i.setAttribute("fill", "#888888"), i.setAttribute("fill-opacity", "0.5"), i.setAttribute("stroke-width", "0"), i.setAttribute("fill-rule", "evenodd"), r.appendChild(i), e.appendChild(r), this.svgCanvas = r, this.path = i;
|
|
590
|
+
}
|
|
591
|
+
destroy() {
|
|
592
|
+
this.svgCanvas?.remove(), this.svgCanvas = null, this.path = null, this.map = null;
|
|
593
|
+
}
|
|
594
|
+
toPixels(e, t) {
|
|
595
|
+
return t === z.mm ? 96 / 25.4 * e : 96 * e;
|
|
596
|
+
}
|
|
597
|
+
}, G = class {
|
|
598
|
+
toPNG(e, t) {
|
|
599
|
+
e.toBlob((e) => {
|
|
600
|
+
if (e) {
|
|
601
|
+
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
602
|
+
r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
toJPEG(e, t, n = .85) {
|
|
607
|
+
let r = document.createElement("canvas");
|
|
608
|
+
r.width = e.width, r.height = e.height;
|
|
609
|
+
let i = r.getContext("2d");
|
|
610
|
+
i && (i.fillStyle = "#FFFFFF", i.fillRect(0, 0, r.width, r.height), i.drawImage(e, 0, 0));
|
|
611
|
+
let a = r.toDataURL("image/jpeg", Math.max(0, Math.min(1, n))), o = document.createElement("a");
|
|
612
|
+
o.href = a, o.download = t, o.click();
|
|
613
|
+
}
|
|
614
|
+
}, K = "<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-hidden=\"true\" role=\"img\" class=\"iconify iconify--gis\" preserveAspectRatio=\"xMidYMid meet\"><path d=\"M47.655 1.634l-35 95c-.828 2.24 1.659 4.255 3.68 2.98l33.667-21.228l33.666 21.228c2.02 1.271 4.503-.74 3.678-2.98l-35-95C51.907.514 51.163.006 50 .008c-1.163.001-1.99.65-2.345 1.626zm-.155 14.88v57.54L19.89 91.461z\" fill=\"none\" stroke=\"white\" stroke-width=\"1.5\"/><path d=\"M47.655 1.634l-35 95c-.828 2.24 1.659 4.255 3.68 2.98l33.667-21.228l33.666 21.228c2.02 1.271 4.503-.74 3.678-2.98l-35-95C51.907.514 51.163.006 50 .008c-1.163.001-1.99.65-2.345 1.626zm-.155 14.88v57.54L19.89 91.461z\" fill=\"#000000\" fill-rule=\"evenodd\"></path></svg>", q = {
|
|
615
|
+
image: K,
|
|
616
|
+
imageName: "gl-export-north-icon",
|
|
617
|
+
imageSizeFraction: .05,
|
|
618
|
+
visibility: "visible",
|
|
619
|
+
position: "top-right"
|
|
620
|
+
}, J = class {
|
|
621
|
+
options;
|
|
622
|
+
constructor(e) {
|
|
623
|
+
this.options = {
|
|
624
|
+
...q,
|
|
625
|
+
...e,
|
|
626
|
+
image: e?.image ?? K
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
async addToMap(e, t, n) {
|
|
630
|
+
let r = this.options.visibility ?? "visible";
|
|
631
|
+
e.getZoom() < 2 && t > n && (r = "none"), await this.addNorthIconImage(e);
|
|
632
|
+
let i = this.getIconWidth(e, this.options.imageSizeFraction ?? .08) * .8, a = this.getElementPosition(e, this.options.position ?? "top-right", i), o = e.unproject(a), s = this.options.imageName ?? "gl-export-north-icon";
|
|
633
|
+
e.addSource(s, {
|
|
634
|
+
type: "geojson",
|
|
635
|
+
data: {
|
|
636
|
+
type: "Feature",
|
|
637
|
+
geometry: {
|
|
638
|
+
type: "Point",
|
|
639
|
+
coordinates: [o.lng, o.lat]
|
|
640
|
+
},
|
|
641
|
+
properties: {}
|
|
642
|
+
}
|
|
643
|
+
}), e.addLayer({
|
|
644
|
+
id: s,
|
|
645
|
+
source: s,
|
|
646
|
+
type: "symbol",
|
|
647
|
+
layout: {
|
|
648
|
+
"icon-image": s,
|
|
649
|
+
"icon-size": 1,
|
|
650
|
+
"icon-rotate": e.getBearing() * -1,
|
|
651
|
+
"icon-allow-overlap": !0,
|
|
652
|
+
"icon-ignore-placement": !0,
|
|
653
|
+
visibility: r
|
|
654
|
+
},
|
|
655
|
+
paint: {}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
async addNorthIconImage(e) {
|
|
659
|
+
let t = this.getIconWidth(e, this.options.imageSizeFraction ?? .08);
|
|
660
|
+
return new Promise((n) => {
|
|
661
|
+
let r = new Image(t, t);
|
|
662
|
+
r.onload = () => {
|
|
663
|
+
this.options.imageName && e.addImage(this.options.imageName, r), n();
|
|
664
|
+
};
|
|
665
|
+
function i(e) {
|
|
666
|
+
return "data:image/svg+xml;charset=utf-8," + encodeURIComponent(e);
|
|
667
|
+
}
|
|
668
|
+
this.options.image && (r.src = i(this.options.image));
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
getIconWidth(e, t) {
|
|
672
|
+
let n = e.getContainer(), r = parseInt(n.style.width.replace("px", ""));
|
|
673
|
+
return parseInt(`${r * t}`);
|
|
674
|
+
}
|
|
675
|
+
getElementPosition(e, t, n = 0) {
|
|
676
|
+
let r = e.getContainer(), i = 0, a = 0;
|
|
677
|
+
switch (t) {
|
|
678
|
+
case "top-left":
|
|
679
|
+
i = 0 + n, a = 0 + n;
|
|
680
|
+
break;
|
|
681
|
+
case "top-right":
|
|
682
|
+
i = parseInt(r.style.width.replace("px", "")) - n, a = 0 + n;
|
|
683
|
+
break;
|
|
684
|
+
case "bottom-left":
|
|
685
|
+
i = 0 + n, a = parseInt(r.style.height.replace("px", "")) - n;
|
|
686
|
+
break;
|
|
687
|
+
case "bottom-right":
|
|
688
|
+
i = parseInt(r.style.width.replace("px", "")) - n, a = parseInt(r.style.height.replace("px", "")) - n;
|
|
689
|
+
break;
|
|
690
|
+
default: break;
|
|
691
|
+
}
|
|
692
|
+
return [i, a];
|
|
693
|
+
}
|
|
694
|
+
updateOptions(e) {
|
|
695
|
+
this.options = {
|
|
696
|
+
...this.options,
|
|
697
|
+
...e,
|
|
698
|
+
image: e.image ?? this.options.image
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
}, Y = {
|
|
702
|
+
"circle-radius": 8,
|
|
703
|
+
"circle-color": "red",
|
|
704
|
+
"circle-stroke-width": 1,
|
|
705
|
+
"circle-stroke-color": "black"
|
|
706
|
+
}, X = "maplibregl-marker", ne = class {
|
|
707
|
+
sourceMap;
|
|
708
|
+
renderMap;
|
|
709
|
+
markerClassName;
|
|
710
|
+
markerCirclePaint;
|
|
711
|
+
constructor(e, t, n) {
|
|
712
|
+
this.sourceMap = e, this.renderMap = t, this.markerClassName = n?.markerClassName ?? X, this.markerCirclePaint = {
|
|
713
|
+
...Y,
|
|
714
|
+
...n?.markerCirclePaint
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
getMarkers() {
|
|
718
|
+
return this.sourceMap.getCanvasContainer().getElementsByClassName(this.markerClassName);
|
|
719
|
+
}
|
|
720
|
+
renderMarkers() {
|
|
721
|
+
let e = this.getMarkers(), t = e.length;
|
|
722
|
+
if (t === 0) return !1;
|
|
723
|
+
for (let n = 0; n < t; n++) {
|
|
724
|
+
let t = e.item(n);
|
|
725
|
+
if (!t) continue;
|
|
726
|
+
let r = t.getAttribute("style");
|
|
727
|
+
if (!r) continue;
|
|
728
|
+
let i = r.match(/translate\(([^,]+)px,\s*([^,]+)px\)/);
|
|
729
|
+
if (!i) continue;
|
|
730
|
+
let a = parseInt(i[1]), o = parseInt(i[2]), s = this.sourceMap.unproject([a, o]), c = `print-marker-${n}`;
|
|
731
|
+
this.renderMap.addSource(c, {
|
|
732
|
+
type: "geojson",
|
|
733
|
+
data: {
|
|
734
|
+
type: "Point",
|
|
735
|
+
coordinates: [s.lng, s.lat]
|
|
736
|
+
}
|
|
737
|
+
}), this.renderMap.addLayer({
|
|
738
|
+
id: c,
|
|
739
|
+
source: c,
|
|
740
|
+
type: "circle",
|
|
741
|
+
paint: this.markerCirclePaint
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
return !0;
|
|
745
|
+
}
|
|
746
|
+
}, re = class {
|
|
747
|
+
width;
|
|
748
|
+
height;
|
|
749
|
+
unit;
|
|
750
|
+
constructor(e, t, n) {
|
|
751
|
+
this.width = e, this.height = t, this.unit = n;
|
|
752
|
+
}
|
|
753
|
+
generate(e, t) {
|
|
754
|
+
let n = this.buildPDF(e), r = new Blob([n], { type: "application/pdf" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
755
|
+
a.href = i, a.download = t, a.click(), URL.revokeObjectURL(i);
|
|
756
|
+
}
|
|
757
|
+
buildPDF(e) {
|
|
758
|
+
let t = this.unit === z.mm ? this.width * 2.83465 : this.width * 72, n = this.unit === z.mm ? this.height * 2.83465 : this.height * 72, r = document.createElement("canvas");
|
|
759
|
+
r.width = e.width, r.height = e.height;
|
|
760
|
+
let i = r.getContext("2d");
|
|
761
|
+
i && (i.fillStyle = "#FFFFFF", i.fillRect(0, 0, r.width, r.height), i.drawImage(e, 0, 0));
|
|
762
|
+
let a = r.toDataURL("image/jpeg", .92).split(",")[1], o = atob(a), s = new Uint8Array(o.length);
|
|
763
|
+
for (let e = 0; e < o.length; e++) s[e] = o.charCodeAt(e);
|
|
764
|
+
return this.createPDFStructure(t, n, e.width, e.height, s);
|
|
765
|
+
}
|
|
766
|
+
createPDFStructure(e, t, n, r, i) {
|
|
767
|
+
let a = Math.round(e), o = Math.round(t), s = i.length, c = 0, l = c;
|
|
768
|
+
c += 49;
|
|
769
|
+
let u = c;
|
|
770
|
+
c += 57;
|
|
771
|
+
let d = `3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${a} ${o}] /Contents 4 0 R /Resources << /XObject << /Im0 5 0 R >> >> >>\nendobj\n`, f = c;
|
|
772
|
+
c += d.length;
|
|
773
|
+
let p = `q\n${a} 0 0 ${o} 0 0 cm\n/Im0 Do\nQ\n`, m = `4 0 obj\n<< /Length ${p.length} >>\nstream\n${p}endstream\nendobj\n`, h = c;
|
|
774
|
+
c += m.length;
|
|
775
|
+
let g = `5 0 obj\n<< /Type /XObject /Subtype /Image /Width ${n} /Height ${r} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${s} >>\nstream\n`, _ = c;
|
|
776
|
+
c += g.length + s + 18;
|
|
777
|
+
let v = c, y = `xref\n0 6\n0000000000 65535 f \n${String(l).padStart(10, "0")} 00000 n \n${String(u).padStart(10, "0")} 00000 n \n${String(f).padStart(10, "0")} 00000 n \n${String(h).padStart(10, "0")} 00000 n \n${String(_).padStart(10, "0")} 00000 n \n`, b = `trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${v}\n%%EOF`, x = new TextEncoder(), S = [
|
|
778
|
+
x.encode("%PDF-1.4\n"),
|
|
779
|
+
x.encode("1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n"),
|
|
780
|
+
x.encode("2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n"),
|
|
781
|
+
x.encode(d),
|
|
782
|
+
x.encode(m),
|
|
783
|
+
x.encode(g),
|
|
784
|
+
i,
|
|
785
|
+
x.encode("\nendstream\nendobj\n"),
|
|
786
|
+
x.encode(y),
|
|
787
|
+
x.encode(b)
|
|
788
|
+
], C = S.reduce((e, t) => e + t.length, 0), w = new Uint8Array(C), T = 0;
|
|
789
|
+
for (let e of S) w.set(e, T), T += e.length;
|
|
790
|
+
return w.buffer;
|
|
791
|
+
}
|
|
792
|
+
}, ie = class {
|
|
793
|
+
toSVG(e, t, n, r, i, a) {
|
|
794
|
+
let o = e.toDataURL("image/png"), s = i === "mm" ? a / 25.4 : a, c = s * n, l = s * r, u = `
|
|
795
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
796
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
797
|
+
version="1.1"
|
|
798
|
+
width="${c}"
|
|
799
|
+
height="${l}"
|
|
800
|
+
viewBox="0 0 ${c} ${l}"
|
|
801
|
+
xml:space="preserve">
|
|
802
|
+
<image xlink:href="${o}" width="${c}" height="${l}"></image>
|
|
803
|
+
</svg>`, d = `data:application/xml,${encodeURIComponent(u)}`, f = document.createElement("a");
|
|
804
|
+
f.href = d, f.download = t, f.click();
|
|
805
|
+
}
|
|
806
|
+
}, ae = class {
|
|
807
|
+
map;
|
|
808
|
+
width;
|
|
809
|
+
height;
|
|
810
|
+
dpi;
|
|
811
|
+
format;
|
|
812
|
+
unit;
|
|
813
|
+
jpegQuality;
|
|
814
|
+
northIcon;
|
|
815
|
+
northIconOptions;
|
|
816
|
+
markerOptions;
|
|
817
|
+
constructor(e, t, n, r, i = z.mm, a) {
|
|
818
|
+
this.map = e, this.width = t[0], this.height = t[1], this.dpi = n, this.format = r, this.unit = i, this.jpegQuality = a?.jpegQuality ?? .85, this.northIcon = a?.northIcon ?? !1, this.northIconOptions = a?.northIconOptions, this.markerOptions = a?.markerOptions ?? {};
|
|
819
|
+
}
|
|
820
|
+
generate(e) {
|
|
821
|
+
this.showLoading();
|
|
822
|
+
let t = window.devicePixelRatio;
|
|
823
|
+
Object.defineProperty(window, "devicePixelRatio", { get: () => this.dpi / 96 });
|
|
824
|
+
let n = document.createElement("div");
|
|
825
|
+
n.className = "qm-print-hidden-container", n.style.cssText = "\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n visibility: hidden;\n pointer-events: none;\n ";
|
|
826
|
+
let r = document.createElement("div"), i = this.toPixels(this.width), a = this.toPixels(this.height);
|
|
827
|
+
r.style.cssText = `position:absolute;top:0;left:0;width:${i}px;height:${a}px;`, n.appendChild(r), document.body.appendChild(n);
|
|
828
|
+
let o = new d({
|
|
829
|
+
container: r,
|
|
830
|
+
style: this.map.getStyle(),
|
|
831
|
+
center: this.map.getCenter(),
|
|
832
|
+
zoom: this.map.getZoom(),
|
|
833
|
+
bearing: this.map.getBearing(),
|
|
834
|
+
pitch: this.map.getPitch(),
|
|
835
|
+
interactive: !1,
|
|
836
|
+
fadeDuration: 0,
|
|
837
|
+
attributionControl: !1,
|
|
838
|
+
canvasContextAttributes: { preserveDrawingBuffer: !0 },
|
|
839
|
+
transformRequest: this.map._requestManager._transformRequestFn
|
|
840
|
+
});
|
|
841
|
+
this.map.getTerrain() && (o.setMaxPitch(85), o.setPitch(this.map.getPitch()));
|
|
842
|
+
let s = this.map.style?.imageManager?.images || [];
|
|
843
|
+
Object.keys(s).forEach((e) => {
|
|
844
|
+
o.hasImage(e) || o.addImage(e, s[e].data);
|
|
845
|
+
});
|
|
846
|
+
let c = () => new Promise((e) => {
|
|
847
|
+
if (!o.isStyleLoaded() || !o.areTilesLoaded()) {
|
|
848
|
+
setTimeout(c, 100);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
setTimeout(e, 200);
|
|
852
|
+
});
|
|
853
|
+
o.once("idle", async () => {
|
|
854
|
+
await c(), this.northIcon && (await new J(this.northIconOptions).addToMap(o, this.width, this.height), await new Promise((e) => {
|
|
855
|
+
o.once("idle", () => {
|
|
856
|
+
setTimeout(e, 200);
|
|
857
|
+
});
|
|
858
|
+
})), new ne(this.map, o, this.markerOptions).renderMarkers() && await new Promise((e) => {
|
|
859
|
+
o.once("idle", () => {
|
|
860
|
+
setTimeout(e, 200);
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
let r = o.getCanvas(), i = r.getContext("webgl") || r.getContext("webgl2");
|
|
864
|
+
i && i.readPixels(0, 0, 1, 1, i.RGBA, i.UNSIGNED_BYTE, new Uint8Array(4));
|
|
865
|
+
let a = `map.${this.format}`, s = new G();
|
|
866
|
+
switch (this.format) {
|
|
867
|
+
case R.PNG:
|
|
868
|
+
s.toPNG(r, a);
|
|
869
|
+
break;
|
|
870
|
+
case R.JPEG:
|
|
871
|
+
s.toJPEG(r, a, this.jpegQuality);
|
|
872
|
+
break;
|
|
873
|
+
case R.PDF:
|
|
874
|
+
new re(this.width, this.height, this.unit).generate(r, a);
|
|
875
|
+
break;
|
|
876
|
+
case R.SVG:
|
|
877
|
+
new ie().toSVG(r, a, this.width, this.height, this.unit, this.dpi);
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
o.remove(), n.remove(), Object.defineProperty(window, "devicePixelRatio", { get: () => t }), this.hideLoading(), e?.();
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
toPixels(e) {
|
|
884
|
+
return this.unit === z.mm ? 96 / 25.4 * e : 96 * e;
|
|
885
|
+
}
|
|
886
|
+
showLoading() {
|
|
887
|
+
let e = document.createElement("div");
|
|
888
|
+
e.className = "qm-print-loading-overlay", e.innerHTML = "<div class=\"qm-print-loading-spinner\"></div><div class=\"qm-print-loading-text\">正在生成...</div>", document.body.appendChild(e);
|
|
889
|
+
}
|
|
890
|
+
hideLoading() {
|
|
891
|
+
document.querySelector(".qm-print-loading-overlay")?.remove();
|
|
892
|
+
}
|
|
893
|
+
}, oe = t((e) => {
|
|
894
|
+
let { map: t } = O(), [r, u] = o(!1), [d, f] = o({
|
|
895
|
+
PageSize: B.A4,
|
|
896
|
+
PageOrientation: V.横向,
|
|
897
|
+
Format: R.PDF,
|
|
898
|
+
DPI: H[300],
|
|
899
|
+
Crosshair: !0,
|
|
900
|
+
PrintableArea: !0
|
|
901
|
+
}), p = a(null), m = a(null);
|
|
902
|
+
i(() => {
|
|
903
|
+
if (t) return r ? (d.Crosshair && (p.current = new U(t), p.current.create()), d.PrintableArea && (m.current = new W(t), m.current.create()), _()) : (p.current?.destroy(), p.current = null, m.current?.destroy(), m.current = null), () => {
|
|
904
|
+
p.current?.destroy(), m.current?.destroy();
|
|
905
|
+
};
|
|
906
|
+
}, [
|
|
907
|
+
t,
|
|
908
|
+
r,
|
|
909
|
+
d.Crosshair,
|
|
910
|
+
d.PrintableArea,
|
|
911
|
+
d.PageSize,
|
|
912
|
+
d.PageOrientation
|
|
913
|
+
]);
|
|
914
|
+
let _ = n(() => {
|
|
915
|
+
if (!m.current) return;
|
|
916
|
+
let e = d.PageSize;
|
|
917
|
+
d.PageOrientation === V.纵向 ? m.current.updateArea(e[1], e[0]) : m.current.updateArea(e[0], e[1]);
|
|
918
|
+
}, [d.PageSize, d.PageOrientation]), v = n(() => {
|
|
919
|
+
if (!t) return;
|
|
920
|
+
let e = [...d.PageSize];
|
|
921
|
+
d.PageOrientation === V.纵向 && (e = [e[1], e[0]]), new ae(t, e, d.DPI, d.Format, z.mm, {
|
|
922
|
+
jpegQuality: d.JPEGQuality,
|
|
923
|
+
northIcon: !0
|
|
924
|
+
}).generate(() => {
|
|
925
|
+
u(!1);
|
|
926
|
+
});
|
|
927
|
+
}, [t, d]), y = (e) => {
|
|
928
|
+
console.log("打印面板:", e), u(e);
|
|
929
|
+
}, b = Object.entries(B).map(([e, t]) => /* @__PURE__ */ c("option", {
|
|
930
|
+
value: JSON.stringify(t),
|
|
931
|
+
children: e
|
|
932
|
+
}, e)), x = Object.entries(V).map(([e, t]) => /* @__PURE__ */ c("option", {
|
|
933
|
+
value: t,
|
|
934
|
+
children: e
|
|
935
|
+
}, e)), S = Object.entries(R).map(([e, t]) => /* @__PURE__ */ c("option", {
|
|
936
|
+
value: t,
|
|
937
|
+
children: e
|
|
938
|
+
}, e)), C = Object.entries(H).map(([e, t]) => /* @__PURE__ */ c("option", {
|
|
939
|
+
value: t,
|
|
940
|
+
children: e
|
|
941
|
+
}, e));
|
|
942
|
+
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(g, {
|
|
943
|
+
name: "打印",
|
|
944
|
+
position: e.position,
|
|
945
|
+
icon: h.Print,
|
|
946
|
+
openHandle: y,
|
|
947
|
+
children: /* @__PURE__ */ c(s, {})
|
|
948
|
+
}), /* @__PURE__ */ l("div", {
|
|
949
|
+
className: `qm-print-panel ${r ? "open" : ""}`,
|
|
950
|
+
style: {
|
|
951
|
+
position: "absolute",
|
|
952
|
+
top: (e.position.top ?? 0) + 34,
|
|
953
|
+
right: e.position.right ?? 10
|
|
954
|
+
},
|
|
955
|
+
children: [/* @__PURE__ */ c("table", {
|
|
956
|
+
className: "qm-print-panel-table",
|
|
957
|
+
children: /* @__PURE__ */ l("tbody", { children: [
|
|
958
|
+
/* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("label", { children: "页面尺寸" }) }), /* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("select", {
|
|
959
|
+
id: "print-page-size",
|
|
960
|
+
value: JSON.stringify(d.PageSize),
|
|
961
|
+
onChange: (e) => {
|
|
962
|
+
f((t) => ({
|
|
963
|
+
...t,
|
|
964
|
+
PageSize: JSON.parse(e.target.value)
|
|
965
|
+
})), _();
|
|
966
|
+
},
|
|
967
|
+
children: b
|
|
968
|
+
}) })] }),
|
|
969
|
+
/* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("label", { children: "布局方向" }) }), /* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("select", {
|
|
970
|
+
id: "print-orientation",
|
|
971
|
+
value: d.PageOrientation,
|
|
972
|
+
onChange: (e) => {
|
|
973
|
+
f((t) => ({
|
|
974
|
+
...t,
|
|
975
|
+
PageOrientation: e.target.value
|
|
976
|
+
})), _();
|
|
977
|
+
},
|
|
978
|
+
children: x
|
|
979
|
+
}) })] }),
|
|
980
|
+
/* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("label", { children: "导出格式" }) }), /* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("select", {
|
|
981
|
+
id: "print-format",
|
|
982
|
+
value: d.Format,
|
|
983
|
+
onChange: (e) => f((t) => ({
|
|
984
|
+
...t,
|
|
985
|
+
Format: e.target.value
|
|
986
|
+
})),
|
|
987
|
+
children: S
|
|
988
|
+
}) })] }),
|
|
989
|
+
/* @__PURE__ */ l("tr", { children: [/* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("label", { children: "DPI" }) }), /* @__PURE__ */ c("td", { children: /* @__PURE__ */ c("select", {
|
|
990
|
+
id: "print-dpi",
|
|
991
|
+
value: d.DPI,
|
|
992
|
+
onChange: (e) => f((t) => ({
|
|
993
|
+
...t,
|
|
994
|
+
DPI: Number(e.target.value)
|
|
995
|
+
})),
|
|
996
|
+
children: C
|
|
997
|
+
}) })] })
|
|
998
|
+
] })
|
|
999
|
+
}), /* @__PURE__ */ c("button", {
|
|
1000
|
+
type: "button",
|
|
1001
|
+
className: "qm-print-export-button",
|
|
1002
|
+
onClick: v,
|
|
1003
|
+
children: "导 出"
|
|
1004
|
+
})]
|
|
1005
|
+
})] });
|
|
1006
|
+
});
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/gis/widget/Swipe/MapCompare/sync-maps.ts
|
|
1009
|
+
function se(e, t) {
|
|
1010
|
+
let n = e.getCenter(), r = e.getZoom(), i = e.getBearing(), a = e.getPitch();
|
|
1011
|
+
t.forEach((e) => {
|
|
1012
|
+
e.jumpTo({
|
|
1013
|
+
center: n,
|
|
1014
|
+
zoom: r,
|
|
1015
|
+
bearing: i,
|
|
1016
|
+
pitch: a
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
function ce(...e) {
|
|
1021
|
+
let t;
|
|
1022
|
+
t = e.length === 1 && Array.isArray(e[0]) ? e[0] : e;
|
|
1023
|
+
let n = [];
|
|
1024
|
+
t.forEach((e, r) => {
|
|
1025
|
+
let i = t.filter((e, t) => t !== r);
|
|
1026
|
+
n[r] = () => a(e, i);
|
|
1027
|
+
});
|
|
1028
|
+
function r() {
|
|
1029
|
+
t.forEach((e, t) => {
|
|
1030
|
+
e.on("move", n[t]);
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
function i() {
|
|
1034
|
+
t.forEach((e, t) => {
|
|
1035
|
+
e.off("move", n[t]);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
function a(e, t) {
|
|
1039
|
+
i(), se(e, t), r();
|
|
1040
|
+
}
|
|
1041
|
+
return r(), () => {
|
|
1042
|
+
i();
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
//#endregion
|
|
1046
|
+
//#region src/gis/widget/Swipe/MapCompare/index.ts
|
|
1047
|
+
var Z = class {
|
|
1048
|
+
options;
|
|
1049
|
+
_mapA;
|
|
1050
|
+
_mapB;
|
|
1051
|
+
_horizontal;
|
|
1052
|
+
_bounds;
|
|
1053
|
+
currentPosition = 0;
|
|
1054
|
+
_swiper;
|
|
1055
|
+
_controlContainer;
|
|
1056
|
+
_clearSync;
|
|
1057
|
+
_onResize;
|
|
1058
|
+
_eventTarget;
|
|
1059
|
+
constructor(e, t, n, r = {}) {
|
|
1060
|
+
this.options = {
|
|
1061
|
+
orientation: "vertical",
|
|
1062
|
+
mousemove: !1,
|
|
1063
|
+
...r
|
|
1064
|
+
}, this._mapA = e, this._mapB = t, this._horizontal = this.options.orientation === "horizontal", this._eventTarget = new EventTarget(), this._swiper = document.createElement("div"), this._swiper.className = this._horizontal ? "compare-swiper-horizontal" : "compare-swiper-vertical", this._controlContainer = document.createElement("div"), this._controlContainer.className = this._horizontal ? "maplibregl-compare maplibregl-compare-horizontal" : "maplibregl-compare", this._controlContainer.appendChild(this._swiper), this._mountContainer(n), this._bounds = this._mapB.getContainer().getBoundingClientRect();
|
|
1065
|
+
let i = this._horizontal ? this._bounds.height / 2 : this._bounds.width / 2;
|
|
1066
|
+
this._setPosition(i), this._clearSync = ce(this._mapA, this._mapB), this._onResize = () => {
|
|
1067
|
+
this._bounds = this._mapB.getContainer().getBoundingClientRect(), this.currentPosition && this._setPosition(this.currentPosition);
|
|
1068
|
+
}, this._mapB.on("resize", this._onResize), this.options.mousemove && (this._mapA.getContainer().addEventListener("mousemove", this._onMove), this._mapB.getContainer().addEventListener("mousemove", this._onMove)), this._swiper.addEventListener("mousedown", this._onDown), this._swiper.addEventListener("touchstart", this._onDown);
|
|
1069
|
+
}
|
|
1070
|
+
_mountContainer(e) {
|
|
1071
|
+
if (typeof e == "string") {
|
|
1072
|
+
let t = document.querySelector(e);
|
|
1073
|
+
if (!t) throw Error("找不到容器");
|
|
1074
|
+
t.appendChild(this._controlContainer);
|
|
1075
|
+
} else if (e instanceof HTMLElement) e.appendChild(this._controlContainer);
|
|
1076
|
+
else throw Error("容器必须是字符串选择器或 HTML 元素");
|
|
1077
|
+
}
|
|
1078
|
+
_setPointerEvents(e) {
|
|
1079
|
+
this._controlContainer.style.pointerEvents = e, this._swiper.style.pointerEvents = e;
|
|
1080
|
+
}
|
|
1081
|
+
_onDown = (e) => {
|
|
1082
|
+
"touches" in e ? (document.addEventListener("touchmove", this._onMove), document.addEventListener("touchend", this._onTouchEnd)) : (document.addEventListener("mousemove", this._onMove), document.addEventListener("mouseup", this._onMouseUp));
|
|
1083
|
+
};
|
|
1084
|
+
_setPosition(e) {
|
|
1085
|
+
let t = this._horizontal ? this._bounds.height : this._bounds.width, n = Math.max(0, Math.min(e, t)), r = this._horizontal ? `translate(0, ${n}px)` : `translate(${n}px, 0)`;
|
|
1086
|
+
this._controlContainer.style.transform = r, this._controlContainer.style.webkitTransform = r;
|
|
1087
|
+
let i = this._bounds.height, a, o;
|
|
1088
|
+
this._horizontal ? (a = `rect(0, 999em, ${n}px, 0)`, o = `rect(${n}px, 999em, ${i}px, 0)`) : (a = `rect(0, ${n}px, ${i}px, 0)`, o = `rect(0, 999em, ${i}px, ${n}px)`), this._mapA.getContainer().style.clip = a, this._mapB.getContainer().style.clip = o, this.currentPosition = n;
|
|
1089
|
+
}
|
|
1090
|
+
_onMove = (e) => {
|
|
1091
|
+
this.options.mousemove && this._setPointerEvents("none"), this._horizontal ? this._setPosition(this._getY(e)) : this._setPosition(this._getX(e));
|
|
1092
|
+
};
|
|
1093
|
+
_onMouseUp = () => {
|
|
1094
|
+
document.removeEventListener("mousemove", this._onMove), document.removeEventListener("mouseup", this._onMouseUp), this._emitSlideEnd();
|
|
1095
|
+
};
|
|
1096
|
+
_onTouchEnd = () => {
|
|
1097
|
+
document.removeEventListener("touchmove", this._onMove), document.removeEventListener("touchend", this._onTouchEnd), this._emitSlideEnd();
|
|
1098
|
+
};
|
|
1099
|
+
_emitSlideEnd() {
|
|
1100
|
+
this._eventTarget.dispatchEvent(new CustomEvent("slideend", { detail: { currentPosition: this.currentPosition } }));
|
|
1101
|
+
}
|
|
1102
|
+
_getX(e) {
|
|
1103
|
+
let t = ("touches" in e ? e.touches[0] : e).clientX - this._bounds.left;
|
|
1104
|
+
return Math.max(0, Math.min(t, this._bounds.width));
|
|
1105
|
+
}
|
|
1106
|
+
_getY(e) {
|
|
1107
|
+
let t = ("touches" in e ? e.touches[0] : e).clientY - this._bounds.top;
|
|
1108
|
+
return Math.max(0, Math.min(t, this._bounds.height));
|
|
1109
|
+
}
|
|
1110
|
+
setSlider(e) {
|
|
1111
|
+
this._setPosition(e);
|
|
1112
|
+
}
|
|
1113
|
+
on(e, t) {
|
|
1114
|
+
this._eventTarget.addEventListener(e, (e) => {
|
|
1115
|
+
let n = e.detail;
|
|
1116
|
+
t(n);
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
off(e, t) {
|
|
1120
|
+
this._eventTarget.removeEventListener(e, t);
|
|
1121
|
+
}
|
|
1122
|
+
remove() {
|
|
1123
|
+
this._clearSync(), this._mapB.off("resize", this._onResize), [this._mapA, this._mapB].forEach((e) => {
|
|
1124
|
+
let t = e.getContainer();
|
|
1125
|
+
t.style.clip = "", t.removeEventListener("mousemove", this._onMove);
|
|
1126
|
+
}), this._swiper.removeEventListener("mousedown", this._onDown), this._swiper.removeEventListener("touchstart", this._onDown), this._controlContainer.remove();
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
window.maplibregl && (window.maplibregl.Compare = Z);
|
|
1130
|
+
var le = t((e) => {
|
|
1131
|
+
let { title: t, open: r = !1, maskClosable: a = !0, mask: s, width: u = 520, footer: d, onCancel: p, destroyOnHidden: m = !1, className: h, style: g, children: _, centered: v = !1 } = e, y = s?.closable === void 0 ? a : s.closable, [b, x] = o(r);
|
|
1132
|
+
i(() => {
|
|
1133
|
+
if (r) x(!0), document.body.style.overflow = "hidden";
|
|
1134
|
+
else if (document.body.style.overflow = "", m) {
|
|
1135
|
+
let e = setTimeout(() => {
|
|
1136
|
+
x(!1);
|
|
1137
|
+
}, 200);
|
|
1138
|
+
return () => clearTimeout(e);
|
|
1139
|
+
}
|
|
1140
|
+
}, [r, m]), i(() => () => {
|
|
1141
|
+
document.body.style.overflow = "";
|
|
1142
|
+
}, []);
|
|
1143
|
+
let S = n((e) => {
|
|
1144
|
+
e.target === e.currentTarget && y && p?.();
|
|
1145
|
+
}, [y, p]), C = n((e) => {
|
|
1146
|
+
e.stopPropagation(), p?.();
|
|
1147
|
+
}, [p]);
|
|
1148
|
+
return b ? f(/* @__PURE__ */ l("div", {
|
|
1149
|
+
className: `qm-modal-wrapper ${r ? "qm-modal-open" : ""} ${v ? "qm-modal-centered" : ""}`,
|
|
1150
|
+
children: [/* @__PURE__ */ c("div", { className: `qm-modal-mask ${r ? "qm-modal-mask-enter" : "qm-modal-mask-leave"}` }), /* @__PURE__ */ c("div", {
|
|
1151
|
+
className: "qm-modal-container",
|
|
1152
|
+
onClick: S,
|
|
1153
|
+
children: /* @__PURE__ */ l("div", {
|
|
1154
|
+
className: `qm-modal ${h || ""} ${r ? "qm-modal-enter" : "qm-modal-leave"}`,
|
|
1155
|
+
style: {
|
|
1156
|
+
width: typeof u == "number" ? `${u}px` : u,
|
|
1157
|
+
...g
|
|
1158
|
+
},
|
|
1159
|
+
onClick: (e) => e.stopPropagation(),
|
|
1160
|
+
children: [
|
|
1161
|
+
t && /* @__PURE__ */ l("div", {
|
|
1162
|
+
className: "qm-modal-header",
|
|
1163
|
+
children: [/* @__PURE__ */ c("div", {
|
|
1164
|
+
className: "qm-modal-title",
|
|
1165
|
+
children: t
|
|
1166
|
+
}), /* @__PURE__ */ c("button", {
|
|
1167
|
+
type: "button",
|
|
1168
|
+
className: "qm-modal-close",
|
|
1169
|
+
onClick: C,
|
|
1170
|
+
"aria-label": "关闭",
|
|
1171
|
+
children: /* @__PURE__ */ c("span", {
|
|
1172
|
+
className: "qm-modal-close-x",
|
|
1173
|
+
children: "×"
|
|
1174
|
+
})
|
|
1175
|
+
})]
|
|
1176
|
+
}),
|
|
1177
|
+
/* @__PURE__ */ c("div", {
|
|
1178
|
+
className: "qm-modal-body",
|
|
1179
|
+
children: _
|
|
1180
|
+
}),
|
|
1181
|
+
d !== null && /* @__PURE__ */ c("div", {
|
|
1182
|
+
className: "qm-modal-footer",
|
|
1183
|
+
children: d
|
|
1184
|
+
})
|
|
1185
|
+
]
|
|
1186
|
+
})
|
|
1187
|
+
})]
|
|
1188
|
+
}), document.body) : null;
|
|
1189
|
+
}), ue = t((e) => {
|
|
1190
|
+
let { map: t } = O(), [r, a] = o(!1), [u, d] = o(null), [f, p] = o(null), m = n((e) => {
|
|
1191
|
+
a(e);
|
|
1192
|
+
}, []);
|
|
1193
|
+
return i(() => {
|
|
1194
|
+
if (u && f) {
|
|
1195
|
+
let e = document.getElementById("swipeContainer");
|
|
1196
|
+
e && (new Z(u, f, e, {
|
|
1197
|
+
mousemove: !1,
|
|
1198
|
+
orientation: "vertical"
|
|
1199
|
+
}), u.setCenter(t.getCenter()), u.setZoom(t.getZoom()), u.setBearing(t.getBearing()), f.setPitch(t.getPitch()));
|
|
1200
|
+
}
|
|
1201
|
+
}, [u, f]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(g, {
|
|
1202
|
+
name: "卷帘对比",
|
|
1203
|
+
position: { ...e.position },
|
|
1204
|
+
icon: h.Swipe,
|
|
1205
|
+
openHandle: m,
|
|
1206
|
+
children: /* @__PURE__ */ c(s, {})
|
|
1207
|
+
}), /* @__PURE__ */ c(le, {
|
|
1208
|
+
title: "卷帘对比",
|
|
1209
|
+
mask: { closable: !1 },
|
|
1210
|
+
open: r,
|
|
1211
|
+
width: 1e3,
|
|
1212
|
+
footer: null,
|
|
1213
|
+
onCancel: () => a(!1),
|
|
1214
|
+
destroyOnHidden: !0,
|
|
1215
|
+
children: /* @__PURE__ */ l("div", {
|
|
1216
|
+
id: "swipeContainer",
|
|
1217
|
+
className: "maplibregl-swipe",
|
|
1218
|
+
children: [/* @__PURE__ */ c(A, {
|
|
1219
|
+
mapOptions: {
|
|
1220
|
+
...t.options,
|
|
1221
|
+
id: "swipeBeforeMap"
|
|
1222
|
+
},
|
|
1223
|
+
mapLayerSettting: t.mapLayerSetting,
|
|
1224
|
+
onMapLoad: (e) => d(e),
|
|
1225
|
+
className: "swipe-map-container",
|
|
1226
|
+
children: /* @__PURE__ */ c(I, { position: {
|
|
1227
|
+
top: 10,
|
|
1228
|
+
left: 10
|
|
1229
|
+
} })
|
|
1230
|
+
}), /* @__PURE__ */ c(A, {
|
|
1231
|
+
mapOptions: {
|
|
1232
|
+
...t.options,
|
|
1233
|
+
id: "swipeAfterMap"
|
|
1234
|
+
},
|
|
1235
|
+
mapLayerSettting: t.mapLayerSetting,
|
|
1236
|
+
onMapLoad: (e) => p(e),
|
|
1237
|
+
className: "swipe-map-container",
|
|
1238
|
+
children: /* @__PURE__ */ c(I, { position: {
|
|
1239
|
+
top: 10,
|
|
1240
|
+
right: 10
|
|
1241
|
+
} })
|
|
1242
|
+
})]
|
|
1243
|
+
})
|
|
1244
|
+
})] });
|
|
1245
|
+
}), Q = {
|
|
1246
|
+
Point: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAARxJREFUWEft1LEuREEYxfHf9jRLIRIqnUSpoOEFREUh3kFBo6LYKEj0StEp8ARUEvUmOg2NSHT07pW73XK/mZBtZto5c87/npn7dYx4dUacrwCUBkoDpYHcBiYwjTG84g2fOUMtB+AYu0PC9nGUCpEK8IyZX0IOq72DFIgUgFusBMw3cBnQfUuiAOu4ippivLqmj4g+ClDfby9i2Gjm8BTRRwFusBYxbDTLuI/oowCn2IkYNpoF9CP6KMA2ziOGjWYS7xF9FKDbfFE9fNrWSTWU9tpEg/0oQK3f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lnD8S4H8a/N0aLAAAAABJRU5ErkJggg==",
|
|
1248
|
+
Rectangle: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAASxJREFUWEft16FKBWEQBeDvvodBRCw+gFWbgtVkEkWLil6wGbSLgiZBxKDFajB6owgGwSQ3GMTmMyhz3YVluRdW+BcM/4FlYXf2zPnPzMJMxy92cYx7POGgeJ76dooFfOEGZx1sIV5UsYKrxNmH5emGgEfMJE7WmC4EvGK69sUbPhuzNAscR1xV9EJA1D56oIo59JrxNo5axnUt+jAEBMr6vGO/aJDGzH8InMU5pjDos1JAcHwXp47Tt4kHhJBB7iwgO5AdyA5kB7ID2YHsQHbg3ziwXgyLMaYdYa+loXAztqGCe7vcjG6xVEvYxUliEYu4q3EOVrOYhuv4QD+xgDFM1jj7owQkzj2S7jkEDCvBKi4Tq4gyR64qNsq/YA2xOgUuWtyMQsQ8JrCDlx+OVWdvFenv8gAAAABJRU5ErkJggg==",
|
|
1249
|
+
Polygon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAxVJREFUWEe1133InnMUB/DPKCQS87ZQtrJ5yT8LUShaJKHWzMSaWqkt07LyEjEvQykrL2WRFautoZBt3hoRhkRqjLyUKMuyGLHWan3X73q6unff7t+953Lq6um5nt855/s7z/ec870mqLfDcBeuwd94E7fUu/c/OWGEAIuxvOf8Ejw6Qox9jo4C4HtM6ZPsM/Q+/TAdWfx/xtbmwCgANuP0ytt+hE3IzzznYW3L9znMy++jAHgIt/cAeAw7cApOKwAPrAR5L5bWAjgKH+DUEjzVGETCizEV03AGzsTxfUC9jstqATyM2/Aqrqq8YXPsEPzTxyfkXVID4AK8iwNKmbeMCCDHV+DGlt83mImvagC8XG79CG7dj+SNy7VYiYNxOdbXkHA+nsFfCA92jQNAXH/EyTgRvwwDkJJ/WYi0AE+NM3ncPywteQ4+HQbgAd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
|
1257
|
+
icon: Q.Point
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
id: "line",
|
|
1261
|
+
title: "绘制线",
|
|
1262
|
+
mode: "draw_line_string",
|
|
1263
|
+
icon: Q.Line
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
id: "polygon",
|
|
1267
|
+
title: "绘制面",
|
|
1268
|
+
mode: "draw_polygon",
|
|
1269
|
+
icon: Q.Polygon
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
id: "reset",
|
|
1273
|
+
title: "清除选中/所有",
|
|
1274
|
+
mode: "simple_select",
|
|
1275
|
+
icon: Q.Reset
|
|
1276
|
+
}
|
|
1277
|
+
], de = [
|
|
1278
|
+
{
|
|
1279
|
+
id: "gl-draw-line",
|
|
1280
|
+
type: "line",
|
|
1281
|
+
filter: ["all", [
|
|
1282
|
+
"==",
|
|
1283
|
+
"$type",
|
|
1284
|
+
"LineString"
|
|
1285
|
+
]],
|
|
1286
|
+
layout: {
|
|
1287
|
+
"line-cap": "round",
|
|
1288
|
+
"line-join": "round"
|
|
1289
|
+
},
|
|
1290
|
+
paint: {
|
|
1291
|
+
"line-color": "#D20C0C",
|
|
1292
|
+
"line-dasharray": [.2, 2],
|
|
1293
|
+
"line-width": 2
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
id: "gl-draw-polygon-fill",
|
|
1298
|
+
type: "fill",
|
|
1299
|
+
filter: ["all", [
|
|
1300
|
+
"==",
|
|
1301
|
+
"$type",
|
|
1302
|
+
"Polygon"
|
|
1303
|
+
]],
|
|
1304
|
+
paint: {
|
|
1305
|
+
"fill-color": "#D20C0C",
|
|
1306
|
+
"fill-outline-color": "#D20C0C",
|
|
1307
|
+
"fill-opacity": .3
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
id: "gl-draw-polygon-midpoint",
|
|
1312
|
+
type: "circle",
|
|
1313
|
+
filter: [
|
|
1314
|
+
"all",
|
|
1315
|
+
[
|
|
1316
|
+
"==",
|
|
1317
|
+
"$type",
|
|
1318
|
+
"Point"
|
|
1319
|
+
],
|
|
1320
|
+
[
|
|
1321
|
+
"==",
|
|
1322
|
+
"meta",
|
|
1323
|
+
"midpoint"
|
|
1324
|
+
]
|
|
1325
|
+
],
|
|
1326
|
+
paint: {
|
|
1327
|
+
"circle-radius": 5,
|
|
1328
|
+
"circle-color": "#fbb03b"
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
id: "gl-draw-polygon-stroke-active",
|
|
1333
|
+
type: "line",
|
|
1334
|
+
filter: ["all", [
|
|
1335
|
+
"==",
|
|
1336
|
+
"$type",
|
|
1337
|
+
"Polygon"
|
|
1338
|
+
]],
|
|
1339
|
+
layout: {
|
|
1340
|
+
"line-cap": "round",
|
|
1341
|
+
"line-join": "round"
|
|
1342
|
+
},
|
|
1343
|
+
paint: {
|
|
1344
|
+
"line-color": "#D20C0C",
|
|
1345
|
+
"line-dasharray": [.3, 3],
|
|
1346
|
+
"line-width": 3
|
|
1347
|
+
}
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
id: "gl-draw-polygon-and-line-vertex-halo-active",
|
|
1351
|
+
type: "circle",
|
|
1352
|
+
filter: [
|
|
1353
|
+
"all",
|
|
1354
|
+
[
|
|
1355
|
+
"==",
|
|
1356
|
+
"meta",
|
|
1357
|
+
"vertex"
|
|
1358
|
+
],
|
|
1359
|
+
[
|
|
1360
|
+
"==",
|
|
1361
|
+
"$type",
|
|
1362
|
+
"Point"
|
|
1363
|
+
]
|
|
1364
|
+
],
|
|
1365
|
+
paint: {
|
|
1366
|
+
"circle-radius": 5,
|
|
1367
|
+
"circle-color": "#FFF"
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
id: "gl-draw-polygon-and-line-vertex-active",
|
|
1372
|
+
type: "circle",
|
|
1373
|
+
filter: [
|
|
1374
|
+
"all",
|
|
1375
|
+
[
|
|
1376
|
+
"==",
|
|
1377
|
+
"meta",
|
|
1378
|
+
"vertex"
|
|
1379
|
+
],
|
|
1380
|
+
[
|
|
1381
|
+
"==",
|
|
1382
|
+
"$type",
|
|
1383
|
+
"Point"
|
|
1384
|
+
]
|
|
1385
|
+
],
|
|
1386
|
+
paint: {
|
|
1387
|
+
"circle-radius": 3,
|
|
1388
|
+
"circle-color": "#D20C0C"
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
id: "gl-draw-point-point-stroke-active",
|
|
1393
|
+
type: "circle",
|
|
1394
|
+
filter: [
|
|
1395
|
+
"all",
|
|
1396
|
+
[
|
|
1397
|
+
"==",
|
|
1398
|
+
"$type",
|
|
1399
|
+
"Point"
|
|
1400
|
+
],
|
|
1401
|
+
[
|
|
1402
|
+
"==",
|
|
1403
|
+
"meta",
|
|
1404
|
+
"feature"
|
|
1405
|
+
],
|
|
1406
|
+
[
|
|
1407
|
+
"==",
|
|
1408
|
+
"active",
|
|
1409
|
+
"true"
|
|
1410
|
+
]
|
|
1411
|
+
],
|
|
1412
|
+
paint: {
|
|
1413
|
+
"circle-radius": 8,
|
|
1414
|
+
"circle-color": "#FFF"
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
id: "gl-draw-point-active",
|
|
1419
|
+
type: "circle",
|
|
1420
|
+
filter: [
|
|
1421
|
+
"all",
|
|
1422
|
+
[
|
|
1423
|
+
"==",
|
|
1424
|
+
"$type",
|
|
1425
|
+
"Point"
|
|
1426
|
+
],
|
|
1427
|
+
[
|
|
1428
|
+
"==",
|
|
1429
|
+
"meta",
|
|
1430
|
+
"feature"
|
|
1431
|
+
],
|
|
1432
|
+
[
|
|
1433
|
+
"==",
|
|
1434
|
+
"active",
|
|
1435
|
+
"true"
|
|
1436
|
+
]
|
|
1437
|
+
],
|
|
1438
|
+
paint: {
|
|
1439
|
+
"circle-radius": 6,
|
|
1440
|
+
"circle-color": "#D20C0C"
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
id: "gl-draw-point-point-stroke-inactive",
|
|
1445
|
+
type: "circle",
|
|
1446
|
+
filter: [
|
|
1447
|
+
"all",
|
|
1448
|
+
[
|
|
1449
|
+
"==",
|
|
1450
|
+
"$type",
|
|
1451
|
+
"Point"
|
|
1452
|
+
],
|
|
1453
|
+
[
|
|
1454
|
+
"==",
|
|
1455
|
+
"meta",
|
|
1456
|
+
"feature"
|
|
1457
|
+
],
|
|
1458
|
+
[
|
|
1459
|
+
"==",
|
|
1460
|
+
"active",
|
|
1461
|
+
"false"
|
|
1462
|
+
]
|
|
1463
|
+
],
|
|
1464
|
+
paint: {
|
|
1465
|
+
"circle-radius": 8,
|
|
1466
|
+
"circle-color": "#FFF"
|
|
1467
|
+
}
|
|
1468
|
+
},
|
|
1469
|
+
{
|
|
1470
|
+
id: "gl-draw-point-inactive",
|
|
1471
|
+
type: "circle",
|
|
1472
|
+
filter: [
|
|
1473
|
+
"all",
|
|
1474
|
+
[
|
|
1475
|
+
"==",
|
|
1476
|
+
"$type",
|
|
1477
|
+
"Point"
|
|
1478
|
+
],
|
|
1479
|
+
[
|
|
1480
|
+
"==",
|
|
1481
|
+
"meta",
|
|
1482
|
+
"feature"
|
|
1483
|
+
],
|
|
1484
|
+
[
|
|
1485
|
+
"==",
|
|
1486
|
+
"active",
|
|
1487
|
+
"false"
|
|
1488
|
+
]
|
|
1489
|
+
],
|
|
1490
|
+
paint: {
|
|
1491
|
+
"circle-radius": 6,
|
|
1492
|
+
"circle-color": "#D20C0C"
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
], fe = t((e) => {
|
|
1496
|
+
let { position: t, onDraw: n, initFeature: r, modes: o } = e, s = o ? $.filter((e) => o.includes(e.mode) || e.id === "reset") : $, { map: l } = O(), u = a(null);
|
|
1497
|
+
i(() => {
|
|
1498
|
+
r && d(r);
|
|
1499
|
+
}, [r]);
|
|
1500
|
+
let d = (e) => {
|
|
1501
|
+
if (l && e.features && u.current) {
|
|
1502
|
+
let t = x(e.features[0]);
|
|
1503
|
+
t && l.fitBounds(t, { maxZoom: 16 });
|
|
1504
|
+
let n = u.current.add(e);
|
|
1505
|
+
u.current.changeMode("simple_select", { featureIds: n });
|
|
1506
|
+
}
|
|
1507
|
+
}, f = (e, t) => {
|
|
1508
|
+
if (!u.current || !l) return;
|
|
1509
|
+
t === "reset" && u.current.deleteAll(), u.current.changeMode(e);
|
|
1510
|
+
let n = l.getCanvas();
|
|
1511
|
+
e === "simple_select" ? n.style.cursor = "" : n.style.cursor = "crosshair";
|
|
1512
|
+
}, h = () => {
|
|
1513
|
+
if (!u.current) return;
|
|
1514
|
+
let e = u.current.getAll();
|
|
1515
|
+
if (e && e.features.length > 0) {
|
|
1516
|
+
let t = 0;
|
|
1517
|
+
e.features.forEach((e) => {
|
|
1518
|
+
(e.geometry.type === "Polygon" || e.geometry.type === "MultiPolygon") && (t += m(e));
|
|
1519
|
+
}), n({
|
|
1520
|
+
data: e,
|
|
1521
|
+
area: t
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
return i(() => (l && !u.current && (u.current = new p({
|
|
1526
|
+
displayControlsDefault: !1,
|
|
1527
|
+
styles: de,
|
|
1528
|
+
defaultMode: "simple_select"
|
|
1529
|
+
}), l.addControl(u.current, "bottom-left"), l.on("draw.create", h), l.on("draw.delete", h), l.on("draw.update", h), l.on("draw.modechange", (e) => {
|
|
1530
|
+
let t = l.getCanvas();
|
|
1531
|
+
e.mode === "simple_select" ? t.style.cursor = "" : t.style.cursor = "crosshair";
|
|
1532
|
+
})), () => {}), []), /* @__PURE__ */ c("div", {
|
|
1533
|
+
className: "mapboxgl-draw",
|
|
1534
|
+
style: { ...t },
|
|
1535
|
+
children: /* @__PURE__ */ c("div", {
|
|
1536
|
+
className: "mapboxgl-draw-bar",
|
|
1537
|
+
children: /* @__PURE__ */ c("div", { children: s.map((e) => /* @__PURE__ */ c("div", {
|
|
1538
|
+
title: e.title,
|
|
1539
|
+
className: "mapboxgl-draw-bar-button",
|
|
1540
|
+
style: { backgroundImage: `url(${e.icon})` },
|
|
1541
|
+
onClick: () => f(e.mode, e.id)
|
|
1542
|
+
}, e.id)) })
|
|
1543
|
+
})
|
|
1544
|
+
});
|
|
1545
|
+
});
|
|
1546
|
+
//#endregion
|
|
1547
|
+
export { S as BaseLayer, g as BaseWidget, fe as Draw, w as LayerGroupWrapper, I as LayerList, C as LayerWrapper, L as Legend, D as MapContext, A as MapWidget, E as MapWrapper, oe as Print, ue as Swipe, O as useMap };
|