gpt4 book ai didi

angularjs - 如何在@agm/core 中为谷歌地图使用 api key 和客户端 ID?

转载 作者:行者123 更新时间:2023-12-05 06:35:37 24 4
gpt4 key购买 nike

我们使用 agm/core 包在我们的 Angular 应用程序中显示 Google map 。根据@agm/core 的可用文档,它只需要 apiKey。

AgmCoreModule.forRoot({
apiKey: 'xxxxxxxxxxxxx'
})

但是在我们的应用程序中,我们需要使用 Google map 的客户端 ID 和签名。有办法实现吗?

最佳答案

正如我在 AGM 的引用文档中看到的,LazyMapsAPILoaderConfigLiteral 也支持 clientId

https://angular-maps.com/api-docs/agm-core/interfaces/LazyMapsAPILoaderConfigLiteral.html#clientId

注意初始化接受LazyMapsAPILoaderConfigLiteral对象

static forRoot(lazyMapsAPILoaderConfig?: LazyMapsAPILoaderConfigLiteral): ModuleWithProviders

所以你可以这样写

AgmCoreModule.forRoot({
clientId: 'gme-xxxxxxxxxxxxx'
});

Google Maps JavaScript API 不使用加密 key 。它用于为 Web 服务请求创建数字签名。它永远不应该被公开,你只能在你的后端服务器上使用它来创建文档中描述的数字签名

https://developers.google.com/maps/documentation/geocoding/get-api-key#client-id

确保不要在您的客户端代码中公开加密 key 。

希望对您有所帮助!

关于angularjs - 如何在@agm/core 中为谷歌地图使用 api key 和客户端 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49668066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com