question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'Cesium is not defined' in ol-cesium npm module

See original GitHub issue

I’m trying to use the new 2.0 ol-cesium package in npm. I have the OpenLayers 5.0.0-beta13 installed, and the Cesium npm package. I’ve followed the Cesium webpack tutorial to get Cesium working. Both ol and Cesium work individually. However, when I add the following under the working ol code:

import OLCesium from 'ol-cesium'; const ol3d = new OLCesium({map: map});

I get the following runtime error:

ReferenceError: Cesium is not defined at new exports (olcesium.js?aa03:2464)

The line in question is:

this.scene_ = new Cesium.Scene(sceneOptions);

Is there something I need to do to allow ol-cesium to see Cesium? In an attempt to debug, I even added the line import Cesium from 'cesium/Cesium', which is what I use to import Cesium by itself. That didn’t work at all though.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
edieboldcommented, Jun 5, 2018

Okay, I’ve fixed my issue! For anyone else who runs into something like this:

I should have looked more closely at the example code- it wasn’t my config, but it was actually the changes to the ol import statements. For example, I originally had

import Map from 'ol/map';

but the imports need to look like this:

import Map from 'ol/Map.js';

I’d be lying if I said I understand why this distinction matters to ol-cesium and not ol by itself, but at least it’s all fixed now.

0reactions
edieboldcommented, Jun 4, 2018

Thanks @gberaudo, that example works great. There must be something wrong with my config somewhere. Hopefully this little demo repo will be useful to others as well though!

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - Problem with Cesium integration in OpenLayers 5
Ok, I've figured it out. I only needed to add script tag inside an index.html file that points to Cesium build. Example below:...
Read more >
Cesium is not defined
i'm trying to use cesium with openlayers Library but i get this error can you help me i'm using typescript for development that's...
Read more >
ol-cesium - npm
Start using ol-cesium in your project by running `npm i ol-cesium`. There is 1 other project in the npm registry using ol-cesium.
Read more >
Problem With Cesium Integration In Openlayers 5 - ADocLib
Problem With Cesium Integration In Openlayers 5 - Cesium Is Not Defined ... A convenient ES6 package olcs is available on npm. Features....
Read more >
openlayers - ImageWMS layer doesn't work in 3D mode
OLCesium ({ map: map, sceneOptions: { mapProjection: new Cesium. ... href="https://cdn.jsdelivr.net/npm/ol-cesium@2.11.3/css/olcs.css"> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found