我们正在使用agm / core包在Angular应用程序中显示Google地图。 根据@ agm / core可用的文档,它只需要apiKey。
AgmCoreModule.forRoot({
apiKey: 'xxxxxxxxxxxxx'
})
但是在我们的应用程序中,我们需要使用Google地图的客户端ID和签名。有没有办法实现这个目标?
答案 0 :(得分:0)
正如我在AGM的参考文档中所看到的,LazyMapsAPILoaderConfigLiteral
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不使用加密密钥。它用于为Web服务请求创建数字签名。它永远不应该被披露,您只能在后端服务器上使用它来创建数字签名,如文档中所述
https://developers.google.com/maps/documentation/geocoding/get-api-key#client-id
请勿在客户端代码中公开加密密钥。
我希望这有帮助!