@edugis-org/webmapx 0.1.3 → 0.1.4

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.
@@ -0,0 +1,335 @@
1
+ //#region src/utils/dynamic-layout.ts
2
+ var e = {
3
+ layerTree: "webmapx-layer-tree",
4
+ search: "webmapx-search-tool",
5
+ measure: "webmapx-measure-tool",
6
+ settings: "webmapx-settings",
7
+ geolocation: "webmapx-geolocation-tool",
8
+ info: "webmapx-info-tool",
9
+ draw: "webmapx-draw-tool",
10
+ "view-mode": "webmapx-view-mode-tool",
11
+ "3d": "webmapx-3d-tool",
12
+ importLayer: "webmapx-import-layer-tool",
13
+ "import-layer": "webmapx-import-layer-tool",
14
+ layerOverview: "webmapx-layer-overview",
15
+ maplanguage: "webmapx-language-osmvector",
16
+ print: "webmapx-print-tool",
17
+ truearea: "webmapx-truearea-tool"
18
+ }, t = {
19
+ search: {
20
+ label: "Search",
21
+ icon: "search"
22
+ },
23
+ layerTree: {
24
+ label: "Catalog",
25
+ icon: "layers"
26
+ },
27
+ layers: {
28
+ label: "Catalog",
29
+ icon: "layers"
30
+ },
31
+ catalog: {
32
+ label: "Catalog",
33
+ icon: "layers"
34
+ },
35
+ datacatalog: {
36
+ label: "Catalog",
37
+ icon: "layers"
38
+ },
39
+ measure: {
40
+ label: "Measure",
41
+ icon: "rulers"
42
+ },
43
+ info: {
44
+ label: "Feature info",
45
+ icon: "info-circle"
46
+ },
47
+ draw: {
48
+ label: "Draw",
49
+ icon: "pencil"
50
+ },
51
+ geolocation: {
52
+ label: "Geolocation",
53
+ icon: "crosshair"
54
+ },
55
+ geolocate: {
56
+ label: "Geolocation",
57
+ icon: "crosshair"
58
+ },
59
+ "view-mode": {
60
+ label: "View mode",
61
+ icon: "globe"
62
+ },
63
+ "3d": {
64
+ label: "3D",
65
+ icon: "box"
66
+ },
67
+ importLayer: {
68
+ label: "Import layer",
69
+ icon: "file-earmark-arrow-up"
70
+ },
71
+ "import-layer": {
72
+ label: "Import layer",
73
+ icon: "file-earmark-arrow-up"
74
+ },
75
+ layerOverview: {
76
+ label: "Legend",
77
+ icon: "card-list"
78
+ },
79
+ legend: {
80
+ label: "Legend",
81
+ icon: "card-list"
82
+ },
83
+ settings: {
84
+ label: "Settings",
85
+ icon: "gear"
86
+ },
87
+ maplanguage: {
88
+ label: "Map language",
89
+ icon: "translate"
90
+ },
91
+ print: {
92
+ label: "Print",
93
+ icon: "printer"
94
+ },
95
+ truearea: {
96
+ label: "True Area",
97
+ icon: "bounding-box-circles"
98
+ }
99
+ }, n = {
100
+ scale: "webmapx-scale-control",
101
+ attribution: "webmapx-attribution-control",
102
+ coordinates: "webmapx-coordinates-tool",
103
+ navigation: "webmapx-navigation-control",
104
+ fullscreen: "webmapx-fullscreen-control",
105
+ zoomLevel: "webmapx-zoom-level",
106
+ spinner: "webmapx-spinner",
107
+ insetMap: "webmapx-inset-map",
108
+ maplanguage: "webmapx-language-osmvector"
109
+ }, r = [
110
+ {
111
+ id: "search",
112
+ label: "Search",
113
+ icon: "search"
114
+ },
115
+ {
116
+ id: "layerTree",
117
+ label: "Catalog",
118
+ icon: "layers"
119
+ },
120
+ {
121
+ id: "measure",
122
+ label: "Measure",
123
+ icon: "rulers"
124
+ },
125
+ {
126
+ id: "info",
127
+ label: "Feature info",
128
+ icon: "info-circle"
129
+ },
130
+ {
131
+ id: "draw",
132
+ label: "Draw",
133
+ icon: "pencil"
134
+ },
135
+ {
136
+ id: "geolocation",
137
+ label: "Geolocation",
138
+ icon: "crosshair"
139
+ },
140
+ {
141
+ id: "view-mode",
142
+ label: "View mode",
143
+ icon: "globe"
144
+ },
145
+ {
146
+ id: "3d",
147
+ label: "3D",
148
+ icon: "box"
149
+ },
150
+ {
151
+ id: "importLayer",
152
+ label: "Import layer",
153
+ icon: "file-earmark-arrow-up"
154
+ },
155
+ {
156
+ id: "layerOverview",
157
+ label: "Legend",
158
+ icon: "card-list"
159
+ },
160
+ {
161
+ id: "maplanguage",
162
+ label: "Map language",
163
+ icon: "translate"
164
+ },
165
+ {
166
+ id: "print",
167
+ label: "Print",
168
+ icon: "printer"
169
+ },
170
+ {
171
+ id: "truearea",
172
+ label: "True Area",
173
+ icon: "bounding-box-circles"
174
+ },
175
+ {
176
+ id: "settings",
177
+ label: "Settings",
178
+ icon: "gear"
179
+ },
180
+ {
181
+ id: "navigation",
182
+ label: "Navigation",
183
+ icon: "compass"
184
+ },
185
+ {
186
+ id: "scale",
187
+ label: "Scale bar",
188
+ icon: "rulers"
189
+ },
190
+ {
191
+ id: "coordinates",
192
+ label: "Coordinates",
193
+ icon: "crosshair2"
194
+ },
195
+ {
196
+ id: "fullscreen",
197
+ label: "Fullscreen",
198
+ icon: "fullscreen"
199
+ },
200
+ {
201
+ id: "zoomLevel",
202
+ label: "Zoom level",
203
+ icon: "zoom-in"
204
+ },
205
+ {
206
+ id: "attribution",
207
+ label: "Attribution",
208
+ icon: "info-circle"
209
+ },
210
+ {
211
+ id: "insetMap",
212
+ label: "Inset map",
213
+ icon: "map"
214
+ }
215
+ ];
216
+ function i(e) {
217
+ return e ? e === "3d" ? "3D" : e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase()) : "Tool";
218
+ }
219
+ function a(e) {
220
+ if (e) return typeof e == "string" ? { name: e } : e;
221
+ }
222
+ function o(e) {
223
+ let n = t[e.type ?? ""] ?? t[e.id ?? ""];
224
+ return {
225
+ label: e.label ?? e.title ?? n?.label ?? i(e.id ?? e.type),
226
+ icon: e.icon ?? n?.icon
227
+ };
228
+ }
229
+ function s(e) {
230
+ try {
231
+ if (!e.includes("://")) return !0;
232
+ let t = new URL(e, typeof window < "u" ? window.location.href : "http://localhost"), n = typeof window < "u" ? window.location.origin : "http://localhost";
233
+ return t.origin === n;
234
+ } catch {
235
+ return !1;
236
+ }
237
+ }
238
+ function c(e, t) {
239
+ let n = a(t);
240
+ if (!n) return !1;
241
+ let r = n.src;
242
+ return r && !s(r) && (console.warn(`[webmapx] Icon "src" blocked: cross-origin SVG URLs may contain executable code. Use a same-origin URL or a Shoelace named icon instead. Blocked: ${r}`), r = void 0), l(e, {
243
+ name: n.name,
244
+ library: n.library,
245
+ src: r
246
+ }), !!(n.name || r);
247
+ }
248
+ function l(e, t) {
249
+ for (let [n, r] of Object.entries(t)) r == null || r === !1 || e.setAttribute(n, r === !0 ? "" : String(r));
250
+ }
251
+ function u(t) {
252
+ let n = t.panel, r = document.createElement("webmapx-control-group");
253
+ l(r, {
254
+ slot: t.position,
255
+ orientation: t.orientation ?? "vertical",
256
+ "panel-position": n?.position ?? "after",
257
+ alignment: t.alignment ?? "start",
258
+ priority: t.priority ?? "normal"
259
+ });
260
+ let i = document.createElement("webmapx-toolbar");
261
+ l(i, {
262
+ "tooltip-placement": t.tooltipPlacement,
263
+ orientation: t.orientation
264
+ });
265
+ let a = document.createElement("webmapx-tool-panel");
266
+ n?.label && a.setAttribute("label", String(n.label));
267
+ let s = Array.isArray(t.items) ? t.items : [];
268
+ for (let t of s) {
269
+ if (t.enabled === !1) continue;
270
+ if (t.type === "spacer") {
271
+ let e = document.createElement("div");
272
+ e.style.flex = "1", e.style.pointerEvents = "none", i.appendChild(e);
273
+ continue;
274
+ }
275
+ let n = o(t), r = document.createElement("sl-button");
276
+ l(r, {
277
+ name: t.id,
278
+ size: "medium",
279
+ "data-tooltip": n.label
280
+ });
281
+ let s = document.createElement("sl-icon");
282
+ if (c(s, n.icon)) {
283
+ s.setAttribute("aria-hidden", "true"), r.appendChild(s);
284
+ let e = document.createElement("span");
285
+ e.style.cssText = "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", e.textContent = n.label, r.appendChild(e);
286
+ } else r.textContent = n.label;
287
+ i.appendChild(r);
288
+ let u = t.type ? e[t.type] : void 0;
289
+ if (u) {
290
+ let e = document.createElement(u);
291
+ e.setAttribute("tool-id", String(t.id)), e.setAttribute("label", n.label), n.icon && (e.icon = n.icon), a.appendChild(e);
292
+ }
293
+ }
294
+ return r.appendChild(i), r.appendChild(a), r;
295
+ }
296
+ function d(e, t) {
297
+ let r = n[e];
298
+ if (!r) return null;
299
+ let i = document.createElement(r);
300
+ switch (i.setAttribute("slot", String(t.position)), e) {
301
+ case "scale":
302
+ t.maxWidth !== void 0 && i.setAttribute("max-width", String(t.maxWidth)), t.margin && i.setAttribute("style", `--webmapx-tool-margin: ${t.margin}`);
303
+ break;
304
+ case "navigation":
305
+ t.direction && i.setAttribute("direction", String(t.direction)), t.orientation && i.setAttribute("orientation", String(t.orientation));
306
+ break;
307
+ case "insetMap":
308
+ t.zoomOffset !== void 0 && i.setAttribute("zoom-offset", String(t.zoomOffset)), t.minimizable && i.setAttribute("minimizable", "");
309
+ break;
310
+ case "maplanguage":
311
+ (t.visible === !1 || t.visible === 0) && i.setAttribute("hide-ui", ""), typeof t.language == "string" && i.setAttribute("language", t.language);
312
+ break;
313
+ }
314
+ return i;
315
+ }
316
+ function f(e, n) {
317
+ if (n) for (let [r, i] of Object.entries(n)) {
318
+ if (!i || typeof i != "object") continue;
319
+ let n = i;
320
+ if (n.enabled === !1) continue;
321
+ let a = t[r], o = a ? {
322
+ ...n,
323
+ label: n.label ?? a.label,
324
+ icon: n.icon ?? a.icon
325
+ } : n;
326
+ if (o.type === "toolbar") {
327
+ e.appendChild(u(o));
328
+ continue;
329
+ }
330
+ let s = d(r, o);
331
+ s && e.appendChild(s);
332
+ }
333
+ }
334
+ //#endregion
335
+ export { r as KNOWN_TOOLS, f as buildLayoutFromConfig };
@@ -5,115 +5,10 @@ import "./button-DFdGkRPQ.js";
5
5
  import "./checkbox-QoR4S8tV.js";
6
6
  import "./input-CeGntPlT.js";
7
7
  import "./divider-CPm675yY.js";
8
- import { LitElement as i, css as a, html as o } from "lit";
9
- //#region src/utils/dynamic-layout.ts
10
- var s = [
11
- {
12
- id: "search",
13
- label: "Search",
14
- icon: "search"
15
- },
16
- {
17
- id: "layerTree",
18
- label: "Catalog",
19
- icon: "layers"
20
- },
21
- {
22
- id: "measure",
23
- label: "Measure",
24
- icon: "rulers"
25
- },
26
- {
27
- id: "info",
28
- label: "Feature info",
29
- icon: "info-circle"
30
- },
31
- {
32
- id: "draw",
33
- label: "Draw",
34
- icon: "pencil"
35
- },
36
- {
37
- id: "geolocation",
38
- label: "Geolocation",
39
- icon: "crosshair"
40
- },
41
- {
42
- id: "view-mode",
43
- label: "View mode",
44
- icon: "globe"
45
- },
46
- {
47
- id: "3d",
48
- label: "3D",
49
- icon: "box"
50
- },
51
- {
52
- id: "importLayer",
53
- label: "Import layer",
54
- icon: "file-earmark-arrow-up"
55
- },
56
- {
57
- id: "layerOverview",
58
- label: "Legend",
59
- icon: "card-list"
60
- },
61
- {
62
- id: "maplanguage",
63
- label: "Map language",
64
- icon: "translate"
65
- },
66
- {
67
- id: "print",
68
- label: "Print",
69
- icon: "printer"
70
- },
71
- {
72
- id: "truearea",
73
- label: "True Area",
74
- icon: "bounding-box-circles"
75
- },
76
- {
77
- id: "settings",
78
- label: "Settings",
79
- icon: "gear"
80
- },
81
- {
82
- id: "navigation",
83
- label: "Navigation",
84
- icon: "compass"
85
- },
86
- {
87
- id: "scale",
88
- label: "Scale bar",
89
- icon: "rulers"
90
- },
91
- {
92
- id: "coordinates",
93
- label: "Coordinates",
94
- icon: "crosshair2"
95
- },
96
- {
97
- id: "fullscreen",
98
- label: "Fullscreen",
99
- icon: "fullscreen"
100
- },
101
- {
102
- id: "zoomLevel",
103
- label: "Zoom level",
104
- icon: "zoom-in"
105
- },
106
- {
107
- id: "attribution",
108
- label: "Attribution",
109
- icon: "info-circle"
110
- },
111
- {
112
- id: "insetMap",
113
- label: "Inset map",
114
- icon: "map"
115
- }
116
- ], c = new Set([
8
+ import { KNOWN_TOOLS as i } from "./dynamic-layout-DmLc5_yX.js";
9
+ import { LitElement as a, css as o, html as s } from "lit";
10
+ //#region src/components/webmapx-config-edit-tool.ts
11
+ var c = new Set([
117
12
  "configedit",
118
13
  "config-edit",
119
14
  "settings"
@@ -259,12 +154,12 @@ function f(e, t, n, r, i, a, o, s, l) {
259
154
  state: x
260
155
  };
261
156
  }
262
- var p = class extends i {
157
+ var p = class extends a {
263
158
  constructor(...e) {
264
159
  super(...e), this.toolEnabled = /* @__PURE__ */ new Map(), this.onlyActiveLayers = !1, this.removeUnsupported = !1, this.projectTitle = "", this.filename = "config.json";
265
160
  }
266
161
  static {
267
- this.styles = a`
162
+ this.styles = o`
268
163
  :host { display: block; padding: 0.75rem; box-sizing: border-box; min-width: 220px; }
269
164
  h4 { margin: 0 0 0.6rem; font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 0.4rem; }
270
165
  .section-label { font-size: 0.78rem; font-weight: 600; color: var(--sl-color-neutral-600); margin: 0.6rem 0 0.3rem; }
@@ -282,7 +177,7 @@ var p = class extends i {
282
177
  }
283
178
  loadFromConfig() {
284
179
  let e = this.mapElement?.config, t = /* @__PURE__ */ new Map();
285
- for (let { id: n } of s) c.has(n) || t.set(n, d(e ?? {}, n));
180
+ for (let { id: n } of i) c.has(n) || t.set(n, d(e ?? {}, n));
286
181
  this.toolEnabled = t;
287
182
  let n = e?.project;
288
183
  this.projectTitle = typeof n?.title == "string" ? n.title : "";
@@ -333,8 +228,8 @@ var p = class extends i {
333
228
  }).click(), URL.revokeObjectURL(h);
334
229
  }
335
230
  render() {
336
- let e = s.filter((e) => !c.has(e.id));
337
- return o`
231
+ let e = i.filter((e) => !c.has(e.id));
232
+ return s`
338
233
  <h4><sl-icon name="pencil-square"></sl-icon> Edit config</h4>
339
234
 
340
235
  <sl-input size="small" label="Project title" required
@@ -361,7 +256,7 @@ var p = class extends i {
361
256
 
362
257
  <div class="section-label">Visible tools:</div>
363
258
  <div class="tool-list">
364
- ${e.map((e) => o`
259
+ ${e.map((e) => s`
365
260
  <sl-checkbox
366
261
  ?checked=${this.toolEnabled.get(e.id) === !0}
367
262
  @sl-change=${(t) => this.toggle(e.id, t.target.checked)}>
@@ -3,7 +3,7 @@ import { t } from "./webmapx-base-tool-Dm9NAWLD.js";
3
3
  import { i as n, n as r, o as i } from "./decorators-B35AgiCU.js";
4
4
  import { css as a, html as o, nothing as s } from "lit";
5
5
  //#region src/utils/epsg-lookup-manager.ts
6
- var c = "https://cdn.jsdelivr.net/npm/@edugis-org/webmapx@0.1.3/public", l = 6e4, u = new class {
6
+ var c = "https://cdn.jsdelivr.net/npm/@edugis-org/webmapx@0.1.4/public", l = 6e4, u = new class {
7
7
  constructor() {
8
8
  this.worker = null, this.isReady = !1, this.isInitializing = !1, this.initPromise = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.requestCounter = 0, this.idleTimeout = null, this.idleTimeoutMs = l;
9
9
  }
@@ -26,9 +26,9 @@ var i = {
26
26
  "3d": () => import("./webmapx-3d-tool-D4CTD2gB.js"),
27
27
  truearea: () => import("./webmapx-truearea-tool-CMB4Orm-.js"),
28
28
  "view-mode": () => import("./webmapx-view-mode-tool-CUpLNjOj.js"),
29
- coordinates: () => import("./webmapx-coordinates-tool-CPC2mR5N.js"),
29
+ coordinates: () => import("./webmapx-coordinates-tool-Cygt5m-J.js"),
30
30
  settings: () => import("./webmapx-settings-DDEJ8aoV.js"),
31
- "config-edit": () => import("./webmapx-config-edit-tool-DCTyxqTk.js")
31
+ "config-edit": () => import("./webmapx-config-edit-tool-BgcSkmmg.js")
32
32
  };
33
33
  async function a(e) {
34
34
  await import("./webmapx-core-bundle-BDImi1RE.js"), await Promise.all(e.map((e) => {
@@ -1298,7 +1298,7 @@ function le(e, t) {
1298
1298
  }
1299
1299
  //#endregion
1300
1300
  //#region src/bootstrap/locale-loader.ts
1301
- var ue = "https://cdn.jsdelivr.net/npm/@edugis-org/webmapx@0.1.3/src/locales";
1301
+ var ue = "https://cdn.jsdelivr.net/npm/@edugis-org/webmapx@0.1.4/src/locales";
1302
1302
  async function $(e) {
1303
1303
  if (Z.hasResourceBundle(e, "webmapx")) {
1304
1304
  await Z.changeLanguage(e);
@@ -1316,7 +1316,11 @@ async function $(e) {
1316
1316
  }
1317
1317
  //#endregion
1318
1318
  //#region src/bootstrap/WebMapX.ts
1319
- var de = class {
1319
+ var de = {
1320
+ version: 8,
1321
+ sources: {},
1322
+ layers: []
1323
+ }, fe = class {
1320
1324
  static async mount(e, t) {
1321
1325
  let n = typeof t.config == "string" ? await fetch(t.config).then((e) => {
1322
1326
  if (!e.ok) throw Error(`[webmapx] Failed to load config: ${t.config}`);
@@ -1331,8 +1335,38 @@ var de = class {
1331
1335
  ]), n.locale && n.locale !== "en" && await $(n.locale);
1332
1336
  let o = document.querySelector(e);
1333
1337
  if (!o) throw Error(`[webmapx] Mount target not found: "${e}"`);
1334
- o.innerHTML = `<webmapx-map adapter="${i}"><webmapx-layout></webmapx-layout></webmapx-map>`, o.querySelector("webmapx-map").setConfig(n);
1338
+ o.innerHTML = `<webmapx-map adapter="${i}"><webmapx-layout></webmapx-layout></webmapx-map>`;
1339
+ let c = o.querySelector("webmapx-map"), l = n.map;
1340
+ c.setConfig({
1341
+ ...n,
1342
+ map: {
1343
+ type: i,
1344
+ center: [0, 0],
1345
+ zoom: 2,
1346
+ ...l
1347
+ }
1348
+ });
1349
+ let u = c.querySelector("webmapx-layout");
1350
+ if (u && u.childElementCount === 0 && n.tools) {
1351
+ let { buildLayoutFromConfig: e } = await import("./dynamic-layout-DmLc5_yX.js");
1352
+ e(u, n.tools);
1353
+ }
1354
+ let d = await c.getAdapterAsync?.();
1355
+ if (!d) {
1356
+ console.error("[webmapx] Adapter not available — check engine config.");
1357
+ return;
1358
+ }
1359
+ let f = l?.style ?? de, p = {
1360
+ center: l?.center ?? [0, 0],
1361
+ zoom: l?.zoom ?? 2,
1362
+ ...l?.bearing == null ? {} : { bearing: l.bearing },
1363
+ ...l?.pitch == null ? {} : { pitch: l.pitch },
1364
+ ...l?.minZoom == null ? {} : { minZoom: l.minZoom },
1365
+ ...l?.maxZoom == null ? {} : { maxZoom: l.maxZoom },
1366
+ ...typeof f == "string" ? { styleUrl: f } : { style: f }
1367
+ };
1368
+ d.initialize(e.replace(/^#/, ""), p);
1335
1369
  }
1336
1370
  };
1337
1371
  //#endregion
1338
- export { de as WebMapX, e as WebmapxBaseTool, t as WebmapxPluginTool, $ as changeLocale, Z as i18n, le as t };
1372
+ export { fe as WebMapX, e as WebmapxBaseTool, t as WebmapxPluginTool, $ as changeLocale, Z as i18n, le as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edugis-org/webmapx",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A modular web map UI with built-in adapters for MapLibre, OpenLayers, Leaflet, and Cesium.",
5
5
  "license": "ISC",
6
6
  "author": "Anne Blankert",