Search adjustments + building techs

This commit is contained in:
2026-05-24 16:21:33 +02:00
parent 487995366e
commit cb39695e6c
8 changed files with 83 additions and 5 deletions

View File

@@ -20,6 +20,14 @@ export default class extends Controller {
event.preventDefault();
const data = new FormData(event.target);
const body = {};
const map = GisState.map;
const techs = GisState.layers.buildingTechs;
const techsMarkers = GisState.markers.buildingTechs;
// Reset search for building techs...
for (const key of Object.keys(techsMarkers)) {
map.removeLayer(techsMarkers[key]);
}
for (const entry of data.entries()) {
body[entry[0]] = entry[1];
@@ -28,9 +36,18 @@ export default class extends Controller {
const response = await fetch(`${GisState.apiUrl}/search?` + new URLSearchParams(body));
const results = await response.json();
console.warn(body);
this.containerTarget.classList.remove('is-hidden');
this.#injectResults(results);
if (results.length) this.#filterMap(results);
if (results.length) {
this.#filterMap(results);
// Should technique always be shown after a search?
for (const key of Object.keys(techsMarkers)) {
if (techsMarkers[key].options.label === body.technique)
map.addLayer(techsMarkers[key]);
}
}
}
clearSearch() {