'Cesium is not defined' in ol-cesium npm module
See original GitHub issueI’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:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
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.
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!