简体   繁体   English

Google maps api无法加载地图图块

[英]Google maps api fails to load map tiles

I have google maps api v3 embedded into my website and it all worked fine up until a couple of weeks back. 我有谷歌地图api v3嵌入到我的网站,这一切都很好,直到几周前。 Within the last weeks, every now and then the map tiles (only the map, satellite tiles work fine all the time) fail to load for a couple of hours, sometimes days. 在最近几周内,地图图块(只有地图,卫星图块始终正常工作)不时加载几个小时,有时几天。 Along with that i get the following two 403 error messages: 除此之外,我得到以下两条403错误消息:

[Error] Failed to load resource: the server responded with a status of 403 
(Forbidden) (ViewportInfoService.GetViewportInfo, line 0)
http://maps.googleapis.com/maps/api/js/ViewportInfoService.GetViewportInfo

[Error] Failed to load resource: the server responded with a status of 403 
(Forbidden) (AuthenticationService.Authenticate, line 0)
http://maps.googleapis.com/maps/api/js/AuthenticationService.Authenticate

It seems like something with the authentication goes wrong. 看起来身份验证出错了。 However, i am nowhere near the maximum number of calls to the api per day. 但是,我远不及每天拨打api的最大数量。 Moreover, the map controls as well as the satellite tiles (when i switch over to them) load without problems. 此外,地图控件以及卫星图块(当我切换到它们时)加载没有问题。

The issue occurs randomly a few times a week for a couple of ours, up to an entire day. 这个问题每周几次随机发生几次,直到一整天。 Most of the time everything works fine. 大部分时间一切正常。

Has anybody experienced such issues before or any idea on what could be going wrong? 有没有人遇到过这样的问题,或者有什么可能出错的想法?

Update feb 2016: still dealing with the same problem 更新2016年2月:仍在处理同样的问题

Upon closer examination, it appears that every time after updating the website the map tiles work for a couple of days, before the 403 messages appear again. 仔细检查后,似乎每次更新网站后,地图图块都会工作几天,然后再次显示403条消息。

Usage statistics in the google developper console show that I barely ever exceed 100 requests per day, so usage limits should not be a problem at all. 谷歌开发者控制台中的使用情况统计数据显示,我每天几乎不会超过100个请求,因此使用限制应该不是问题。

By now I did request a new API key to see if that would help. 到目前为止,我确实请求了一个新的API密钥,看看这是否会有所帮助。 After I changed the key, like after a site update for a couple of days everything was working fine, however by now we are back at the same old situation 我改变了密钥之后,比如在网站更新几天之后一切正常,但是现在我们又回到了同样的旧情况

So, finally this seems to be solved. 所以,最后这似乎得到了解决。 It turns out that the problem was that I handled the included google maps javascript file with symfony's assetic. 原来问题是我用symfony的资产处理了包含的谷歌地图javascript文件。 This caused the file to be cached on my webserver, and served to my users from there, which in turn triggered google's security measures to prevent tile scraping, causing the 403 responses. 这导致文件缓存在我的网络服务器上,并从那里提供给我的用户,这反过来触发谷歌的安全措施,以防止瓦片刮,导致403响应。

The solution was very simpel, to use simple <script src=".."></script> tags instead of assetic's and twig's {% javascripts '..' %} tag. 解决方案非常简单,使用简单的<script src=".."></script>标签而不是assetic和twig的{% javascripts '..' %}标签。

Why this only caused problems with the map, and not with the satellite images, i have no idea! 为什么这只会导致地图问题,而不是卫星图像,我不知道!

Solved the same issue on GMaps API on WordPress site. 在WordPress网站上解决了GMaps API上的相同问题。

Issue was caused by aggressive caching. 问题是由积极的缓存引起的。

Purging W3 Total Cache solved the issue for now. 清除W3 Total Cache现在解决了这个问题。 Setting less aggressive caching policy should prevent the issue from happening again. 设置不太激进的缓存策略应该可以防止问题再次发生。

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

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