Refactor with less awaits (WIP)

This commit is contained in:
2025-02-19 10:48:19 +01:00
parent 64af485a54
commit 13d6004fe8
3 changed files with 24 additions and 35 deletions

View File

@@ -132,10 +132,11 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
let layerVincoli = await this.loadLayer('vincoli.geojson', optionsVincoli);
let layerPaesistici = await this.loadLayer('paesistici.geojson', optionsPaesistici);
let markersGroup = await this.sitesMarkers(sitesGroup);
let notConservedGroup = await this.notConserved();
let findingsGroup = await this.findings();
let prehistoric = await this.prehistoric();
// Refactor with separate function...
this.sitesMarkers(sitesGroup).then(group => {group.addTo(map); window.Sites = group});
this.notConserved().then(group => {group.addTo(map); window.NotConserved = group});
this.findings().then(group => {group.addTo(map); window.Findings = group});
this.prehistoric().then(group => {group.addTo(map); window.Prehistoric = group});
const archeo = {
'Vincoli archeologici' : layerVincoli,
@@ -144,16 +145,7 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
// TEMP!! Remove point for Lo Pozzo...
sitesGroup.removeLayer(sitesGroup.customGetLayer('lopozzo'));
markersGroup.addTo(map);
sitesGroup.addTo(map);
notConservedGroup.addTo(map);
findingsGroup.addTo(map);
prehistoric.addTo(map);
window.Sites = markersGroup;
window.NotConserved = notConservedGroup;
window.Findings = findingsGroup;
window.Prehistoric = prehistoric;
L.control.layers(baseMap, archeo).addTo(map);
@@ -171,7 +163,7 @@ GIS.sitesMarkers = async function (sitesGroup) {
for (let id in MARKER_NAMES.sites) {
let layer = sitesGroup.customGetLayer(id);
let coords = layer.getBounds().getCenter();
let coords = layer?.getBounds().getCenter();
const fromStorage = localStorage.getItem(id);
let data = {};