Giter Club home page Giter Club logo

worldwind-react-globe's Introduction

worldwind-react-globe

A 3D globe for React featuring maps, imagery and terrain plus 2D map projections using the Web WorldWind virtual globe SDK from NASA and ESA.

Demo

NPM JavaScript Style Guide

Install

npm install --save worldwind-react-globe

Usage

Example #1: Simple

Create a Globe using the defaults.

import React, { Component } from 'react'
import Globe from 'worldwind-react-globe'

class App extends Component {
  render () {
    return (
      <div>
        <Globe />
      </div>
    )
  }
}

Example #2: Normal

Creates a Globe that fills the page.

  • Adds layers to the Globe using layer type keys defined in Globe.layerTypes
  • Sets the startup latitude and longitude coordinates (in decimal degrees)and the eye/camera altitude (in meters)
App.js
import React, { Component } from 'react'
import Globe from 'worldwind-react-globe'
import './App.css'

export default class App extends Component {
  render() {

    const layers = [
      'eox-sentinal2-labels',
      'coordinates',
      'view-controls',
      'stars',
      'atmosphere-day-night'
    ];

    return (
      <div className='fullscreen'>
        <Globe 
          ref={this.globeRef}
          layers={layers}
          latitude={34.2}
          longitude={-119.2}
          altitude={10e6} 
        />
      </div>
    )
  }
}
App.css
.fullscreen {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

Example #3: More Complex

Creates a Globe that fills the page.

  • Adds layers to the Globe using layer type keys defined in Globe.layerTypes
  • Sets and changes the globe's latitude and longitude coordinates and the eye/camera altitude via the component's state.
  • Uses a ref object to get a references to the Globe
App.js
import React, { Component } from 'react'
import Globe from 'worldwind-react-globe'
import './App.css'

export default class App extends Component {
  constructor(props) {
    super(props)
    this.state = {
      lat: 34.2,
      lon: -119.2,
      alt: 10e6
    }
    this.globeRef = React.createRef();
  }

  render() {
    const layers = [
      'eox-sentinal2-labels',
      'coordinates',
      'view-controls',
      'stars',
      'atmosphere-day-night'
    ];
    return (
      <div className='fullscreen'>
        <Globe 
          layers={layers}
          latitude={this.state.lat}
          longitude={this.state.lon}
          altitude={this.state.alt} 
        />
      </div>
    )
  }
}
App.css
.fullscreen {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

Predefined Layer Types

Following is a list of the predefined layer type names available in Globe.layerTypes.

Key Value Description
blue-marble Blue Marble Blue Marble Next Generation (BMNG)
blue-marble-landsat Blue Marble and LandSat BMNG for oceans and seas with LandSat for land masses
blue-marble-lowres Background Blue Marble low-resolution background image
bing-aerial Bing Aerial Bing aerial imagery from Bing maps
bing-aerial-labels Bing Aerial with Labels Bing aerial imagery with road and place name labels from Bing maps
bing-roads Bing Roads Bing roads map from Bing maps
eox-sentinal2 EOX Sentinal-2 Sentinal 2 imagery from EOX IT Services GmbH
eox-sentinal2-labels EOX Sentinal-2 with Labels Sentinal 2 imagery with OpenStreetMap overlay from EOX IT Services GmbH
eox-openstreetmap EOX OpenStreetMap OpenStreetMap from EOX IT Services GmbH
usgs-topo USGS Topographic Topographic base map from the USGS
usgs-imagery-topo USGS Imagery Topographic Imagery and topographic base map from the USGS
renderables Renderables A general purpose layer for hosting shapes and markers
compass Compass A compass displayed in upper right
coordinates Coordinates View coordinates displayed on top or bottom of screen
view-controls View Controls View controls displayed in bottom left
atmosphere-day-night Atmosphere and Day/Night Atmosphere and day/night effects
stars Stars Background star field
tessellation Tessellation Shows terrain tessellation

License

MIT © Bruce Schubert

worldwind-react-globe's People

Contributors

combatvision avatar dependabot[bot] avatar emxsys avatar pjhogan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

worldwind-react-globe's Issues

Add props to control Globe settings

Consider:

  • enableAtmosphere
  • enableCompass
  • enableCoordinates
  • enableDayNight
  • enableStars
  • enableTessellation

Deprecate the use of the layers prop for establishing these settings.

Issue addding Renderable to renderableLayer

So I have one test project set up that takes in data from a websocket and display the location on a worldwindjs (vanillajs) map. I am now testing this library with this npm project and cannot figure out how to add a the location image to the map.

In the vanillajs implementation I am adding with (sudo code):

var renderableLayer = new WorldWind.RenderableLayer();
var location = new WorldWind.Position(lat, long, alt);
var placemark = new WorldWind.Placemark(location);

renderableLayer.addRenderable(placemark);

In the worldwind-react-globe project I console logged the globeRef and cannot find any prototype of the Object where I can call the WW.Position() or WW.Placemark() function to add a renderable.

Is this possible in the worldwind-react-globe? If so do you have examples of how to do this?

I have a renderable layer available for use and have verified its existence within the globeRef.

Thanks,

James

Add rotation prop to control the Globe's rotation speed and direction

Add a rotation prop (PropType.number) that controls the Globes rotation animation. The rotation value is a simple multiplier where 1 is one rotation in 24 hours, 2 is 2x, etc.

  • a value of 0 is no rotation (default)
  • values > 0 rotate the globe in the normal direction
  • values < 0 rotate the opposite direction
  • a value of 1 rotates one rotation in 24 hours

Improve category support for layers

Improve the support for layer categories :

  • The order addLayer is called should define the draw order of layers within their category. I.e., addLayer should add the layer to the end of its category, inserting it into the overall layer list if necessary.
  • A defaultCategories array should define the draw order of the categories themselves.

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

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
  }

Add an interface to replace the layer categories

Application may want to add custom categories and/or change the order of categories. Add a setter to allow the categories to be replaced.

  • Add a setter for categories property
  • Add a defaultCategory property

npm ERR! peer react@"^0.13.0 || ^0.14.0 || ^15.0.0 || ^16.0.0" from [email protected]

I am pretty new to react, what the heck is going on here?

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.13.0 || ^0.14.0 || ^15.0.0 || ^16.0.0" from [email protected]
npm ERR! node_modules/mobx-react
npm ERR!   peer mobx-react@"^5.1.2" from [email protected]
npm ERR!   node_modules/worldwind-react-globe
npm ERR!     worldwind-react-globe@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Add enableNavigation prop to Globe

Add the enableNavigation prop to the Globe to control whether the user can move the globe with mouse or touch gestures. The default value should be true.

Setting this prop to false would establish a static globe/map whose location can only be changed programmatically.

Simplify layer creation with string literals

Manifest an array of string literals for all the default layers available to the Globe. The individual layer names can be used by the developer to add layers to the Globe without having to traverse the WorldWind library to discover them on his or her own.

Add backgroundColor property to Globe

Add a backgroundColor property to the Globe so the background color can be set by the application. E.g.:

import React, { Component } from 'react'
import Globe from 'worldwind-react-globe'

class App extends Component {
    render () {
        return (
            <div>
                <Globe backgroundColor='rgb(36,74,101)' />
            </div>
        )
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.