问题
I am trying to setup cesium and resium for react typescript and got stuck on the very initial steps. I am currently referencing steps from the following resium website, from here I have installed the packages and attempted to setup webpack based on the following steps. Based on the steps i installed the following package
- npm install copy-webpack-plugin html-webpack-plugin html-webpack-include-assets-plugin
- npm install cesium resium
The following example was also presented so i attempted to mimic the settings as much as possible creating and tweaking the following files in my root directory
- webpack.config.js
- package.json (Adding of scripts)
Once done I changed the following setting CESIUM_BASE_URL: JSON.stringify("/cesium")
in webpack.config.js
to point to my python server(https://localhost:5000
) for the necessary tiles.
With this I expected the error to at least go away or maybe even stating another error such as "Asset XXX not found". But the error stating DeveloperError: Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL
still persists.
I have also tried setting a variable for CESIUM_BASE_URL
in env.local
but it still doesn't work. Any pointers or guidance to any missing steps will be greatly appreciated.
回答1:
Add this script before others (or just before cesium) to your index.html
...
</body>
<script>
window.CESIUM_BASE_URL = 'https://localhost:5000/';
<script>
<script>
...
Resources:
https://cesium.com/blog/2016/01/26/cesium-and-webpack/#ive-already-got-webpack-set-up-just-tell-me-how-to-use-cesium
https://github.com/opensensorhub/osh-js/issues/55
来源:https://stackoverflow.com/questions/58990689/unable-to-determine-cesium-base-url-automatically-typescript