Just kick off the next load from your completion function.
something like (untested):
var kmlFiles = [<list of urls>];
var kmlObjects = [];
var kmlFileIx = 0;
function loadNextKml()
{
if (kmlFileIx >= kmlFiles.length) return;
window.google.earth.fetchKml(ge,kmlFiles[kmlFileIx], function(kml) {
kmlObjects[kmlFileIx++] = kml;
// other stuff
loadNextKml();
});
}
But there's no real need to force them to be sequential. You could
kick off all the loads, and then handle the completions in whatever
order they arrive.
var kmlFiles = [<list of urls>];
var kmlObjects = [];
function loadKmlFile(ix)
{
window.google.earth.fetchKml(ge, kmlFiles[ix], function(kml) {
kmlObjects[ix] = kml;
//other stuff
});
}
for (var i=0; i< kmlFiles.length;i++) {
loadKmlFile(i);
}