@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,437 @@
|
|
|
1
|
+
import { r as e, t } from "./decorate-CWgUV1hU.js";
|
|
2
|
+
import { t as n } from "./webmapx-base-tool-Dm9NAWLD.js";
|
|
3
|
+
import { i as r, o as i } from "./decorators-B35AgiCU.js";
|
|
4
|
+
import { css as a, html as o } from "lit";
|
|
5
|
+
//#region src/components/webmapx-search-tool.ts
|
|
6
|
+
var s, c = class extends n {
|
|
7
|
+
static {
|
|
8
|
+
s = this;
|
|
9
|
+
}
|
|
10
|
+
constructor(...e) {
|
|
11
|
+
super(...e), this.active = !1, this.mapElement = null, this.searchInputName = "wmx-7f3a9c1", this.query = "", this.results = null, this.searching = !1, this.selectedIndex = -1, this.previewSourceId = "search-preview", this.previewLayerIds = [
|
|
12
|
+
"search-preview-fill",
|
|
13
|
+
"search-preview-line",
|
|
14
|
+
"search-preview-point"
|
|
15
|
+
], this.previewLayersAdded = !1, this.persistCounter = 0, this.persistedMap = /* @__PURE__ */ new WeakMap(), this.cfg = {
|
|
16
|
+
endpoint: "https://nominatim.openstreetmap.org/search",
|
|
17
|
+
params: {
|
|
18
|
+
format: "geojson",
|
|
19
|
+
polygon_geojson: 1,
|
|
20
|
+
addressdetails: 1
|
|
21
|
+
},
|
|
22
|
+
maxResults: 15,
|
|
23
|
+
defaultZoom: 14,
|
|
24
|
+
marker: !1,
|
|
25
|
+
persistOnSelect: !1,
|
|
26
|
+
provider: "nominatim",
|
|
27
|
+
attribution: ""
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
randomColorHex() {
|
|
31
|
+
let e = Math.floor(Math.random() * 360) / 360, t = 50 / 100, n = (e, t, n) => (n < 0 && (n += 1), n > 1 && --n, n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e), r = 0, i = 0, a = 0;
|
|
32
|
+
{
|
|
33
|
+
let o = 1.2 - t * .7, s = 2 * t - o;
|
|
34
|
+
r = n(s, o, e + 1 / 3), i = n(s, o, e), a = n(s, o, e - 1 / 3);
|
|
35
|
+
}
|
|
36
|
+
let o = Math.round(r * 255), s = Math.round(i * 255), c = Math.round(a * 255), l = (e) => e.toString(16).padStart(2, "0");
|
|
37
|
+
return `#${l(o)}${l(s)}${l(c)}`;
|
|
38
|
+
}
|
|
39
|
+
static {
|
|
40
|
+
this.KNOWN_PROVIDERS = new Set(["nominatim"]);
|
|
41
|
+
}
|
|
42
|
+
isKnownProvider(e) {
|
|
43
|
+
return s.KNOWN_PROVIDERS.has(e.toLowerCase());
|
|
44
|
+
}
|
|
45
|
+
static {
|
|
46
|
+
this.styles = a`
|
|
47
|
+
:host { display: block; width: 100%; pointer-events: auto; }
|
|
48
|
+
:host([hidden]) { display: none !important; }
|
|
49
|
+
.container { width: 100%; max-width: 100%; color: var(--webmapx-search-color, var(--color-text-primary)); box-sizing: border-box; padding: var(--webmapx-tool-padding, 0); }
|
|
50
|
+
.searchbox { display:flex; gap:6px; align-items:center; }
|
|
51
|
+
input { flex:1; padding:6px; min-width:0; }
|
|
52
|
+
button { flex:0 0 auto; }
|
|
53
|
+
.results { margin-top:8px; max-height:50%; overflow:auto; }
|
|
54
|
+
.results ul { list-style: none; margin: 0; padding: 0; }
|
|
55
|
+
.result-item { padding:6px; border-bottom:1px solid rgba(0,0,0,0.05); cursor:pointer; display:flex; align-items:center; gap:8px; }
|
|
56
|
+
.result-item:hover, .result-item[selected] { background: rgba(0,0,0,0.03); }
|
|
57
|
+
.meta { font-size: small; color: var(--color-text-secondary); }
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
onMapAttached(t) {
|
|
61
|
+
super.onMapAttached(t), this.adapter = t, this.mapElement = e(this), this.subscribeToConfig();
|
|
62
|
+
}
|
|
63
|
+
onMapDetached() {
|
|
64
|
+
this.adapter = null, this.mapElement = null, this.unsubscribeFromConfig(), super.onMapDetached();
|
|
65
|
+
}
|
|
66
|
+
onConfigReady(e) {
|
|
67
|
+
let t = e?.tools?.search;
|
|
68
|
+
t && (this.cfg = {
|
|
69
|
+
...this.cfg,
|
|
70
|
+
...t
|
|
71
|
+
}), this.cfg.provider && !this.isKnownProvider(this.cfg.provider) && console.warn(`webmapx-search-tool: unknown provider "${this.cfg.provider}"`), !this.cfg.attribution && this.cfg.provider?.toLowerCase() === "nominatim" && (this.cfg.attribution = "© OpenStreetMap contributors | © Nominatim");
|
|
72
|
+
}
|
|
73
|
+
activate() {
|
|
74
|
+
this.active = !0, this.hidden = !1, setTimeout(() => {
|
|
75
|
+
(this.renderRoot?.querySelector("input"))?.focus();
|
|
76
|
+
}, 0), this.dispatchEvent(new CustomEvent("webmapx-search-opened", {
|
|
77
|
+
bubbles: !0,
|
|
78
|
+
composed: !0
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
deactivate() {
|
|
82
|
+
this.active = !1, this.results = null, this.query = "", this.selectedIndex = -1, this.hidden = !0, this.dispatchEvent(new CustomEvent("webmapx-search-closed", {
|
|
83
|
+
bubbles: !0,
|
|
84
|
+
composed: !0
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
onStateChanged(e) {}
|
|
88
|
+
async doSearch() {
|
|
89
|
+
let e = this.query.trim();
|
|
90
|
+
if (!e || e.length < 1) {
|
|
91
|
+
this.results = null;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let t = new URLSearchParams();
|
|
95
|
+
Object.entries(this.cfg.params || {}).forEach(([e, n]) => t.set(e, String(n))), t.set("q", e), t.set("limit", String(this.cfg.maxResults || 15));
|
|
96
|
+
let n = `${this.cfg.endpoint}?${t.toString()}`;
|
|
97
|
+
this.searching = !0;
|
|
98
|
+
try {
|
|
99
|
+
let e = await fetch(n);
|
|
100
|
+
if (!e.ok) console.error("search failed:", e.statusText), this.results = {
|
|
101
|
+
type: "FeatureCollection",
|
|
102
|
+
features: []
|
|
103
|
+
};
|
|
104
|
+
else {
|
|
105
|
+
let t = await e.json();
|
|
106
|
+
this.results = t;
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.error("search error", e), this.results = {
|
|
110
|
+
type: "FeatureCollection",
|
|
111
|
+
features: []
|
|
112
|
+
};
|
|
113
|
+
} finally {
|
|
114
|
+
this.searching = !1, this.dispatchEvent(new CustomEvent("webmapx-search-result", {
|
|
115
|
+
detail: this.results,
|
|
116
|
+
bubbles: !0,
|
|
117
|
+
composed: !0
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async handleKey(e) {
|
|
122
|
+
e.key === "Enter" ? await this.doSearch() : e.key === "ArrowDown" ? this.selectedIndex = Math.min((this.results?.features?.length ?? 0) - 1, Math.max(0, this.selectedIndex + 1)) : e.key === "ArrowUp" && (this.selectedIndex = Math.max(0, this.selectedIndex - 1));
|
|
123
|
+
}
|
|
124
|
+
getFeatureTitle(e) {
|
|
125
|
+
return (e.properties && (e.properties.display_name || e.properties.name)) ?? JSON.stringify(e.geometry?.type ?? "");
|
|
126
|
+
}
|
|
127
|
+
centerFeature(e) {
|
|
128
|
+
let t = null, n = e.bbox;
|
|
129
|
+
if (n && n.length === 4 && this.adapter) {
|
|
130
|
+
t = [(n[0] + n[2]) / 2, (n[1] + n[3]) / 2];
|
|
131
|
+
try {
|
|
132
|
+
if (typeof this.adapter.fitBounds == "function") {
|
|
133
|
+
this.adapter.fitBounds(n);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
} catch (e) {
|
|
137
|
+
console.warn("adapter fitBounds failed", e);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (e.geometry?.type === "Point") {
|
|
141
|
+
let n = e.geometry.coordinates;
|
|
142
|
+
t = [n[0], n[1]];
|
|
143
|
+
}
|
|
144
|
+
let r = e.properties && (e.properties.zoom || this.cfg.defaultZoom) || this.cfg.defaultZoom;
|
|
145
|
+
if (t && this.adapter) try {
|
|
146
|
+
this.adapter.setViewport(t, r);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
console.warn("setViewport failed", e);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
handleSelect(e) {
|
|
152
|
+
this.centerFeature(e);
|
|
153
|
+
let t = e.bbox ?? null;
|
|
154
|
+
this.dispatchEvent(new CustomEvent("webmapx-search-selected", {
|
|
155
|
+
detail: {
|
|
156
|
+
feature: e,
|
|
157
|
+
bbox: t,
|
|
158
|
+
center: null
|
|
159
|
+
},
|
|
160
|
+
bubbles: !0,
|
|
161
|
+
composed: !0
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
persistedChanged(e, t) {
|
|
165
|
+
this.dispatchEvent(new CustomEvent("webmapx-search-persist-change", {
|
|
166
|
+
detail: {
|
|
167
|
+
feature: e,
|
|
168
|
+
persisted: t
|
|
169
|
+
},
|
|
170
|
+
bubbles: !0,
|
|
171
|
+
composed: !0
|
|
172
|
+
})), this.requestUpdate();
|
|
173
|
+
}
|
|
174
|
+
isPersisted(e) {
|
|
175
|
+
return this.persistedMap.has(e);
|
|
176
|
+
}
|
|
177
|
+
addPersistedFeature(e) {
|
|
178
|
+
if (!this.adapter || !this.mapElement) return;
|
|
179
|
+
this.adapter;
|
|
180
|
+
let t = this.mapElement, n = null;
|
|
181
|
+
e.properties && (e.properties.osm_id || e.properties.osm_type) && (n = `search-persist-osm-${e.properties.osm_type ?? ""}-${e.properties.osm_id ?? ""}`), n ||= `search-persist-${Date.now()}-${this.persistCounter++}`;
|
|
182
|
+
let r = {
|
|
183
|
+
type: "FeatureCollection",
|
|
184
|
+
features: [e]
|
|
185
|
+
};
|
|
186
|
+
try {
|
|
187
|
+
let i = this.randomColorHex(), a = {
|
|
188
|
+
type: "geojson",
|
|
189
|
+
data: r
|
|
190
|
+
};
|
|
191
|
+
this.cfg.attribution && (a.attribution = this.cfg.attribution);
|
|
192
|
+
let o = { [n]: a }, s = e.geometry?.type, c = `${n}-fill`, l = `${n}-line`, u = `${n}-point`, d = this.getFeatureTitle(e);
|
|
193
|
+
s === "Polygon" || s === "MultiPolygon" ? t.addLayerRequest({
|
|
194
|
+
id: c,
|
|
195
|
+
type: "style",
|
|
196
|
+
sources: o,
|
|
197
|
+
layers: [{
|
|
198
|
+
id: "fill",
|
|
199
|
+
type: "fill",
|
|
200
|
+
source: n,
|
|
201
|
+
paint: {
|
|
202
|
+
"fill-color": i,
|
|
203
|
+
"fill-opacity": .25
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
id: "line",
|
|
207
|
+
type: "line",
|
|
208
|
+
source: n,
|
|
209
|
+
paint: {
|
|
210
|
+
"line-color": i,
|
|
211
|
+
"line-width": 2
|
|
212
|
+
}
|
|
213
|
+
}],
|
|
214
|
+
metadata: {
|
|
215
|
+
label: d,
|
|
216
|
+
hideFromLegend: !1
|
|
217
|
+
}
|
|
218
|
+
}) : s === "LineString" || s === "MultiLineString" ? t.addLayerRequest({
|
|
219
|
+
id: l,
|
|
220
|
+
type: "line",
|
|
221
|
+
source: n,
|
|
222
|
+
sources: o,
|
|
223
|
+
metadata: {
|
|
224
|
+
label: d,
|
|
225
|
+
hideFromLegend: !1
|
|
226
|
+
},
|
|
227
|
+
paint: {
|
|
228
|
+
"line-color": i,
|
|
229
|
+
"line-width": 3
|
|
230
|
+
}
|
|
231
|
+
}) : t.addLayerRequest({
|
|
232
|
+
id: u,
|
|
233
|
+
type: "circle",
|
|
234
|
+
source: n,
|
|
235
|
+
sources: o,
|
|
236
|
+
metadata: {
|
|
237
|
+
label: d,
|
|
238
|
+
hideFromLegend: !1
|
|
239
|
+
},
|
|
240
|
+
paint: {
|
|
241
|
+
"circle-color": i,
|
|
242
|
+
"circle-radius": 6
|
|
243
|
+
}
|
|
244
|
+
}), this.persistedMap.set(e, {
|
|
245
|
+
sourceId: n,
|
|
246
|
+
color: i
|
|
247
|
+
});
|
|
248
|
+
} catch (e) {
|
|
249
|
+
console.error("Failed to persist feature", e);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
removePersistedFeature(e) {
|
|
253
|
+
if (!this.adapter || !this.mapElement) return;
|
|
254
|
+
let t = this.adapter, n = this.mapElement, r = this.persistedMap.get(e);
|
|
255
|
+
if (!r) return;
|
|
256
|
+
let i = r.sourceId;
|
|
257
|
+
try {
|
|
258
|
+
try {
|
|
259
|
+
n.removeInlineLayer(`${i}-fill`);
|
|
260
|
+
} catch {}
|
|
261
|
+
try {
|
|
262
|
+
n.removeInlineLayer(`${i}-line`);
|
|
263
|
+
} catch {}
|
|
264
|
+
try {
|
|
265
|
+
n.removeInlineLayer(`${i}-point`);
|
|
266
|
+
} catch {}
|
|
267
|
+
try {
|
|
268
|
+
t.removeSource(i);
|
|
269
|
+
} catch {}
|
|
270
|
+
} catch (e) {
|
|
271
|
+
console.warn("Error removing persisted feature", e);
|
|
272
|
+
}
|
|
273
|
+
this.persistedMap.delete(e);
|
|
274
|
+
}
|
|
275
|
+
async showPreviewLayers(e, t) {
|
|
276
|
+
if (!this.adapter || !this.mapElement) return;
|
|
277
|
+
let n = this.adapter, r = this.mapElement;
|
|
278
|
+
try {
|
|
279
|
+
let t = n.getSource(this.previewSourceId);
|
|
280
|
+
t && typeof t.setData == "function" ? t.setData(e) : n.addSource(this.previewSourceId, {
|
|
281
|
+
type: "geojson",
|
|
282
|
+
data: e
|
|
283
|
+
});
|
|
284
|
+
} catch (e) {
|
|
285
|
+
console.warn("preview source update failed", e);
|
|
286
|
+
}
|
|
287
|
+
for (let e of this.previewLayerIds) n.hasLayer(e) && r.removeInlineLayer(e);
|
|
288
|
+
try {
|
|
289
|
+
await r.addLayerRequest({
|
|
290
|
+
id: this.previewLayerIds[0],
|
|
291
|
+
type: "fill",
|
|
292
|
+
source: this.previewSourceId,
|
|
293
|
+
filter: [
|
|
294
|
+
"in",
|
|
295
|
+
"$type",
|
|
296
|
+
"Polygon"
|
|
297
|
+
],
|
|
298
|
+
metadata: {
|
|
299
|
+
hideFromLegend: !0,
|
|
300
|
+
label: "Search preview fill"
|
|
301
|
+
},
|
|
302
|
+
paint: {
|
|
303
|
+
"fill-color": t?.fill ?? "#f1c40f",
|
|
304
|
+
"fill-opacity": .25
|
|
305
|
+
}
|
|
306
|
+
}), await r.addLayerRequest({
|
|
307
|
+
id: this.previewLayerIds[1],
|
|
308
|
+
type: "line",
|
|
309
|
+
source: this.previewSourceId,
|
|
310
|
+
filter: [
|
|
311
|
+
"in",
|
|
312
|
+
"$type",
|
|
313
|
+
"LineString",
|
|
314
|
+
"Polygon"
|
|
315
|
+
],
|
|
316
|
+
metadata: {
|
|
317
|
+
hideFromLegend: !0,
|
|
318
|
+
label: "Search preview line"
|
|
319
|
+
},
|
|
320
|
+
paint: {
|
|
321
|
+
"line-color": t?.line ?? "#f39c12",
|
|
322
|
+
"line-width": 3
|
|
323
|
+
}
|
|
324
|
+
}), await r.addLayerRequest({
|
|
325
|
+
id: this.previewLayerIds[2],
|
|
326
|
+
type: "circle",
|
|
327
|
+
source: this.previewSourceId,
|
|
328
|
+
filter: [
|
|
329
|
+
"==",
|
|
330
|
+
"$type",
|
|
331
|
+
"Point"
|
|
332
|
+
],
|
|
333
|
+
metadata: {
|
|
334
|
+
hideFromLegend: !0,
|
|
335
|
+
label: "Search preview point"
|
|
336
|
+
},
|
|
337
|
+
paint: {
|
|
338
|
+
"circle-color": t?.point ?? "#e67e22",
|
|
339
|
+
"circle-radius": 6
|
|
340
|
+
}
|
|
341
|
+
}), this.previewLayersAdded = !0;
|
|
342
|
+
} catch (e) {
|
|
343
|
+
console.warn("preview layers update failed", e);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
darkenHex(e, t = .15) {
|
|
347
|
+
let n = e.replace("#", "");
|
|
348
|
+
n.length === 3 && (n = n.split("").map((e) => e + e).join(""));
|
|
349
|
+
let r = parseInt(n.substring(0, 2), 16), i = parseInt(n.substring(2, 4), 16), a = parseInt(n.substring(4, 6), 16), o = (e) => Math.max(0, Math.min(255, Math.round(e * (1 - t)))), s = o(r), c = o(i), l = o(a), u = (e) => e.toString(16).padStart(2, "0");
|
|
350
|
+
return `#${u(s)}${u(c)}${u(l)}`;
|
|
351
|
+
}
|
|
352
|
+
clearPreview() {
|
|
353
|
+
if (!this.adapter || !this.mapElement) return;
|
|
354
|
+
let e = this.adapter, t = this.mapElement;
|
|
355
|
+
for (let n of this.previewLayerIds) e.hasLayer(n) && t.removeInlineLayer(n);
|
|
356
|
+
try {
|
|
357
|
+
e.removeSource(this.previewSourceId);
|
|
358
|
+
} catch {}
|
|
359
|
+
this.previewLayersAdded = !1;
|
|
360
|
+
}
|
|
361
|
+
showPreviewForFeature(e) {
|
|
362
|
+
let t = {
|
|
363
|
+
type: "FeatureCollection",
|
|
364
|
+
features: [e]
|
|
365
|
+
}, n = this.persistedMap.get(e), r = n?.color ? (() => {
|
|
366
|
+
let e = this.darkenHex(n.color, .18);
|
|
367
|
+
return {
|
|
368
|
+
fill: e,
|
|
369
|
+
line: e,
|
|
370
|
+
point: e
|
|
371
|
+
};
|
|
372
|
+
})() : void 0;
|
|
373
|
+
this.showPreviewLayers(t, r);
|
|
374
|
+
}
|
|
375
|
+
onResultCheckboxChange(e, t) {
|
|
376
|
+
try {
|
|
377
|
+
t.stopPropagation();
|
|
378
|
+
} catch {}
|
|
379
|
+
let n = t, r = !1;
|
|
380
|
+
r = n?.detail && typeof n.detail.checked == "boolean" ? n.detail.checked : !!t.target?.checked, r ? this.isPersisted(e) || (this.clearPreview(), this.addPersistedFeature(e), this.persistedChanged(e, !0)) : this.isPersisted(e) && (this.removePersistedFeature(e), this.persistedChanged(e, !1)), this.requestUpdate();
|
|
381
|
+
}
|
|
382
|
+
render() {
|
|
383
|
+
return o`
|
|
384
|
+
<div class="container tool-content">
|
|
385
|
+
<div class="title">Search</div>
|
|
386
|
+
<div class="searchbox">
|
|
387
|
+
<input
|
|
388
|
+
type="text"
|
|
389
|
+
name="${this.searchInputName}"
|
|
390
|
+
autocomplete="off"
|
|
391
|
+
autocorrect="off"
|
|
392
|
+
autocapitalize="off"
|
|
393
|
+
spellcheck="false"
|
|
394
|
+
placeholder="Search places and addresses"
|
|
395
|
+
.value="${this.query}"
|
|
396
|
+
@input="${(e) => {
|
|
397
|
+
this.query = e.target.value;
|
|
398
|
+
}}"
|
|
399
|
+
@keyup="${(e) => this.handleKey(e)}"
|
|
400
|
+
/>
|
|
401
|
+
<button @click="${() => this.doSearch()}">Go</button>
|
|
402
|
+
</div>
|
|
403
|
+
|
|
404
|
+
<div class="results">
|
|
405
|
+
${this.searching ? o`<div>Searching...</div>` : ""}
|
|
406
|
+
${this.results ? o`
|
|
407
|
+
<div style="display:flex; align-items:center; gap:8px; padding:2px 6px; font-size:11px; color:var(--color-text-secondary); border-bottom:1px solid var(--color-border);">
|
|
408
|
+
<span style="flex:0 0 auto; min-width:1.5rem; text-align:center;" title="Check to add result as a permanent layer on the map">📌</span>
|
|
409
|
+
<span>hover to preview · click to zoom</span>
|
|
410
|
+
</div>
|
|
411
|
+
<ul>
|
|
412
|
+
${(this.results.features || []).map((e, t) => o`
|
|
413
|
+
<li class="result-item" ?selected=${t === this.selectedIndex}
|
|
414
|
+
@mouseenter=${() => this.showPreviewForFeature(e)}
|
|
415
|
+
@mouseleave=${() => this.clearPreview()}>
|
|
416
|
+
<sl-checkbox
|
|
417
|
+
.checked=${this.isPersisted(e)}
|
|
418
|
+
@sl-change=${(t) => this.onResultCheckboxChange(e, t)}
|
|
419
|
+
@click=${(e) => e.stopPropagation()}
|
|
420
|
+
style="flex:0 0 auto;">
|
|
421
|
+
</sl-checkbox>
|
|
422
|
+
<div @click=${() => this.handleSelect(e)} style="flex:1; display:flex; justify-content:space-between; align-items:center; cursor:pointer;">
|
|
423
|
+
<strong>${this.getFeatureTitle(e)}</strong>
|
|
424
|
+
<span style="font-size:12px; color:var(--color-text-secondary);">${e.properties && (e.properties.type || e.properties.category) || ""}</span>
|
|
425
|
+
</div>
|
|
426
|
+
</li>
|
|
427
|
+
`)}
|
|
428
|
+
</ul>
|
|
429
|
+
` : o``}
|
|
430
|
+
</div>
|
|
431
|
+
</div>
|
|
432
|
+
`;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
t([r()], c.prototype, "query", void 0), t([r()], c.prototype, "results", void 0), t([r()], c.prototype, "searching", void 0), t([r()], c.prototype, "selectedIndex", void 0), c = s = t([i("webmapx-search-tool")], c);
|
|
436
|
+
//#endregion
|
|
437
|
+
export { c as WebmapxSearchTool };
|