ol-cesium: Why doesn't ol-cesium import Cesium?
I’m trying to use ol-cesium inside a react app, built with create-react-app. When using ol-cesium, i get the Cesium is not defined error. I see the references to loading Cesium onto the window object, and i’ve tried importing Cesium in the root index.html, with no luck.
I’m trying to load it with:
<script type="text/javascript" src="node_modules/cesium/Build/Cesium/Cesium.js"></script>
I see the network tab load the .js, but its not globally available on the window object. So why doesn’t ol-cesium just import Cesium from cesium/Cesium’`. It seems like that would be a fairly standard way of loading the library (in addition to having a cesium dependency defined in package.json).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (6 by maintainers)
Unfortunately, I can’t get
ol-cesiumto run with theol-appeither. I have made the following:–> ol map is running fine, npm stopped.
npm i --save olcsThen extend the main.js file as follows:npm startThe 2D map can be displayed, but the following message fromOLCesium.js(from the NPM package itself) appears:Are there any further adjustments to be made there, so that ol-cesium is executable within the
create-ol-app?I am using
ol-cesiumin version 2.13 and have also run additionalnpm i cesium@1.82, but this also does not change the error message.@b4l8ter, Your use of ol-cesium is the standard one. Some people use ol-cesium, ol and CesiumJS as “old-fashioned” libs (no ES6 modules at all).
This is historical, “inject_ol_cesium.js” used to load OL, hence its name.