Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've noticed that whenever I was using the Google Maps API recently it was displaying an error in the JavaScript console and the API was not functional. This seems to be due to Google forcing developers to use an API Key whenever they access their Maps API now. This change is not huge and is easy to implement so read on.

This is the kind of error I was seeing...
 JavaScript Concole
Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error


Google actually blogged about this change not long ago.
As of June 22, 2016 we are making the following changes to the Google Maps APIs Standard Plan:

* We no longer support keyless access (any request that doesn't include an API key). Future product updates are only available for requests made with an API key. API keys allow us to contact developers when required and help us identify misbehaving implementations.
...


Ok great, so you just have to get the key it seems! I noticed that requests for old URLs that have already accessed Maps API data worked, but any new URLs failed. In addition it looks like localhost access to the API doesn't work very well now, even when using a key.

So what you need to create is a browser key. Google has a page describing how to get the API key. If you click the 'Get a Key' button it will take you through the right steps.

First you will be asked to select a project or create a new one.

Then you're taken to the Credentials page where you can generate the key. It's a good idea to give this key a meaningful name as well as add a domain to restrict it to. If the key is unrestricted, other domains can make use of your key, which will reduce your quota allowances i.e. bad things will happen.
gmapsapikey1.png




After you click 'Create', your new API Key is presented to you.
gmapsapikey2.png


Making use of your key is easy...
 HTML
Old code like this...
<script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>
Becomes...
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=your_api_key_here"></script>


...simply replace 'your_api_key_here' with the actual value of your API Key.

As a bonus for any old URLs the 'no API key' warning will also disappear.

-i

Please leave your comments or feedback below!
comments powered by Disqus
Other posts you may like...
Hi! You can search my blog here ⤵
Or browse the recent top tags...

Recent Blog Posts

Using DeoxIT to repair old game catridges

WebLogic Maven Plugin - How to fix the MojoExecutionException: The artifact location was not specified

jPhotoFrame version 0.4 released with a whole new layout engine

Upcycling a couple of old broken lamps to create something amazing

A custom exception mapper and writer for a RESTful JAX-RS Jersey service

How to fix Plex error - Sorry there was a problem playing this item

Jersey JAX-RS filters and interceptors execution order for a POST request

Fix your Mac - users not showing on the macOS login screen when FileVault is enabled

BMB-012 Nanoblock T-Rex Skeleton Model assembly

Writing a custom MessageBodyReader to process POST body data with Jersey

Recent Galleries

BMB-012 Nanoblock T-Rex Skeleton Model assembly

Tiny Arcade revision 6 kit assembly and decal application

Atari Lynx repair - Part 5 - McWill LED screen mod installation

Atari Lynx repair - Part 4 - screen cover replacement

Atari Lynx repair - Part 2 - re-capping the motherboard

Atari Lynx repair - Part 3 - broken speaker replacement

Atari Lynx repair - Part 1 - introduction and case disassembly

Building a custom Atari Lynx game box storage shelf unit in a day

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

Monument Valley 2 is released and does not disappoint

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity