相关疑难解决方法(0)

使用谷歌地图js API时是否需要隐藏API密钥?如果是这样,怎么样?

根据https://developers.google.com/maps/documentation/javascript/tutorial#HTML5,似乎我可以将以下标记添加到我的html并开始使用maps js API.

<script async defer
      src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
Run Code Online (Sandbox Code Playgroud)

但这将揭示我的API密钥.

在google上搜索并在stackoverflow上浏览答案后,我觉得可能没有必要隐藏此API密钥.我只需要在谷歌上创建API密钥时设置引用,如 /sf/answers/157941871/中所述

因此,即使其他人知道我的API密钥,他们也无法从其他域使用它.我对吗?

但Google表示您不应在代码中嵌入API密钥:https: //support.google.com/cloud/answer/6310037

那么,在使用谷歌地图js API时是否需要隐藏API密钥?如果是这样,怎么样?

更新:通过'API密钥',我的意思是浏览器API密钥.

html javascript google-maps google-maps-api-3

21
推荐指数
4
解决办法
1万
查看次数

标签 统计

google-maps ×1

google-maps-api-3 ×1

html ×1

javascript ×1