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
| const viewer = new Cesium.Viewer("cesiumContainer", { geocoder: false, homeButton: false, sceneModePicker: false, navigationHelpButton: false, navigationInstructionsInitiallyVisible: false, animation: false, timeline: false, fullscreenButton: false, skyBox: false, shouldAnimate: true, baseLayerPicker: false, }); viewer.cesiumWidget.creditContainer.style.display = "none";
const options = { camera: viewer.scene.camera, canvas: viewer.scene.canvas, };
let tour = null; viewer.dataSources .add( Cesium.KmlDataSource.load( "../SampleData/kml/eiffel-tower-flyto.kml", options, ), ) .then(function (dataSource) {
tour = dataSource.kmlTours[0]; tour.tourStart.addEventListener(function () { console.log("开始旅行"); });
tour.tourEnd.addEventListener(function (terminated) { console.log(`${terminated ? "游览终止" : "游览结束"} tour`); });
tour.entryStart.addEventListener(function (entry) { console.log(`开始播放:${entry.type} (时长:${entry.duration})`); });
tour.entryEnd.addEventListener(function (entry, terminated) { console.log(`${terminated ? "游览终止" : "游览结束"} ${entry.type}`); }); });
Sandcastle.addToolbarButton("开始(游览)", function () { tour.play(viewer.cesiumWidget); });
Sandcastle.addToolbarButton("终止(游览)", function () { tour.stop(); });
Sandcastle.reset = function () { viewer.dataSources.removeAll(); viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED; viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK; viewer.clock.multiplier = 2; };
|