Skip to content

Commit

Permalink
Add a simple React component that shows a Cesium billboard on the globe
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Apr 18, 2016
1 parent 5a1d6a3 commit 62ab019
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
20 changes: 16 additions & 4 deletions src/components/CesiumBillboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ import fireflyIcon from "styles/Firefly.png";
// A React component that manages some Cesium primitives
export default class CesiumBillboard extends Component {
componentDidMount() {
const {scene} = this.props;


this.billboards = new BillboardCollection();
}

addBillboard() {
this.billboards.add({
position : new Cesium.Cartesian3(1.0, 2.0, 3.0),
if(scene) {
scene.primitives.add(this.billboards);
}



this.billboard = this.billboards.add({
position : Cesium.Cartesian3.fromDegrees(-117.0, 35.0, 10000),
image : fireflyIcon
});
}
Expand All @@ -21,6 +28,11 @@ export default class CesiumBillboard extends Component {
}

componentWillUnmount() {
const {scene} = this.props;
if(scene) {
scene.primitives.remove(this.billboards);
}

this.billboards.destroy();
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/CesiumGlobe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ window.CESIUM_BASE_URL = "/cesium/";
import "assets/cesiumWidgets.css"
import cs from "cesiumDll/Cesium"

import CesiumBillboard from "./CesiumBillboard";



Expand All @@ -31,8 +32,12 @@ class CesiumGlobe extends Component {


render() {
const billboard = (this.viewer) ? <CesiumBillboard scene={this.viewer.scene} /> : null;

return (
<div className="cesiumWidget" ref="cesiumNode" />
<div className="cesiumWidget" ref="cesiumNode">
{billboard}
</div>

);
}
Expand Down

0 comments on commit 62ab019

Please sign in to comment.