最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do folks put all these cool google maps examples on jsFiddle without disclosing their google API key? - Stack O

programmeradmin5浏览0评论

Take this example, for instance - /

It is a working google maps example, but the respective API key is not disclosed when examining the source code on jsFiddle.

I have a question to ask on google maps and for that I wish to make a jsFiddle example, but I just do not get how do I keep my google API key private?

Thanks.

Take this example, for instance - http://jsfiddle/pborreli/X5r8r/

It is a working google maps example, but the respective API key is not disclosed when examining the source code on jsFiddle.

I have a question to ask on google maps and for that I wish to make a jsFiddle example, but I just do not get how do I keep my google API key private?

Thanks.

Share Improve this question asked Apr 23, 2012 at 12:16 markmark 63k96 gold badges346 silver badges671 bronze badges 8
  • 3 Weren't API keys done away with in v3? – Jasper Commented Apr 23, 2012 at 12:18
  • I haven't noticed it. In my code I have a line like this: <script type="text/javascript" src="http://maps.googleapis./maps/api/js?key=***MY API KEY***&sensor=false&libraries=geometry&libraries=drawing"> </script> Please, tell me how to get rid of it. – mark Commented Apr 23, 2012 at 12:24
  • That fiddle you linked imports the JavaScript without any key. What happens when you try that? – Pointy Commented Apr 23, 2012 at 12:30
  • developers.google./maps/documentation/javascript/tutorial clearly states that a google API key must first be obtained. So, please, explain what do you mean? – mark Commented Apr 23, 2012 at 12:31
  • developers.google./maps/signup states that you no longer need an API key. – Lee Kowalkowski Commented Apr 23, 2012 at 12:31
 |  Show 3 more ments

2 Answers 2

Reset to default 7

The messages Google are sending on the matter of needing a key or not are a bit mixed and not very clear. However, I'll reconstruct the story for a bit, partly from memory, partly from what different parts of the website are saying and partly from other resources such as another question on this website (Whats the API Key for in Google Maps API V3?)

It all started when the API version 3 was introduced. Whereas version 2 used a key, they no longer felt the need to use a key, so the next version did not have one. One was now able to use the API without a key.

However, later on they changed some things such as allowing you to view your usage statistics and setting some extra limits such as the number of map loads one could do. This meant they were reintroduced keys. Keys could now be used to buy extra map loads, and the information you give when registering for a key, will allow Google to contact you when you are hitting your maximum map loads.

Because the key hadn't been necessary in the past, it couldn't bee so now without them changing the version of the API, as otherwise all application using the API would just break. As such, they continued allowing usage of the API without the key. Nevertheless, Google really wanted people to use API keys, so they worded things in such a way that it may seem that you do need one after all.

In some places traces of the lack of the API keys are to be found, but for some reason, Google choose not to tell the entire story and they don't tell the part where the API keys weren't there in the past, but are now.

Anyway, getting back to your question, you can just omit the API key.

The latest Google Maps Javascript API requires key, but you don't need a key for jsfiddle. Just add google maps js URL to the "External Resources":

https://maps.googleapis./maps/api/js

jsfiddle

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论