这个错误提示通常是因为在使用 Cesium 时没有提供正确的 API 密钥。Cesium 需要 API 密钥才能从 Google Maps 或 Bing Maps 等地图提供程序中获取地图图像。

如果您正在使用 Google Maps,可以通过以下方式获得 API 密钥:

  1. 前往 Google Cloud Console:https://console.cloud.google.com/
  2. 创建或选择一个项目。
  3. 在左侧菜单中选择 API 和服务 > 凭据。
  4. 在“创建凭据”下,选择 API 密钥。
  5. 您可以选择为此 API 密钥设置限制(例如,仅允许使用特定的 IP 地址或应用程序)。
  6. 复制 API 密钥并将其用作 Cesium 的 API 密钥。

如果您正在使用 Bing Maps,可以通过以下方式获得 API 密钥:

  1. 前往 Bing Maps 开发人员门户:https://www.bingmapsportal.com/
  2. 登录或创建一个账户。
  3. 选择“我的密钥”。
  4. 点击“创建新密钥”。
  5. 输入密钥名称并选择适当的 API 访问级别。
  6. 复制 API 密钥并将其用作 Cesium 的 API 密钥。

一旦您获得了正确的 API 密钥并将其提供给 Cesium,您应该能够正确加载地图图像并避免出现 'key is required to be a string or number' 的错误提示。

Cesium 错误提示:'key is required to be a string or number' 解决方法

原文地址: https://www.cveoy.top/t/topic/m6da 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录