<!-- We'll need to walk the DOM looking for a KmlTour later --> <script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"></script>
var tour = null;
// create the tour by fetching it out of a KML file
var href = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + '/';
href += 'static/grandcanyon_tour.kmz';
google.earth.fetchKml(ge, href, function(kmlObject) {
if (!kmlObject) {
// wrap alerts in API callbacks and event handlers
// in a setTimeout to prevent deadlock in some browsers
setTimeout(function() {
alert('Bad or null KML.');
}, 0);
return;
}
// Show the entire KML file in the plugin.
ge.getFeatures().appendChild(kmlObject);
// Walk the DOM looking for a KmlTour
walkKmlDom(kmlObject, function() {
if (this.getType() == 'KmlTour') {
tour = this;
return false; // stop the DOM walk here.
}
});
}); function enterTour() {
if (!tour) {
alert('No tour found!');
return;
}
ge.getTourPlayer().setTour(tour);
}
function playTour() {
ge.getTourPlayer().play();
}
function pauseTour() {
ge.getTourPlayer().pause();
}
function resetTour() {
ge.getTourPlayer().reset();
}
function exitTour() {
// just like setBalloon(null)
ge.getTourPlayer().setTour(null);
}