Permalink
Browse files

Add camera management

  • Loading branch information...
markerikson committed Mar 2, 2017
1 parent 60eed65 commit 50af234084687896a045e2462a2d862dfdbc58b1
Showing with 19 additions and 3 deletions.
  1. +13 −2 src/App.js
  2. +6 −1 src/cesium/CesiumGlobe.jsx
View
@@ -17,16 +17,23 @@ class App extends Component {
{lat : 36.2, lon : -115.0, alt : 20000 },
{lat : 39.0, lon : -94.6, alt : 20000 },
{lat : 30.4, lon : -81.6, alt : 20000 },
- ]
+ ],
+ flyToLocation : null,
}
handleLeftClick = (coords) => {
console.log("Left mouse clicked at: ", coords)
}
+ handleFlyToClicked = () => {
+ this.setState({
+ flyToLocation : {lat : 32.6925, lon : -117.1587, alt : 100000}
+ });
+ }
+
render() {
- const {reactLogo, redsLogo, label, line} = this.state;
+ const {reactLogo, redsLogo, label, line, flyToLocation} = this.state;
const containerStyle = {
width: '100%',
@@ -49,11 +56,15 @@ class App extends Component {
labels={labels}
polylines={polylines}
onLeftClick={this.handleLeftClick}
+ flyToLocation={flyToLocation}
/>
<div style={{position : "fixed", top : 0}}>
<div style={{color : "white", fontSize: 40, }}>
Text Over the Globe
</div>
+ <button style={{fontSize : 40}} onClick={this.handleFlyToClicked}>
+ Jump Camera Location
+ </button>
</div>
</div>
@@ -10,6 +10,7 @@ const STK_TERRAIN_URL = "//assets.agi.com/stk-terrain/world";
import CesiumProjectContents from "./CesiumProjectContents";
import CesiumClickHandler from "./CesiumClickHandler";
+import CesiumCameraManager from "./CesiumCameraManager";
@@ -60,7 +61,7 @@ export default class CesiumGlobe extends Component {
if(viewerLoaded) {
const {scene} = this.viewer;
- const {icons, labels, polylines, onLeftClick} = this.props;
+ const {icons, labels, polylines, onLeftClick, flyToLocation} = this.props;
contents = (
<span>
@@ -74,6 +75,10 @@ export default class CesiumGlobe extends Component {
scene={scene}
onLeftClick={onLeftClick}
/>
+ <CesiumCameraManager
+ camera={scene.camera}
+ flyToLocation={flyToLocation}
+ />
</span>
);
}

0 comments on commit 50af234

Please sign in to comment.