Google Maps API密钥提醒 [英] Google Maps API Key alert
问题描述
我的Google Maps API密钥存在问题。我收到一条警告:这个网站需要一个不同的Google Maps API密钥。
当我准备好警报时,地图加载并正常工作。
同样的问题已经发布:
Google Maps API密钥无法使用 我已尝试为 http://www.domain.com 和 http:// domain.com 但我仍然收到警报。
当我遵循他们的FQA中的指示并使用alert(window.location.host)时,我得到www.domain.com,但如果前缀是http://
有没有人有解决这个问题的方法?
解决方案我发现那是是我的谷歌地图api脚本标记中的一个generel编码错误。当我有这样的脚本标记时,我收到了警告错误:
< script src =http:// maps。 google.com/maps?file=api&amp;v=2&amp;key=MyGoogleMapsApiKeytype =text / javascript>< / script>
这里的问题是重复的 amp;
这是从asp.net中的scriptmanager生成的。因此&
被替换为& amp;
。
脚本标签应该如下所示:
< script src =http://maps.google.com / maps?file = api& amp; v = 2& amp; key = MyGoogleMapsApiKeytype =text / javascript>< / script>
因此,如果您使用脚本管理器添加脚本标记或以任何其他方式动态添加脚本标记您的网页,请扫描重复的 amp;
。
I have a problem with my Google Maps API key. I get an alert saying "This web site needs a different Google Maps API key.
" When I prees OK to the alert the map are loading and working fine.
The same problem is already posted: Google Maps API key not working
I have tried to request the API key for both "http://www.domain.com" and "http://domain.com" but I still get the alert. When I follow the instructions from their FQA and use alert(window.location.host) I get www.domain.com but the api key generator will only accept the domain if the prefix is http://
Does anyone have a solution to this?
I found out that is was a generel encoding error in my google maps api script tag. I got the alert error when I had a script tag like this:
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=MyGoogleMapsApiKey" type="text/javascript"></script>
The problem here is the duplicated amp;
wich was generated from a scriptmanager in asp.net. So the &
was replaced with &
.
The script tag should look like this:
<script src="http://maps.google.com/maps?file=api&v=2&key=MyGoogleMapsApiKey" type="text/javascript"></script>
So if you are using a scriptmanager to add script tags or in any other way dynamically adding script tags to your pages, wach out for duplicated amp;
.
这篇关于Google Maps API密钥提醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!