从 img 标签加载时,Google 静态地图 API 禁止 403 [英] Google static map API getting 403 forbidden when loading from img tag

查看:29
本文介绍了从 img 标签加载时,Google 静态地图 API 禁止 403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张谷歌地图,它显示了一个房产的位置,但是当我来打印动态地图时,它的打印效果不太好,所以我决定实现谷歌静态地图图像 API.

http://lpoc.co.uk/properties-for-sale/property/oldgate-dairy-st-james-road-long-sutton-cambridgeshire-pe12/?prop-print=1>

^^ 是打印视图中的属性示例,应该显示静态地图图像,但无法加载并查看我的检查器,我收到图像的 403 Forbiden 响应.

但是如果我直接访问 URL,图像会加载...

我做错了什么?

谢谢

斯科特

解决方案

糟糕,我觉得自己像个白痴.我使用的是旧的 V2 地图 API URL 而不是新的 V3 API URL.我收到了 403,因为我在使用 V2 URL 时没有提供 API 密钥 :(

What I have is a Google map that shows the location of a property but when I come to print the dynamic maps dont print so good so I decided to implement the Google Static Map image API.

http://lpoc.co.uk/properties-for-sale/property/oldgate-dairy-st-james-road-long-sutton-cambridgeshire-pe12/?prop-print=1

^^ is an example of a property in print view and should show a static map image but it fails to load and looking at my inspector I'm getting a 403 Forbiden response for the image.

But if I go to the URL directly the image loads...

What am I doing wrong?

Thanks

Scott

解决方案

Oops I feel like such an idiot. I was using the old V2 maps API URL and not the new V3 API URL. I was getting a 403 because I was using the V2 URL without providing an API key :(

这篇关于从 img 标签加载时,Google 静态地图 API 禁止 403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆