Show correct building techs in search

This commit is contained in:
2026-05-25 14:57:06 +02:00
parent bfdcab8be3
commit adac2e04bb
2 changed files with 9 additions and 4 deletions

View File

@@ -37,18 +37,22 @@ export default class extends Controller {
const response = await fetch(`${GisState.apiUrl}/search?` + new URLSearchParams(body)); const response = await fetch(`${GisState.apiUrl}/search?` + new URLSearchParams(body));
const results = await response.json(); const results = await response.json();
console.warn(body);
this.containerTarget.classList.remove('is-hidden'); this.containerTarget.classList.remove('is-hidden');
this.#injectResults(results); this.#injectResults(results);
if (results.length) { if (results.length) {
// Reset zoom level after successful search // Reset zoom level after successful search
map.setZoom(INIT_ZOOM); map.setZoom(INIT_ZOOM);
this.#filterMap(results); this.#filterMap(results);
console.debug(results);
// Should technique always be shown after a search? // Should technique always be shown after a search?
for (const key of Object.keys(techsMarkers)) { for (const key of Object.keys(techsMarkers)) {
if (techsMarkers[key].options.label === body.technique) for (const record of results) {
map.addLayer(techsMarkers[key]); // Adjust for non-site records!!
if (techsMarkers[key].options.site === record.label)
map.addLayer(techsMarkers[key]);
}
} }
} }
} }

View File

@@ -140,6 +140,7 @@ GIS.buildingTechs = async function () {
techs.addLayer(marker); techs.addLayer(marker);
const markerLabel = `${record.coordinates[0]} ${record.coordinates[1]}`; const markerLabel = `${record.coordinates[0]} ${record.coordinates[1]}`;
marker.options.data = record; marker.options.data = record;
// Rename to include non-site relations??
marker.options.site = record.site?.label; marker.options.site = record.site?.label;
GisState.markers.buildingTechs[markerLabel] = marker; GisState.markers.buildingTechs[markerLabel] = marker;
} }