Created
September 16, 2013 14:33
-
-
Save mramato/6581488 to your computer and use it in GitHub Desktop.
Cesium Sandcastle example of two synchronized Viewer widgets in a single application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE --> | |
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | |
<meta name="description" content="Use the Viewer Widget to start building new applications or easily embed Cesium into existing applications."> | |
<meta name="cesium-sandcastle-labels" content="Beginner"> | |
<title>Cesium Demo</title> | |
<script type="text/javascript" src="../Sandcastle-header.js"></script> | |
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.6/require.js"></script> | |
<script type="text/javascript"> | |
require.config({ | |
baseUrl : '../../../Source', | |
waitSeconds : 60 | |
}); | |
</script> | |
</head> | |
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html" data-sandcastle-title="Cesium + require.js"> | |
<style> | |
@import url(../templates/bucket.css); | |
</style> | |
<div id="cesiumContainerTop" class="top"></div> | |
<div id="cesiumContainerBottom" class="bottom"></div> | |
<div id="topToolbar"></div> | |
<div id="bottomToolbar"></div> | |
<script id="cesium_sandcastle_script"> | |
require(['Cesium'], function(Cesium) { | |
"use strict"; | |
var viewerTop = new Cesium.Viewer('cesiumContainerTop', { | |
timeline : false, | |
animation : false, | |
sceneMode : Cesium.SceneMode.SCENE2D, | |
useDefaultRenderLoop : false | |
}); | |
var viewerBottom = new Cesium.Viewer('cesiumContainerBottom'); | |
//Diable animation because we will manually be updating the clock | |
viewerTop.clock.animating = false; | |
//Slave the top widget's rendering to the bottom. | |
viewerBottom.clock.onTick.addEventListener(function(clock, currentTime) { | |
viewerTop.clock.currentTime = clock.currentTime; | |
viewerTop.clock.onTick.raiseEvent(viewerTop.clock); | |
viewerTop.resize(); | |
viewerTop.render(); | |
}); | |
//We have to add the data independantly to both widgets | |
var czmlDataSourceTop = new Cesium.CzmlDataSource(); | |
czmlDataSourceTop.loadUrl('../../CesiumViewer/Gallery/simple.czml').then(function() { | |
viewerTop.dataSources.add(czmlDataSourceTop); | |
}); | |
var czmlDataSourceBottom = new Cesium.CzmlDataSource(); | |
czmlDataSourceBottom.loadUrl('../../CesiumViewer/Gallery/simple.czml').then(function() { | |
viewerBottom.dataSources.add(czmlDataSourceBottom); | |
}); | |
Sandcastle.finishedLoading(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment