58

In the older version of the API, I'd have to insert the javascript into the page using something like this for just basic functionality to work:

http://maps.google.com/maps?file=api&v=2&key=GoogleMapsAPIKey

Where I had to configure the API key for each individual site. Looking at the documentation, it says to get a basic map working I just need this:

http://maps.google.com/maps/api/js?sensor=true/false

Where does the API key fit in? Do I need to worry about it if I just plan on using a basic map and marker and none of the more advanced functions?

I'm also testing on localhost, but the FAQ says I still need to register a key for it, which I haven't done and it still works.

Seybsen
  • 14,989
  • 4
  • 40
  • 73
Brandon
  • 68,708
  • 30
  • 194
  • 223

5 Answers5

65

Whilst it is true that V3 of the Google Maps API does not require an API key, it is there for a reason. Google recently introduced the following usage limits:

Web sites and applications using each of the Maps API may at no cost generate:

  • up to 25,000 map loads per day for each API
  • up to 2,500 map loads per day that have been modified using the Styled Maps feature

In order to monitor usage an API key is necessary, as the developer notes make clear:

All Maps API applications should load the Maps API using an API key. Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. If your application's Maps API usage by exceeds the Usage Limits, you must load the Maps API using an API key in order to purchase additional quota.

So whilst you don't need to have an API key it is useful if you want to monitor your usage and also required if you buy additional usage quota.

keyser
  • 18,829
  • 16
  • 59
  • 101
Dan Diplo
  • 25,076
  • 4
  • 67
  • 89
  • could you check these 3 Questions please [Question 1](http://stackoverflow.com/questions/29846040/how-to-use-generated-key-in-google-maps) [Question 2](http://stackoverflow.com/questions/29571750/google-map-error-invalidkeyorunauthorizedurlmaperror) [Question 3](http://stackoverflow.com/questions/29411338/how-to-handle-over-query-limit/29412378) Am not able to handle Over Query Limit even after creating a key – Prabs Apr 30 '15 at 07:39
  • 1
    then what are the usage limits if we don't use an ApiKey ? – Oliboy50 Jul 22 '15 at 15:23
  • @Oliboy50 I believe the limits are identical for the API key and non-key users, the key simply allows you to monitor your usage and see whether you're getting close to the limits. – DBS Nov 12 '15 at 11:45
  • 2
    As of June 22, 2016 Google Maps V3 no longer supports keyless access. http://stackoverflow.com/a/37994162/982002 – Seybsen Jun 23 '16 at 14:22
  • 1
    It appears Google Maps once again supports access without an API key. Well, at least I can do it locally with no problem, but never tried on an actual web server. – Rafael Mar 19 '17 at 14:19
46

V3 of the Google Maps API does not require an API key. So you're good to go.

Edit: In the time since I answered this question Google released support for API keys in v3, letting you see usage of your API site in Google's developer console. The original answer is still accurate: API keys are not required, but they are now recommended.

Ossama
  • 2,417
  • 1
  • 20
  • 20
41

As of June 22, 2016 Google Maps V3 no longer supports keyless access so you need to get a key for every (referrer-)domain which has never had a Google Map on it before.

Get your key here: https://developers.google.com/maps/documentation/javascript/get-api-key

and append it to the URL of the script like so:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>

If you do not provide an API key you will see this warning instead of your rendered map:

Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details.

and your browser's console will tell you the reason:

Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

Seybsen
  • 14,989
  • 4
  • 40
  • 73
  • Although it might now be an official requirement to use an API key, it still seems to work without one right now. Does anyone have an idea when/if this will change in the future? – Tobias Aug 22 '16 at 14:35
  • 2
    If your domain has had a google map implementation before june 22nd it will work without key: _The new policies will apply immediately to all Maps API implementations created on or after June 22nd, 2016._ -- http://googlegeodevelopers.blogspot.de/2016/06/building-for-scale-updates-to-google.html – Seybsen Aug 22 '16 at 15:24
  • @Seybsen, without an API key google maps emit a *warning*, not an error: the API will continue to work, you will only see a log in the console: _If you receive only warnings without any errors, the API will work correctly on that page. But we recommend that you fix the potential issues as well._ You can read more on [the official documentation](https://developers.google.com/maps/documentation/javascript/error-messages#deverrorcodes) – Tilt Oct 24 '17 at 14:21
  • @Tilt you'll see the warning if you've had a Google Map on that domain before June 22, 2016, but you'll see the error (see screenshot above) if your domain is unknown to the Google Maps API. – Seybsen Oct 24 '17 at 14:26
  • @Seybsen: after looking at the screenshot and the docs you're definitely right, sorry :P Clearly, the domains I checked out where using a Google Map before June 22, 2016. – Tilt Oct 25 '17 at 07:45
  • how do i assign the key if i generate it all in code. ie. ```this.map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);``` – mewc Mar 14 '18 at 03:53
  • @mewc that’s the initialisation of your map. Loading the google maps script happens somewhere else in your code. Supply the key when loading the google maps js – Seybsen Mar 14 '18 at 06:46
0

Under Google Map's Api's choose Google Maps JavaScript API Enable the Api. Go to credentials section.Choose create Credentials. choose API Key from the popup,and then choose browser key from the proceeding popup. .

6.Replace the YOUR_API_KEY with your own api key obtained

Bakhtawar GIll
  • 407
  • 5
  • 16
-1

You can't use google maps in Android app unless you create a google map key. You need to use keytool to generate MD5 and use that to generate google map key on google map website. keytool should be located on your computer where you have sdk installed. I have generated developer google map key, and I have noticed that key is only good for developing Android app on that particular computer. If you are going to develop Android app on an another computer then you need to generate another google map key for that computer. If you don't see a google map on your Android app but rather you see a grid, this could mean that your google map key is invalid.

user1701556
  • 47
  • 2
  • 2
  • 8