javascript - Mapbox gl js draw multiple layers after map is loaded -


i have display many (~1 million) gps coordinates using mapbox gl js. have multiple sequential ajax requests take care of fetching data server. add layer map after each ajax request , have displayed immediately.

the problem if put code inside map.on('style.load', function() {}) event, map not displayed until last ajax call has terminated. have this:

function loaddata(finished) {     if (finished) {         return;     }     // ajax request , wait completion     // if last request, set finished = true     // call map.addsource()     // call map.addlayer()     // recursive call loaddata() }  map.on("style.load", function() {     loaddata(); }); 

do know solution problem?

i solved substituting map.on(...) call following:

function waitformaploaded() {     if(!map.loaded()) {         window.settimeout(waitformaploaded, 100);     } else {         loaddata();     } } waitformaploaded(); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -