无法自动确定铯基 URL (Typescript) [英] Unable to determine Cesium base URL automatically (Typescript)

查看:29
本文介绍了无法自动确定铯基 URL (Typescript)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 react typescript 设置 cesium 和 resium,但在最初的步骤中卡住了.我目前正在参考以下 resium 网站 中的步骤,从这里我已经安装了软件包并尝试设置webpack 基于以下步骤.根据我安装了以下软件包的步骤

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

还提供了以下 example 所以我试图模仿尽可能在我的根目录中创建和调整以下文件的设置

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(添加脚本)

完成后,我将 webpack.config.js 中的以下设置 CESIUM_BASE_URL: JSON.stringify("/cesium") 更改为指向我的 python 服务器(https://localhost:5000) 用于必要的图块.

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.

有了这个,我预计错误至少会消失,或者甚至可能会出现另一个错误,例如未找到资产 XXX".但错误指出DeveloperError:无法自动确定Cesium base URL,尝试定义一个名为CESIUM_BASE_URL的全局变量仍然存在.

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.

我也尝试在 env.local 中为 CESIUM_BASE_URL 设置一个变量,但它仍然不起作用.对任何缺失步骤的任何指示或指导将不胜感激.

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.

推荐答案

将此脚本在其他脚本之前(或在 cesium 之前)添加到您的 index.html

Add this script before others (or just before cesium) to your index.html

    ...
    </body>
    <script>
      window.CESIUM_BASE_URL = 'https://localhost:5000/';
    <script>
    <script>
    ...

资源:
https://cesium.com/blog/2016/01/26/cesium-and-webpack/#ive-already-got-webpack-set-up-just-tell-我如何使用铯https://github.com/opensensorhub/osh-js/issues/55

这篇关于无法自动确定铯基 URL (Typescript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆