简体   繁体   English

Google Maps API密钥提醒

[英]Google Maps API Key alert

I have a problem with my Google Maps API key. 我的Google Maps API密钥存在问题。 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. 我收到一条警告,说“ This web site needs a different Google Maps API key. ”当我提示确定警报时,地图正在加载并正常工作。

The same problem is already posted: Google Maps API key not working 已发布相同的问题: Google Maps API密钥无效

I have tried to request the API key for both " http://www.domain.com " and " http://domain.com " but I still get the alert. 我曾尝试为“ http://www.domain.com ”和“ http://domain.com ”请求API密钥,但我仍然收到警报。 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:// 当我按照他们的FQA中的说明并使用alert(window.location.host)时,我得到www.domain.com但是api密钥生成器只接受域名,如果前缀是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. 我发现这是我的谷歌地图api脚本标签中的一个编码错误。 I got the alert error when I had a script tag like this: 当我有这样的脚本标记时,我收到了警告错误:

<script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=MyGoogleMapsApiKey" type="text/javascript"></script>

The problem here is the duplicated amp; 这里的问题是重复的amp; wich was generated from a scriptmanager in asp.net. 这是从asp.net的scriptmanager生成的。 So the & was replaced with &amp; 所以&被替换为&amp; .

The script tag should look like this: 脚本标记应如下所示:

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;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; 因此,如果您使用脚本管理器添加脚本标记或以任何其他方式动态地将脚本标记添加到您的页面,请为重复的amp; .

You have to sign up for the new google API key for your new domain, I used to get the same error message, because I use the old API with the new domain, please click the following link to register your new API key for the new domain. 您必须为新域注册新的Google API密钥,我以前会收到相同的错误消息,因为我使用新域的旧API,请点击以下链接为新域注册新的API密钥域。

http://code.google.com/apis/maps/signup.html http://code.google.com/apis/maps/signup.html

Hope this can help. 希望这可以提供帮助。

Vutha Vutha

I had the same problem. 我有同样的问题。 I remembered that Google calls my Appspot app by a different name found in the Versions area of the App Engine Dashboard. 我记得谷歌通过App Engine仪表板的“版本”区域中的其他名称来调用我的Appspot应用程序。 I changed the name of the URL to the long version and the key started to work... eg LIVE URI... http://5.latest.myappname.appspot.com . 我将URL的名称更改为长版本,并且密钥开始工作...例如LIVE URI ... http://5.latest.myappname.appspot.com

You'd think they could resolve their keys to their own app hosting service urls. 你认为他们可以解决他们自己的应用托管服务网址的密钥。

Regards, John 问候,约翰

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

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