Search adjustments + building techs
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user