@edugis-org/webmapx 0.1.0
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 +149 -0
- package/dist-lib/WMTS-DCN4zX0-.js +1169 -0
- package/dist-lib/alert-GeHlqlN8.js +310 -0
- package/dist-lib/assets/epsg-lookup.worker-J7TVnHDq.js +1 -0
- package/dist-lib/assets/shapefile.worker-kQfZj6G2.js +4 -0
- package/dist-lib/attribution-format-B4f05_u0.js +62 -0
- package/dist-lib/button-DFdGkRPQ.js +741 -0
- package/dist-lib/cesium-adapter-BHXNytkU.js +1488 -0
- package/dist-lib/checkbox-QoR4S8tV.js +284 -0
- package/dist-lib/chunk-HEgqtunE.js +20 -0
- package/dist-lib/chunk.36O46B5H-B6ZL7Sm1.js +77 -0
- package/dist-lib/chunk.3RPBFEDE-BFO1fHVm.js +138 -0
- package/dist-lib/chunk.5JY5FUCG-DTXsslmx.js +1090 -0
- package/dist-lib/chunk.6CTB5ZDJ-DjZrBd6Y.js +99 -0
- package/dist-lib/chunk.AJ3ENQ5C-Ci7Gm2b6.js +175 -0
- package/dist-lib/chunk.LD4M4QGE-CiCfhE8r.js +8 -0
- package/dist-lib/chunk.NYIIDP5N-BikXIStD.js +99 -0
- package/dist-lib/chunk.RWUUFNUL-DFztA4uV.js +43 -0
- package/dist-lib/chunk.SI4ACBFK-CLb9VfMG.js +61 -0
- package/dist-lib/chunk.YHLNUJ7P-D-kanrCf.js +503 -0
- package/dist-lib/core-CMAlSR68.js +22 -0
- package/dist-lib/decorate-CWgUV1hU.js +1139 -0
- package/dist-lib/decorators-B35AgiCU.js +351 -0
- package/dist-lib/deferred-query-service-BJDcngw6.js +386 -0
- package/dist-lib/dist-Dm6b7XCs.js +12318 -0
- package/dist-lib/dist-Ha9LQCut.js +244 -0
- package/dist-lib/dist-c1PlDAd1.js +2359 -0
- package/dist-lib/dist-kKlmcBXq.js +50 -0
- package/dist-lib/divider-CPm675yY.js +41 -0
- package/dist-lib/dropped-config-C_GyVa8o.js +17 -0
- package/dist-lib/dropped-layer-builder-DAaYgUPk.js +396 -0
- package/dist-lib/epsg-definitions-BZLZWa8Q.js +668 -0
- package/dist-lib/esm-CTuscnN5.js +46 -0
- package/dist-lib/file-sniff-Dhxj3KTF.js +251 -0
- package/dist-lib/geo-calculations-DbFJAUoI.js +30 -0
- package/dist-lib/icon-CEOgWlro.js +9 -0
- package/dist-lib/icon-button-Da_nBTy3.js +408 -0
- package/dist-lib/input-CeGntPlT.js +590 -0
- package/dist-lib/layer-discovery-afWzu5hY.js +2825 -0
- package/dist-lib/leaflet-adapter-D9djjrKv.js +1227 -0
- package/dist-lib/lib-CdHVicAE.js +4074 -0
- package/dist-lib/map-layer-registry-2cmkiRDK.js +62 -0
- package/dist-lib/maplibre-adapter-TFc3e0G9.js +1190 -0
- package/dist-lib/maplibre-expression-evaluator-DCWUcpwf.js +7233 -0
- package/dist-lib/marker-utils-DztWXeop.js +12 -0
- package/dist-lib/ol-tilegrid-9VtyxaLG.js +64 -0
- package/dist-lib/openlayers-adapter-DVW1KCRv.js +13307 -0
- package/dist-lib/option-CBxl1mZP.js +1106 -0
- package/dist-lib/papaparse.min-B7v3c0D7.js +501 -0
- package/dist-lib/rbush-C8k41T4z.js +254 -0
- package/dist-lib/shapefile-SawVY6xg.js +207 -0
- package/dist-lib/spinner-DysxdNG9.js +6 -0
- package/dist-lib/src-CL94RDe3.js +111 -0
- package/dist-lib/throttle-BeneRNYK.js +16 -0
- package/dist-lib/toast-Cm28o9U6.js +15 -0
- package/dist-lib/togeojson.es-DAgiTBvg.js +579 -0
- package/dist-lib/tooltip-Cucn1SiD.js +197 -0
- package/dist-lib/webmapx-3d-tool-D4CTD2gB.js +176 -0
- package/dist-lib/webmapx-base-tool-Dm9NAWLD.js +75 -0
- package/dist-lib/webmapx-config-edit-tool-DCTyxqTk.js +389 -0
- package/dist-lib/webmapx-coordinates-tool-jeWohup9.js +648 -0
- package/dist-lib/webmapx-core-bundle-BDImi1RE.js +8203 -0
- package/dist-lib/webmapx-draw-tool-DooAV8cF.js +4336 -0
- package/dist-lib/webmapx-geolocation-tool-Rw3-Iad1.js +788 -0
- package/dist-lib/webmapx-import-layer-tool-DRYviHd5.js +250 -0
- package/dist-lib/webmapx-info-tool-BJA157cy.js +412 -0
- package/dist-lib/webmapx-language-osmvector-M5y_lwOg.js +489 -0
- package/dist-lib/webmapx-measure-tool-BXhMJFC6.js +590 -0
- package/dist-lib/webmapx-modal-tool-eF6Naluv.js +84 -0
- package/dist-lib/webmapx-plugin-tool-D2Hghf9n.js +45 -0
- package/dist-lib/webmapx-print-tool-ob1bOsR5.js +348 -0
- package/dist-lib/webmapx-search-tool-Cv8BrYvY.js +437 -0
- package/dist-lib/webmapx-settings-DDEJ8aoV.js +479 -0
- package/dist-lib/webmapx-truearea-tool-CMB4Orm-.js +615 -0
- package/dist-lib/webmapx-view-mode-tool-CUpLNjOj.js +106 -0
- package/dist-lib/webmapx.css +2 -0
- package/dist-lib/webmapx.js +1321 -0
- package/dist-lib/wms-feature-info-C0RVMEQC.js +145 -0
- package/dist-lib/wms-url-builder-DIJLQ1v2.js +54 -0
- package/dist-lib/zip.js-DVhmtjxZ.js +3615 -0
- package/package.json +107 -0
- package/public/data/country-epsg-codes.json +297 -0
- package/public/data/world-countries-simplified.topojson +1 -0
- package/src/locales/en/core.json +20 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { t as e } from "./decorate-CWgUV1hU.js";
|
|
2
|
+
import { a as t, o as n } from "./decorators-B35AgiCU.js";
|
|
3
|
+
import { LitElement as r, html as i } from "lit";
|
|
4
|
+
//#region src/components/webmapx-plugin-tool.ts
|
|
5
|
+
var a = class extends r {
|
|
6
|
+
constructor(...e) {
|
|
7
|
+
super(...e), this.toolId = "", this.pluginElement = null, this.configReadyHandler = (e) => this.handleConfigReady(e);
|
|
8
|
+
}
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
super.connectedCallback();
|
|
11
|
+
let e = this.closest("webmapx-map");
|
|
12
|
+
if (!e) return;
|
|
13
|
+
let t = e.toolsConfig;
|
|
14
|
+
if (t && this.toolId) {
|
|
15
|
+
this.mountPlugin(t[this.toolId]);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
e.addEventListener("webmapx-config-ready", this.configReadyHandler);
|
|
19
|
+
}
|
|
20
|
+
disconnectedCallback() {
|
|
21
|
+
this.closest("webmapx-map")?.removeEventListener("webmapx-config-ready", this.configReadyHandler), this.pluginElement = null, super.disconnectedCallback();
|
|
22
|
+
}
|
|
23
|
+
handleConfigReady(e) {
|
|
24
|
+
let t = e.detail?.config?.tools;
|
|
25
|
+
!t || !this.toolId || this.mountPlugin(t[this.toolId]);
|
|
26
|
+
}
|
|
27
|
+
mountPlugin(e) {
|
|
28
|
+
if (!e?.enabled || !e.element || this.pluginElement) return;
|
|
29
|
+
let t = document.createElement(e.element);
|
|
30
|
+
for (let [n, r] of Object.entries(e)) n === "enabled" || n === "element" || (t[n] = r);
|
|
31
|
+
this.pluginElement = t, this.requestUpdate();
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
return this.pluginElement ? i`<slot></slot>` : i``;
|
|
35
|
+
}
|
|
36
|
+
updated() {
|
|
37
|
+
this.pluginElement && !this.contains(this.pluginElement) && this.appendChild(this.pluginElement);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
e([t({
|
|
41
|
+
type: String,
|
|
42
|
+
attribute: "tool-id"
|
|
43
|
+
})], a.prototype, "toolId", void 0), a = e([n("webmapx-plugin-tool")], a);
|
|
44
|
+
//#endregion
|
|
45
|
+
export { a as t };
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { r as e, t } from "./decorate-CWgUV1hU.js";
|
|
2
|
+
import { i as n, o as r } from "./decorators-B35AgiCU.js";
|
|
3
|
+
import "./button-DFdGkRPQ.js";
|
|
4
|
+
import "./checkbox-QoR4S8tV.js";
|
|
5
|
+
import "./input-CeGntPlT.js";
|
|
6
|
+
import "./spinner-DysxdNG9.js";
|
|
7
|
+
import { i, r as a, t as o } from "./attribution-format-B4f05_u0.js";
|
|
8
|
+
import { t as s } from "./webmapx-modal-tool-eF6Naluv.js";
|
|
9
|
+
import "./option-CBxl1mZP.js";
|
|
10
|
+
import { css as c, html as l } from "lit";
|
|
11
|
+
//#region src/components/webmapx-print-tool.ts
|
|
12
|
+
var u = 210, d = 297, f = 40, p = 10, m = 50, h = 12, g = 6, _ = 96 / 25.4;
|
|
13
|
+
function v(e) {
|
|
14
|
+
return e * _;
|
|
15
|
+
}
|
|
16
|
+
function y(e) {
|
|
17
|
+
return e.startsWith("landscape");
|
|
18
|
+
}
|
|
19
|
+
function b(e) {
|
|
20
|
+
return e.endsWith("_with_legend");
|
|
21
|
+
}
|
|
22
|
+
function x(e) {
|
|
23
|
+
return {
|
|
24
|
+
w: (y(e) ? d : u) - 2 * p - (b(e) ? m : 0),
|
|
25
|
+
h: (y(e) ? u : d) - 2 * p
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var S = class extends s {
|
|
29
|
+
constructor(...e) {
|
|
30
|
+
super(...e), this.toolId = "print", this.mapTitle = "", this.format = "portrait", this.addLink = !1, this.printing = !1, this.errorMsg = "", this.zoomDelta = 0, this.printBoxEl = null, this.resizeObserver = null;
|
|
31
|
+
}
|
|
32
|
+
static {
|
|
33
|
+
this.styles = c`
|
|
34
|
+
:host { display: block; font-size: var(--sl-font-size-small); }
|
|
35
|
+
.tool-content {
|
|
36
|
+
padding: var(--webmapx-tool-panel-padding, 12px);
|
|
37
|
+
display: flex; flex-direction: column; gap: 12px; min-width: 220px;
|
|
38
|
+
}
|
|
39
|
+
.description { color: var(--sl-color-neutral-600); margin: 0; line-height: 1.4; }
|
|
40
|
+
.field { display: flex; flex-direction: column; gap: 4px; }
|
|
41
|
+
.field label { font-weight: var(--sl-font-weight-semibold); font-size: var(--sl-font-size-small); }
|
|
42
|
+
.error { color: var(--sl-color-danger-600); font-size: var(--sl-font-size-x-small); margin: 0; }
|
|
43
|
+
.warning {
|
|
44
|
+
font-size: var(--sl-font-size-x-small);
|
|
45
|
+
color: var(--sl-color-warning-800, #854d0e);
|
|
46
|
+
background: var(--sl-color-warning-50, #fefce8);
|
|
47
|
+
border: 1px solid var(--sl-color-warning-200, #fef08a);
|
|
48
|
+
border-radius: var(--sl-border-radius-small);
|
|
49
|
+
padding: 6px 8px;
|
|
50
|
+
margin: 0;
|
|
51
|
+
line-height: 1.4;
|
|
52
|
+
}
|
|
53
|
+
.busy { display: flex; align-items: center; gap: 8px; color: var(--sl-color-neutral-600); }
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
onActivate() {
|
|
57
|
+
let t = e(this);
|
|
58
|
+
if (!t) return;
|
|
59
|
+
this.printBoxEl = document.createElement("div"), this.printBoxEl.className = "webmapx-print-box", Object.assign(this.printBoxEl.style, {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
boxSizing: "border-box",
|
|
62
|
+
backgroundImage: [
|
|
63
|
+
"repeating-linear-gradient(90deg, #fff 0, #fff 6px, #000 6px, #000 12px)",
|
|
64
|
+
"repeating-linear-gradient(90deg, #fff 0, #fff 6px, #000 6px, #000 12px)",
|
|
65
|
+
"repeating-linear-gradient(0deg, #fff 0, #fff 6px, #000 6px, #000 12px)",
|
|
66
|
+
"repeating-linear-gradient(0deg, #fff 0, #fff 6px, #000 6px, #000 12px)"
|
|
67
|
+
].join(","),
|
|
68
|
+
backgroundSize: "12px 2px, 12px 2px, 2px 12px, 2px 12px",
|
|
69
|
+
backgroundPosition: "0 0, 0 100%, 0 0, 100% 0",
|
|
70
|
+
backgroundRepeat: "repeat-x, repeat-x, repeat-y, repeat-y",
|
|
71
|
+
boxShadow: "0 0 0 9999px rgba(0,0,0,0.35)",
|
|
72
|
+
pointerEvents: "none"
|
|
73
|
+
});
|
|
74
|
+
let n = t.querySelector("webmapx-layout");
|
|
75
|
+
t.insertBefore(this.printBoxEl, n ?? t.firstChild), this.resizeObserver = new ResizeObserver(() => this.updateBox()), this.resizeObserver.observe(t), this.updateBox();
|
|
76
|
+
}
|
|
77
|
+
onDeactivate() {
|
|
78
|
+
this.printBoxEl?.remove(), this.printBoxEl = null, this.resizeObserver?.disconnect(), this.resizeObserver = null;
|
|
79
|
+
}
|
|
80
|
+
onStateChanged() {
|
|
81
|
+
this.updateBox();
|
|
82
|
+
}
|
|
83
|
+
updateBox() {
|
|
84
|
+
let t = e(this);
|
|
85
|
+
if (!this.printBoxEl || !t) return;
|
|
86
|
+
let n = t.clientWidth, r = t.clientHeight, i = n - 2 * f, a = r - 2 * f, o = x(this.format), s = v(o.w), c = v(o.h) - (this.mapTitle.trim() ? v(h) : 0) - (this.addLink ? v(g) : 0), l, u;
|
|
87
|
+
if (s <= i && c <= a) l = s, u = c, this.zoomDelta = 0;
|
|
88
|
+
else {
|
|
89
|
+
let e = Math.min(i / s, a / c);
|
|
90
|
+
l = s * e, u = c * e, this.zoomDelta = Math.log2(s / l);
|
|
91
|
+
}
|
|
92
|
+
Object.assign(this.printBoxEl.style, {
|
|
93
|
+
left: `${(n - l) / 2}px`,
|
|
94
|
+
top: `${(r - u) / 2}px`,
|
|
95
|
+
width: `${l}px`,
|
|
96
|
+
height: `${u}px`
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async handlePrint() {
|
|
100
|
+
this.printing = !0, this.errorMsg = "";
|
|
101
|
+
try {
|
|
102
|
+
await this.renderAndPrint();
|
|
103
|
+
} catch (e) {
|
|
104
|
+
this.errorMsg = e instanceof Error ? e.message : "Print failed", console.error("[print-tool]", e);
|
|
105
|
+
} finally {
|
|
106
|
+
this.printing = !1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async renderAndPrint() {
|
|
110
|
+
let t = this.adapter;
|
|
111
|
+
if (!t) throw Error("No map adapter available.");
|
|
112
|
+
let n = e(this), r = this.format, i = y(r), a = b(r), o = v(i ? d : u), s = v(i ? u : d), c = v(p), l = this.mapTitle.trim() ? v(h) : 0, f = this.addLink ? v(g) : 0, _ = a ? v(m) : 0, S = x(r), C = v(S.w), w = v(S.h) - l - f, T = n.getBoundingClientRect(), E = this.printBoxEl.getBoundingClientRect(), D = E.left - T.left, O = E.top - T.top, k = E.width, A = t.engineId === "maplibre", j = document.createElement("div");
|
|
113
|
+
if (j.id = "webmapx-print-overlay", Object.assign(j.style, {
|
|
114
|
+
position: "fixed",
|
|
115
|
+
top: "-99999px",
|
|
116
|
+
left: "0",
|
|
117
|
+
width: o + "px",
|
|
118
|
+
height: s + "px",
|
|
119
|
+
background: A ? "white" : "transparent",
|
|
120
|
+
display: "flex",
|
|
121
|
+
flexDirection: "column",
|
|
122
|
+
padding: c + "px",
|
|
123
|
+
boxSizing: "border-box",
|
|
124
|
+
fontFamily: "sans-serif"
|
|
125
|
+
}), l) {
|
|
126
|
+
let e = document.createElement("div");
|
|
127
|
+
e.textContent = this.mapTitle.trim(), Object.assign(e.style, {
|
|
128
|
+
height: l + "px",
|
|
129
|
+
lineHeight: l + "px",
|
|
130
|
+
fontSize: "16px",
|
|
131
|
+
fontWeight: "bold",
|
|
132
|
+
flexShrink: "0",
|
|
133
|
+
background: "white"
|
|
134
|
+
}), j.appendChild(e);
|
|
135
|
+
}
|
|
136
|
+
let M = [], N = document.createElement("div");
|
|
137
|
+
Object.assign(N.style, {
|
|
138
|
+
display: "flex",
|
|
139
|
+
gap: a ? "8px" : "0",
|
|
140
|
+
height: w + "px",
|
|
141
|
+
flexShrink: "0"
|
|
142
|
+
});
|
|
143
|
+
let P = document.createElement("div");
|
|
144
|
+
if (Object.assign(P.style, {
|
|
145
|
+
width: C + "px",
|
|
146
|
+
height: w + "px",
|
|
147
|
+
flexShrink: "0",
|
|
148
|
+
overflow: "hidden",
|
|
149
|
+
background: "transparent"
|
|
150
|
+
}), N.appendChild(P), a) {
|
|
151
|
+
let e = document.createElement("div");
|
|
152
|
+
Object.assign(e.style, {
|
|
153
|
+
width: _ - 8 + "px",
|
|
154
|
+
height: w + "px",
|
|
155
|
+
flexShrink: "0",
|
|
156
|
+
overflow: "hidden",
|
|
157
|
+
paddingLeft: "6px",
|
|
158
|
+
borderLeft: "1px solid #ddd",
|
|
159
|
+
boxSizing: "border-box",
|
|
160
|
+
display: "flex",
|
|
161
|
+
flexDirection: "column",
|
|
162
|
+
background: "white"
|
|
163
|
+
});
|
|
164
|
+
let t = document.createElement("div");
|
|
165
|
+
t.textContent = "Legend", Object.assign(t.style, {
|
|
166
|
+
fontWeight: "600",
|
|
167
|
+
fontSize: "8px",
|
|
168
|
+
letterSpacing: "0.06em",
|
|
169
|
+
textTransform: "uppercase",
|
|
170
|
+
color: "#555",
|
|
171
|
+
marginBottom: "4px",
|
|
172
|
+
flexShrink: "0"
|
|
173
|
+
}), e.appendChild(t);
|
|
174
|
+
let n = this.store?.getState()?.mapLayers ?? {};
|
|
175
|
+
for (let [t, r] of Object.entries(n).reverse()) {
|
|
176
|
+
if (r.hideFromLegend === !0 || r.legendExpandMode === "collapsed" || r.visible === !1) continue;
|
|
177
|
+
let n = typeof r.label == "string" && r.label ? r.label : t, i = document.createElement("div");
|
|
178
|
+
i.textContent = n, Object.assign(i.style, {
|
|
179
|
+
fontSize: "13px",
|
|
180
|
+
fontWeight: "700",
|
|
181
|
+
color: "#111827",
|
|
182
|
+
marginTop: "4px",
|
|
183
|
+
marginBottom: "1px",
|
|
184
|
+
flexShrink: "0",
|
|
185
|
+
overflow: "hidden",
|
|
186
|
+
textOverflow: "ellipsis",
|
|
187
|
+
whiteSpace: "nowrap"
|
|
188
|
+
}), e.appendChild(i);
|
|
189
|
+
let a = document.createElement("webmapx-layer-legend");
|
|
190
|
+
a.setAttribute("layer-id", t), a.collapsible = !1, Object.assign(a.style, {
|
|
191
|
+
display: "block",
|
|
192
|
+
marginBottom: "6px",
|
|
193
|
+
flexShrink: "0"
|
|
194
|
+
}), e.appendChild(a), M.push(a);
|
|
195
|
+
}
|
|
196
|
+
N.appendChild(e);
|
|
197
|
+
}
|
|
198
|
+
j.appendChild(N);
|
|
199
|
+
let F = this.buildAttributionText();
|
|
200
|
+
if (F) {
|
|
201
|
+
let e = document.createElement("div");
|
|
202
|
+
e.textContent = F, Object.assign(e.style, {
|
|
203
|
+
flexShrink: "0",
|
|
204
|
+
textAlign: "left",
|
|
205
|
+
fontSize: "7px",
|
|
206
|
+
lineHeight: "1.4",
|
|
207
|
+
color: "#444",
|
|
208
|
+
fontFamily: "sans-serif",
|
|
209
|
+
paddingTop: "3px"
|
|
210
|
+
}), j.appendChild(e);
|
|
211
|
+
}
|
|
212
|
+
if (f) {
|
|
213
|
+
let e = document.createElement("div"), t = document.createElement("a");
|
|
214
|
+
t.href = window.location.href, t.textContent = window.location.href, e.appendChild(t), Object.assign(e.style, {
|
|
215
|
+
height: f + "px",
|
|
216
|
+
lineHeight: f + "px",
|
|
217
|
+
fontSize: "9px",
|
|
218
|
+
flexShrink: "0",
|
|
219
|
+
background: "white"
|
|
220
|
+
}), j.appendChild(e);
|
|
221
|
+
}
|
|
222
|
+
document.body.appendChild(j), M.length > 0 && (await Promise.all(M.map((e) => e.updateComplete ?? Promise.resolve())), await Promise.all(M.map((e) => e.updateComplete ?? Promise.resolve())), await Promise.all(M.map((e) => {
|
|
223
|
+
let t = e.shadowRoot ?? e, n = Array.from(t.querySelectorAll("img"));
|
|
224
|
+
return Promise.all(n.map((e) => e.complete ? Promise.resolve() : new Promise((t) => {
|
|
225
|
+
e.onload = () => t(), e.onerror = () => t();
|
|
226
|
+
})));
|
|
227
|
+
})));
|
|
228
|
+
let I = () => {}, L;
|
|
229
|
+
if (A) {
|
|
230
|
+
let e = t.core?.mapInstance;
|
|
231
|
+
if (!e) throw Error("MapLibre map not initialised.");
|
|
232
|
+
let r = e.unproject([D + k / 2, O + E.height / 2]), i = e.getZoom() + Math.log2(C / k), { default: a } = await import("maplibre-gl"), o = new a.Map({
|
|
233
|
+
container: P,
|
|
234
|
+
style: e.getStyle(),
|
|
235
|
+
center: r,
|
|
236
|
+
zoom: i,
|
|
237
|
+
bearing: e.getBearing(),
|
|
238
|
+
pitch: e.getPitch(),
|
|
239
|
+
interactive: !1,
|
|
240
|
+
attributionControl: !1
|
|
241
|
+
});
|
|
242
|
+
await new Promise((e, t) => {
|
|
243
|
+
let n = setTimeout(() => t(/* @__PURE__ */ Error("Map render timed out (30 s)")), 3e4);
|
|
244
|
+
o.once("idle", () => {
|
|
245
|
+
clearTimeout(n), e();
|
|
246
|
+
});
|
|
247
|
+
}), I = () => o.remove(), L = `
|
|
248
|
+
body > * { display: none !important; }
|
|
249
|
+
#webmapx-print-overlay { display: flex !important; position: fixed !important; top: 0 !important; left: 0 !important; }
|
|
250
|
+
#${n.id} > .webmapx-print-box { display: none !important; }`;
|
|
251
|
+
} else {
|
|
252
|
+
let e = C / k, t = c, r = c + l, i = T.width, a = T.height, o = O, s = i - D - k, u = a - O - E.height, d = D;
|
|
253
|
+
L = `
|
|
254
|
+
body > * { visibility: hidden !important; }
|
|
255
|
+
#${n.id} {
|
|
256
|
+
visibility: visible !important;
|
|
257
|
+
position: fixed !important; top: 0 !important; left: 0 !important;
|
|
258
|
+
width: ${i}px !important; height: ${a}px !important;
|
|
259
|
+
transform-origin: 0 0 !important;
|
|
260
|
+
transform: translate(${t}px,${r}px) scale(${e}) translate(${-D}px,${-O}px) !important;
|
|
261
|
+
clip-path: inset(${o}px ${s}px ${u}px ${d}px) !important;
|
|
262
|
+
}
|
|
263
|
+
#${n.id} * { visibility: visible !important; }
|
|
264
|
+
#${n.id} > .webmapx-print-box { display: none !important; }
|
|
265
|
+
webmapx-layout { display: none !important; }
|
|
266
|
+
#webmapx-print-overlay { display: flex !important; visibility: visible !important; position: fixed !important; top: 0 !important; left: 0 !important; background: transparent !important; }
|
|
267
|
+
#webmapx-print-overlay * { visibility: visible !important; }`;
|
|
268
|
+
}
|
|
269
|
+
let R = document.createElement("style");
|
|
270
|
+
R.id = "webmapx-print-style", R.textContent = `
|
|
271
|
+
@media print {
|
|
272
|
+
@page { size: A4 ${i ? "landscape" : "portrait"}; margin: 0; }
|
|
273
|
+
html, body { margin: 0 !important; padding: 0 !important; overflow: hidden !important; background: white !important; }
|
|
274
|
+
${L}
|
|
275
|
+
}`, document.head.appendChild(R), window.addEventListener("afterprint", () => {
|
|
276
|
+
R.remove(), I(), j.remove();
|
|
277
|
+
}, { once: !0 }), requestAnimationFrame(() => requestAnimationFrame(() => window.print()));
|
|
278
|
+
}
|
|
279
|
+
buildAttributionText() {
|
|
280
|
+
let e = this.layerDataConfig, t = this.store?.getState()?.mapLayers ?? {}, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
281
|
+
if (e) {
|
|
282
|
+
for (let t of e.sources ?? []) n.set(t.id, t);
|
|
283
|
+
for (let t of e.layers ?? []) r.set(t.id, t);
|
|
284
|
+
}
|
|
285
|
+
let s = /* @__PURE__ */ new Set(), c = [], l = (e) => {
|
|
286
|
+
if (e) for (let t of e.split("|")) {
|
|
287
|
+
let e = o(i(t)).trim();
|
|
288
|
+
e && !s.has(e) && (s.add(e), c.push(e));
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
for (let [e, i] of Object.entries(t)) {
|
|
292
|
+
if (i.visible === !1) continue;
|
|
293
|
+
let t = r.get(e);
|
|
294
|
+
if (t) l(a(t, n));
|
|
295
|
+
else {
|
|
296
|
+
let e = typeof i.sourceId == "string" ? i.sourceId : null;
|
|
297
|
+
e && l(this.adapter?.getSourceAttribution?.(e));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return c.join(" • ");
|
|
301
|
+
}
|
|
302
|
+
render() {
|
|
303
|
+
return l`
|
|
304
|
+
<div class="tool-content">
|
|
305
|
+
<p class="description">Position the map inside the box, then click Print to save as PDF.</p>
|
|
306
|
+
<div class="field">
|
|
307
|
+
<label for="print-title">Title</label>
|
|
308
|
+
<sl-input id="print-title" size="small" placeholder="Map title"
|
|
309
|
+
.value=${this.mapTitle}
|
|
310
|
+
@sl-input=${(e) => {
|
|
311
|
+
this.mapTitle = e.target.value, this.updateBox();
|
|
312
|
+
}}
|
|
313
|
+
></sl-input>
|
|
314
|
+
</div>
|
|
315
|
+
<div class="field">
|
|
316
|
+
<label for="print-format">Format</label>
|
|
317
|
+
<sl-select id="print-format" size="small" .value=${this.format}
|
|
318
|
+
@sl-change=${(e) => {
|
|
319
|
+
this.format = e.target.value, this.updateBox();
|
|
320
|
+
}}
|
|
321
|
+
>
|
|
322
|
+
<sl-option value="portrait">Portrait</sl-option>
|
|
323
|
+
<sl-option value="landscape">Landscape</sl-option>
|
|
324
|
+
<sl-option value="portrait_with_legend">Portrait with legend</sl-option>
|
|
325
|
+
<sl-option value="landscape_with_legend">Landscape with legend</sl-option>
|
|
326
|
+
</sl-select>
|
|
327
|
+
</div>
|
|
328
|
+
<sl-checkbox size="small"
|
|
329
|
+
?checked=${this.addLink}
|
|
330
|
+
@sl-change=${(e) => {
|
|
331
|
+
this.addLink = e.target.checked, this.updateBox();
|
|
332
|
+
}}
|
|
333
|
+
>Add viewer link</sl-checkbox>
|
|
334
|
+
${Math.abs(this.zoomDelta) > .05 ? l`
|
|
335
|
+
<p class="warning">
|
|
336
|
+
<strong>Note:</strong> The print zoom differs from the screen zoom
|
|
337
|
+
(${this.zoomDelta > 0 ? "+" : ""}${this.zoomDelta.toFixed(1)} levels).
|
|
338
|
+
Labels and zoom-dependent layers may look different in the print.
|
|
339
|
+
</p>` : ""}
|
|
340
|
+
${this.printing ? l`<div class="busy"><sl-spinner></sl-spinner> Rendering map…</div>` : l`<sl-button variant="primary" size="small" @click=${this.handlePrint}>Print</sl-button>`}
|
|
341
|
+
${this.errorMsg ? l`<p class="error">${this.errorMsg}</p>` : ""}
|
|
342
|
+
</div>
|
|
343
|
+
`;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
t([n()], S.prototype, "mapTitle", void 0), t([n()], S.prototype, "format", void 0), t([n()], S.prototype, "addLink", void 0), t([n()], S.prototype, "printing", void 0), t([n()], S.prototype, "errorMsg", void 0), t([n()], S.prototype, "zoomDelta", void 0), S = t([r("webmapx-print-tool")], S);
|
|
347
|
+
//#endregion
|
|
348
|
+
export { S as WebmapxPrintTool };
|