Refactor with less awaits (WIP)
This commit is contained in:
@@ -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 = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user