Fix async map ajax calls sequence
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -181,11 +181,11 @@
|
||||
<span>{{ options.formatted_name }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<p v-else-if="options.type == 'poster'" class="message">
|
||||
<div v-else-if="options.type == 'poster'">
|
||||
<textarea ref="post" name="post" :placeholder="spot.lang('post_message')" class="autoExpand" rows="1" v-model="postMessage"></textarea>
|
||||
<input type="text" name="name" :placeholder="spot.lang('post_name')" v-model="user.name" />
|
||||
<spotButton name="submit" :aria-label="spot.lang('send')" :title="spot.lang('send')" :icon="'send'" @click="send()" :iconClasses="sending?'flicker':''" />
|
||||
</p>
|
||||
</div>
|
||||
<div v-else-if="options.type == 'archived'">
|
||||
<p><spotIcon :icon="'success'" /></p>
|
||||
<p>{{ spot.lang('mode_histo') }}</p>
|
||||
|
||||
Reference in New Issue
Block a user