Fix async map ajax calls sequence

This commit is contained in:
2026-04-24 08:43:41 +02:00
parent 9e4fbe7ad4
commit 635b3781e3
3 changed files with 108 additions and 105 deletions

View File

@@ -186,16 +186,18 @@ export default {
if(!this.modeHisto) this.setFeedUpdateTimer(this.refreshRate);
},
async initMap() {
//Start async calls
const oMarkersPromise = this.spot.get2('markers', {id_project: this.currProject.id});
const oTrackPromise = this.spot.get2('geojson', {id_project: this.currProject.id});
//Get Map Info
const aoMarkers = await this.spot.get2('markers', {id_project: this.currProject.id});
const aoMarkers = await oMarkersPromise;
this.baseMap = null;
this.baseMaps = aoMarkers.maps;
this.markers.messages = aoMarkers.messages;
this.markers.medias = aoMarkers.medias;
this.lastUpdate = aoMarkers.last_update;
//console.log(this.baseMaps);
//Base maps (raster tiles)
let asSources = {};
let asLayers = [];
@@ -226,6 +228,7 @@ export default {
},
attributionControl: false
});
const oMarkerImagePromise = this.map.loadImage('images/footprint_mapbox.png');
//Force wait for load event
await new Promise((resolve) => {
@@ -237,7 +240,7 @@ export default {
this.baseMap = this.baseMaps.filter((asBM) => asBM.default_map)[0].codename;
//Get track
const oTrack = await this.spot.get2('geojson', {id_project: this.currProject.id});
const oTrack = await oTrackPromise;
this.map.addSource('track', {
'type': 'geojson',
'data': oTrack
@@ -267,7 +270,7 @@ export default {
});
//Markers
this.map.addImage('markerIcon', (await this.map.loadImage('images/footprint_mapbox.png')).data);
this.map.addImage('markerIcon', (await oMarkerImagePromise).data);
this.map.addSource('markers', {
type:'geojson',
data: {