Is anyone using cesium with Reactjs?

1,906 views
Skip to first unread message

Scott Haynes

unread,
Apr 21, 2016, 10:08:17 PM4/21/16
to cesium-dev
I was trying to load cesium into a react skeleton, and I was running into several issues.  I installed cesium with npm, but I couldn't get Cesium to load with require.  Plus I was exactly sure how to load cesium within a component, although I had several ideas that I thought would have worked.  I ended up getting the Viewer to load, but ran into a error deep down in the Viewer constructor( this._dataSourceAdded is not a function line 675 ).   After finding that error, I decided to load the CesiumWidget and I was able to finally get the load correctly.  I saw the information about Aditya Raisinghani's project, but it doesn't look like that project is open source.

Has anyone successfully loaded the cesium viewer into a react component?
Scott

Kevin Ring

unread,
Apr 21, 2016, 10:36:31 PM4/21/16
to cesiu...@googlegroups.com
Hi Scott,

The new user interface in Australia's NationalMap / TerriaJS uses React:

Our approach is to keep Cesium "outside" the React DOM so we don't have to fight it.  If React were to repeatedly create/destroy the Cesium window according to its component life cycle, that would be bad, but of course there are other ways to avoid that if you don't like our approach.

We also use our own fork of Cesium, published to npm as terriajs-cesium, that makes it easier to use with webpack and also fixes some minor things for our applications.

This is very much a work in progress, but let me know if you have questions.

Kevin

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Scott Haynes

unread,
Apr 22, 2016, 6:21:53 AM4/22/16
to cesium-dev
Thanks, wow this is a lot of work.

I'd like to see the newui running either locally or on the web.  I'm a little confused how to get the newui running locally.  I did pull down the newui for both nationalmap and terriajs so I've been able to look through the code.  Is the nationalmap the only example of using the ReactViews?  I see that http://nationalmap.gov.au/ is not using the newui.  

I just found the nationalmap wiki, so I'm reading through that now.  Thanks again, Scott

Kevin Ring

unread,
Apr 22, 2016, 7:08:08 AM4/22/16
to cesiu...@googlegroups.com
Hi,

You can try a running version here:

(no guarantee this is in a working state at all times, but we try)

The new UI is in heavy development at the moment, but the plan is to roll it out on nationalmap.gov.au in the next couple of months.  It will also be used by a bunch of other TerriaJS-based projects.

We're in the middle of a major doc overhaul, but the instructions here should be pretty good for building and running it locally:

The only thing I might add is that, if you're running with TerriaJS npm link'd, you should run npm install repeatedly until it stops installing stuff, first in the NationalMap folder and then in the TerriaJS folder.  npm is shockingly buggy when it comes to npm link. :(

Pop into our gitter if you have trouble.  

Kevin

Mark Erikson

unread,
Apr 22, 2016, 10:29:47 AM4/22/16
to cesium-dev
Yep, I'm in development on an application right now, and so far it's great.  See my thread at https://groups.google.com/forum/#!topic/cesium-dev/Ay7fbqDxyqw , and my sample project config over at https://github.com/markerikson/react-redux-cesium-testing-demo.  Feel free to ask if you have any questions on it.

Emmanuel Play or Die

unread,
Sep 13, 2016, 9:06:47 AM9/13/16
to cesium-dev
Greetings! Would you be so kind as to elaborate on how you were able to mitigate the 'this._dataSourceAdded is not a function' error? I'm encountering the same error when loading Cesium into a Drupal 7 project. Everything seems to function just fine, other than the dataSources.


Thanks!


Emmanuel

norman....@gmail.com

unread,
Nov 19, 2016, 8:13:08 AM11/19/16
to cesium-dev
Hi Kevin,

I'm in the same situation, must integrate multiple Cesium globes in a React app.

> Our approach is to keep Cesium "outside" the React DOM so we don't have to fight it.  If React were to repeatedly create/destroy the Cesium window according to its component life cycle, that would be bad, but of course there are other ways to avoid that if you don't like our approach.

Which other ways are you thinking of? Here are my initial ideas, but since I'm just starting the integration, none of them are yet tested:
https://github.com/CCI-Tools/cate-desktop/wiki/Cesium-React-Integration

Thanks!

Norman
Reply all
Reply to author
Forward
0 new messages