Permalink
Browse files

Add mouse handling

  • Loading branch information...
markerikson committed Mar 2, 2017
1 parent ab9b68b commit 96c5223cf6ae3cc36ab0b6b500107509a77dfd38
Showing with 18 additions and 5 deletions.
  1. +10 −1 src/App.js
  2. +6 −2 src/cesium/CesiumGlobe.jsx
  3. +2 −2 src/cesium/primitives/CesiumPolyline.jsx
View
@@ -20,6 +20,10 @@ class App extends Component {
]
}
+ handleLeftClick = (coords) => {
+ console.log("Left mouse clicked at: ", coords)
+ }
+
render() {
const {reactLogo, redsLogo, label, line} = this.state;
@@ -40,7 +44,12 @@ class App extends Component {
return (
<div style={containerStyle}>
- <CesiumGlobe icons={icons} labels={labels} polylines={polylines} />
+ <CesiumGlobe
+ icons={icons}
+ labels={labels}
+ polylines={polylines}
+ onLeftClick={this.handleLeftClick}
+ />
<div style={{position : "fixed", top : 0}}>
<div style={{color : "white", fontSize: 40, }}>
Text Over the Globe
@@ -9,7 +9,7 @@ const BING_MAPS_KEY = "ApDPY15x9lCXO5Hw89M1G5Q84_BlKalPbjor8GvKGj2UAnVtzlT5UT-zr
const STK_TERRAIN_URL = "//assets.agi.com/stk-terrain/world";
import CesiumProjectContents from "./CesiumProjectContents";
-
+import CesiumClickHandler from "./CesiumClickHandler";
@@ -60,7 +60,7 @@ export default class CesiumGlobe extends Component {
if(viewerLoaded) {
const {scene} = this.viewer;
- const {icons, labels, polylines} = this.props;
+ const {icons, labels, polylines, onLeftClick} = this.props;
contents = (
<span>
@@ -70,6 +70,10 @@ export default class CesiumGlobe extends Component {
labels={labels}
polylines={polylines}
/>
+ <CesiumClickHandler
+ scene={scene}
+ onLeftClick={onLeftClick}
+ />
</span>
);
}
@@ -1,4 +1,4 @@
-import React, {Component} from "react";
+import {Component} from "react";
import Cartographic from "cesium/Source/Core/Cartographic";
import Color from "cesium/Source/Core/Color";
@@ -9,7 +9,7 @@ import {shallowEqual} from "utils/utils";
export default class CesiumPolyline extends Component {
componentDidMount() {
- const {polylines, coords} = this.props;
+ const {polylines} = this.props;
if(polylines) {
this.polyline = polylines.add({

0 comments on commit 96c5223

Please sign in to comment.