Account for search result groups
This commit is contained in:
@@ -80,8 +80,6 @@ export default class extends Controller {
|
||||
const output = this.resultsTarget;
|
||||
output.innerHTML = '';
|
||||
|
||||
console.debug(results);
|
||||
|
||||
if (results.count === 0) {
|
||||
output.innerHTML = html`
|
||||
<p class="has-background-white-bis p-4 mt-0 has-text-centered">
|
||||
@@ -141,22 +139,23 @@ export default class extends Controller {
|
||||
*/
|
||||
#filterMap(results) {
|
||||
const map = GisState.map;
|
||||
const labels = [];
|
||||
results.sites.forEach(r => labels.push(r.label));
|
||||
|
||||
// Remove all layer groups first
|
||||
for (const key of Object.keys(GisState.layers)) {
|
||||
map.removeLayer(GisState.layers[key]);
|
||||
}
|
||||
|
||||
const sites = GisState.markers.sites;
|
||||
const markers = GisState.markers;
|
||||
|
||||
for (let key of Object.keys(sites)) {
|
||||
// If map has layers from previous search results...
|
||||
map.removeLayer(sites[key]);
|
||||
for (const label of labels) {
|
||||
if (sites[key].options.data.label === label) {
|
||||
map.addLayer(sites[key]);
|
||||
for (let group of Object.keys(results)) {
|
||||
for (let key of Object.keys(markers[group])) {
|
||||
// If map has layers from previous search results...
|
||||
map.removeLayer(markers[group][key]);
|
||||
|
||||
for (const result of results[group]) {
|
||||
if (markers[group][key].options.data.label === result.label) {
|
||||
map.addLayer(markers[group][key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user