由于欧盟Cookie法,我试图以不使用Cookie的方式嵌入Google Map。
我想使用Embed API,因为它可以显示地点信息(评分,路线按钮...)。
我知道Maps JavaScript API不使用Cookie,并且可以通过maps.googleapis.com域工作。
但是,Maps Embed API使用www.google.com来设置NID cookie。
如果我尝试像这样替换网址
<iframe
width="600"
height="450"
frameborder="0" style="border:0"
src="https://maps.googleapis.com/maps/embed/v1/place?key=MY_API_KEY&q=Space+Needle,Seattle+WA" allowfullscreen>
</iframe>
有一个1s的闪光灯可以正确显示它,但是上面覆盖了“出了点问题”错误。
在控制台中,返回此错误:
Google Maps JavaScript API error: UnauthorizedURLForClientIdMapError
https://developers.google.com/maps/documentation/javascript/error-messages#unauthorized-url-for-client-id-map-error
Your site URL to be authorized: https://maps.googleapis.com/maps/embed/v1/place?key=MY_API_KEY&q=Space+Needle,Seattle+WA
是否可以使用没有Cookie的Embed API?
答案 0 :(得分:0)
您应该将 API_KEY 放在指定的位置。 iframe 中的 URL 包含“MY_API_KEY”,您应该将其替换为您从 Google Developer Console 获得的密钥。