1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| var ge;
var tour = null;
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCallback, failureCallback);
addSampleButton('Enter Tour', enterTour);
addSampleButton('Play', playTour);
addSampleButton('Pause', pauseTour);
addSampleButton('Stop/Reset', resetTour);
addSampleButton('Exit Tour', exitTour);
}
function initCallback(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
// add a navigation control
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
// add some layers
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
// create the tour by fetching it out of a KML file
var href = 'http://geraud.mazieres.free.fr/visite7kms.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;
}
// Walk the DOM looking for a KmlTour
walkKmlDom(kmlObject, function() {
if (this.getType() == 'KmlTour') {
tour = this;
ge.getTourPlayer().setTour(tour);
ge.getTourPlayer().play();
return false; // stop the DOM walk here.
}
});
});
document.getElementById('installed-plugin-version').innerHTML =
ge.getPluginVersion().toString();
}
function failureCallback(errorCode) {
}
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);
} |
Partager