如何使用客户端 ID 和密钥访问 Google Maps JS API,而不是 API 密钥?

How can I use a client ID and secret to access the Google Maps JS API, instead of an API key?

我正在尝试通过 Google 的 JS 地图 API 将 Google 地图添加到我们的应用程序。我正在关注 the documentation here。我已经通过 yarn 安装了 @googlemaps/js-api-loader,现在正尝试实例化一个加载器:

import { Loader } from "@googlemaps/js-api-loader";
const loader = new Loader({
  // ???
})

问题是,文档告诉我在这个初始化程序中提供一个 API 键。但是我们不使用 API 密钥,我们使用这个项目的 app/client ID 和秘密。

我要如何使用 Google Maps JS API 以这种方式使用 ID 和密码,而不是 API 密钥?我看到 and this question, but neither actually tells you to do it. Also, this documentation 向您展示了如何在使用 <script> 标签时使用客户端 ID,但我更愿意通过 yarn 包加载。

有什么方法可以实现吗?

支持client参数。 https://googlemaps.github.io/js-api-loader/interfaces/loaderoptions.html#client

import { Loader } from "@googlemaps/js-api-loader";
const loader = new Loader({
  client
})

如果这不起作用,请在 https://github.com/googlemaps/js-api-loader

打开一个错误