WorldWindEarth / worldwind-react-globe

A React component for interacting with the Web WorldWind virtual globe SDK from NASA and ESA
https://worldwind.earth/worldwind-react-globe/
MIT License
44 stars 19 forks source link

Add props to set the Globe's lat, lon and altitude #6

Closed emxsys closed 6 years ago

emxsys commented 6 years ago

Add optional React props to establish the globe's latitude, longitude, range and tilt. Also, a prop to indicate whether to animate a change in view.

E.g.:

  static propTypes = {
    lat: PropTypes.number, 
    lon: PropTypes.number,
    range: PropTypes.number,
    tilt: PropTypes.number,
    animateGoto: PropTypes.bool
  }
emxsys commented 6 years ago

Added the latitude, longitude and altitude props:


  static propTypes = {
    // ... 
    /**
     * Latitude +/-90 degrees
     */
    latitude: PropTypes.number,
    /**
     * Longitude +/-180 degrees
     */
    longitude: PropTypes.number,
    /**
     * Altitude in meters above sea level (MSL)
     */
    altitude: PropTypes.number,
    // ...
  }
emxsys commented 6 years ago

Example

export default class App extends Component {
  constructor(props) {
    super(props)
    this.state = {
      lat: 34.2,
      lon: -119.2,
      alt: 50e3
    }
  }

  render() {
    return (
        <div onClick={() => this.setState({lat: 45, lon: -75})} >
            <Globe 
                latitude={this.state.lat}
                longitude={this.state.lon}
                altitude={this.state.alt} 
                />
        </div>
    )
  }
}