9
<iframe width="100%" height="427" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=place_id:[place_id]&key=[my_key]" allowfullscreen></iframe>

"Google Maps Platform 拒绝了您的请求。此 IP、站点或移动应用程序无权使用此 API 密钥。从 IP 地址 xxx.xxx.xxx.xxx 收到请求,引用者:https ://xxx.xxx/ "

在 Google Dev 中,我启用了 Maps Embed API 和 Maps Static API。我已将密钥限制为仅与我的域一起使用,其中包含上述代码,例如https://[asterisk].thedomain.com/[asterisk]

当我不将密钥限制在这个单一域时,地图嵌入工作并且不会引发错误。

问题是,密钥在代码中是可读的,因此我需要将密钥限制在我的域中。

有任何想法吗?

谢谢你。

4

3 回答 3

3

我有问题的网站像https://thedomain.com/一样交付。

Google Maps Platform 确实在https://www.thedomain.com/https://thedomain.com/之间有所不同。

限制我的 APIhttps://thedomain.com/*为我工作,而https://*.thedomain.com/*并不意味着 * 什么都不是。

于 2018-06-22T08:19:54.203 回答
3

确保您已将“Maps Embeded API”添加到您正在使用的 API 密钥的密钥限制/api 限制部分。

于 2018-09-20T18:13:36.080 回答
1

如果你检查谷歌给出的例子,它是一个错误。它应该是:http://*example.com/* 而不是 http://*.example.com/* 因为如果您的域名之前没有类似 www 的东西,它将无法工作。

http://example.com不会工作,因为它没有.between //and example

于 2018-10-26T13:59:02.883 回答