简体   繁体   English

Google Staticmap 403错误

[英]Google Staticmap 403 error

while using staticmaps I always get 在使用静态地图时,我总能得到

Failed to load resource: the server responded with a status of 403 () 无法加载资源:服务器响应状态为403()

but I have no idea why. 但我不知道为什么。 I think my markup is correct but I think you guys can help me. 我认为我的标记是正确的,但我认为你们可以帮助我。

<img src="https://maps.googleapis.com/maps/api/staticmap?center=LATITUDE,LONGITUDE&zoom=15&size=160x90&markers=color:red|LATITUDE|LONGITUDE&key=KEY">

Thank you! 谢谢!

https://maps-generator.com/这将指导你,我认为新地图使用api密钥,该网站将引导出来

<img src="https://maps.googleapis.com/maps/api/staticmap?center=LATITUDE,LONGITUDE&zoom=15&size=160x90&markers=color:red|LATITUDE|LONGITUDE&key=KEY">

So where it says KEY you are supposed to put your API key. 所以在它说KEY你应该放置你的API密钥。 You can generate one here: https://console.cloud.google.com 您可以在此处生成一个: https//console.cloud.google.com

You need to find Google Maps Static. 您需要找到Google Maps Static。 Select it, enable it. 选择它,启用它。 Go to credentials and create an API key. 转到凭据并创建API密钥。 Then I would advise you to limit the API key by domain (http referrer) using the following URLs. 然后,我建议您使用以下URL按域(http referrer)限制API密钥。

*.YOURDOMAN.COM/*

YOURDOMAIN.COM/*

One in each box. 每个盒子一个。 Replace YOURDOMAIN.COM with your website address. 将YOURDOMAIN.COM替换为您的网站地址。 I hope that helps. 我希望有所帮助。

You also need to replace LATITUDe, LONGDITUDE with the correct values. 您还需要使用正确的值替换LATITUDe,LONGDITUDE。 The easiest way to find them is to do a Google Maps search and copy the URL. 找到它们的最简单方法是进行Google地图搜索并复制该网址。 They look something like: 它们看起来像:

https://www.google.co.uk/maps/place/Square+Balloon/@51.613498,0.0882521,15z/data=!4m5!3m4!1s0x0:0xec92c9ffe1ab887d!8m2!3d51.613498!4d0.0882521 https://www.google.co.uk/maps/place/Square+Balloon/@51.613498,0.0882521,15z/data=!4m5!3m4!1s0x0:0xec92c9ffe1ab887d!8m2!3d51.613498!4d0.0882521

The part you need is after the @ sign. 你需要的部分是在@符号之后。

@51.613498,0.0882521

51.613498 is the Latitude and 0.0882521 is the Longitude. 51.613498是纬度,0.0882521是经度。

Incidentally the other part after the Z is the Zoom. 顺便提一下,Z之后的另一部分是Zoom。 Which you can see in your URL as zoom=15. 您可以在URL中看到zoom = 15。 You can zoom in and out and copy that value too if you want. 如果需要,您也可以放大和缩小并复制该值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM