Skip to content

eric79/cesium-react

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

cesium-react

Build Status npm version

React components for ๐ŸŒ Cesium

import React from "react";
import { Cartesian3 } from "cesium";
import { Viewer, Entity } from "cesium-react";

export default class Cesium extends React.PureComponent {

  render() {
    return (
      <Viewer full>
        <Entity
          name="tokyo"
          position={Cartesian3.fromDegrees(139.767052, 35.681167, 100)}
          point={{ pixelSize: 10 }}>
          test
        </Entity>
      </Viewer>
    );
  }

}

Screenshot

Available components:

  • <Viewer>
  • <CesiumWidget>
  • <Scene>
  • <Camera>
  • <Entity>
  • <CustomDataSource>
  • <CzmlDataSource>
  • <GeoJsonDataSource>
  • <KmlDataSource>
  • <Primitive>
  • <PointPrimitive>
  • <PointPrimitiveCollection>
  • <ScreenSpaceEvent>
  • <ScreenSpaceEventHandler>
  • <ScreenSpaceCameraController>
  • <ImageryLayer>
  • ...

Documentation

Sorry, no documents now.

Please refer to storybook and examples:

git clone https://github.com/rot1024/cesium-react.git
cd cesium-react
yarn

# run dev server for examples
yarn run examples:dev
# run storybook
yarn run storybook

Getting Started

Typical env: webpack + html-webpack-plugin

npm i cesium cesium-react --save
npm i html-include-assets-plugin --save-dev

webpack.config.js:

module.exports = {
  externals: {
    cesium: "Cesium"
  },
  output: {
    publicPath: "/"
    // ...
  },
  plugins: {
    new CopyPlugin([
      {
        from: `node_modules/cesium/Build/Cesium${prod ? "" : "Unminified"}`,
        to: "cesium"
      }
    ]),
    new HtmlIncludeAssetsPlugin({
      append: false,
      assets: [
        "cesium/Widgets/widgets.css",
        "cesium/Cesium.js"
      ]
    }),
    new webpack.DefinePlugin({
      "process.env": {
        NODE_ENV: JSON.stringify(opts && prod ? "production" : "development"),
        CESIUM_BASE_URL: JSON.stringify("/cesium")
      }
    })
    // ...
  }
  // ...
}

โš  Unconfirmed

After the article:

npm i cesium-react
module.exports = {
  // ...
  alias: {
    cesiumSource: "cesium",
    cesium: "cesium/Cesium"
  },
  // ...
}

Then replace as bellow:

import Color from "cesium/Core/Color";

to

import Color from "cesiumSource/Core/Color";

TODO

  • Implement other components (Model, EntityCollection, ParticleSystem, Cesium3DTileset ...)
  • Set up proper prop types
  • More unit tests
  • More documentation
  • More examples

Contributing

Welcome PRs and issues.

License

MIT License

About

React components for ๐ŸŒ Cesium

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.9%
  • HTML 0.1%