问题
I have a KMZ file for GE plugin. This file have lots of PNG into, and several kml (poligons, lines, placemarks, etc).
The function to run this tour is:
function loadKmztour(href){
google.earth.fetchKml(ge, kmlURL, function(kmlObject) {
if (kmlObject){
ge.getFeatures().appendChild(kmlObject);
walkKmlDom(kmlObject, function(context) {
if (this.getType() == 'KmlTour') {
ge.getTourPlayer().setTour(this);
ge.getTourPlayer().play();
}
});
});
}
It runs well, but only the second time when I run the tour. When I run it for first time, it run only the tours but doesn't show the poligons, placemarks and png, but if I click the tour for second time, it work fine.
How can I force the kmz info to load at first time?
Thank you for any help. Best Regards, Shunsho.
UPDATE: Sometimes, the kmz poligons and placemarks load at the first time...but it work only sometimes...I think that maybe the tour started to run before the kmz is appended, so the problem is how I can force to wait the appendChild and then run the tour...Thanks!
回答1:
try to wait until the kml is loaded before playing the tour. I use this code:
var interval = setInterval(function wait() {
var streamingPercent = ge.getStreamingPercent();
if(streamingPercent > 98) {
ge.getTourPlayer().setTour(tour);
ge.getTourPlayer().play();
clearInterval(interval);
}
}
来源:https://stackoverflow.com/questions/13243301/appendchild-kmz-works-only-in-second-time-when-i-run-a-tour-tour-is-into-the-sa