Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Take this example, for instance - http://jsfiddle.net/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.

like image 927
mark Avatar asked Jan 16 '23 21:01

mark


2 Answers

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 become 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.

like image 119
Jasper Avatar answered Jan 30 '23 18:01

Jasper


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.com/maps/api/js

jsfiddle

like image 39
Valery Viktorovsky Avatar answered Jan 30 '23 19:01

Valery Viktorovsky