Skip to content

Commit

Permalink
Only set loaded class after ‘load’ & ‘idle’ events
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Apr 28, 2019
1 parent 9207465 commit 4672a4d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ map.addControl(new mapboxgl.GeolocateControl({
map.addControl(new mapboxgl.NavigationControl());

let labelLayerId;
let mapLoaded = new Promise((res, rej) => map.once('load', res));

map.once('styledata', () => {
let mapLoaded = new Promise((res, rej) => map.once('load', () => {
map.once('idle', () => {
document.getElementById('map').classList.add('loaded');
});

res();
}));

map.once('styledata', () => {
const layers = map.getStyle().layers;
console.log(layers);

Expand Down

0 comments on commit 4672a4d

Please sign in to comment.