Igor's Blog

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

, , ,
About — I'm an enthusiastic software engineer and consultant interested in many fields including J2EE, programming, electronics, 3D printing, video games, wood working and gardening.
See my Resume for more information.
The views expressed in this blog are my own and not those of my employer.
comments powered by Disqus
My other posts you may like...
Programming, DIY, Games, Hacks, Tech and more.
Follow me on...
Current and Past Projects
See my Resume

Subscribe


RSS Feed

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer

Recent Blog Posts

WebLogic package-name element classpath generator script

Using Jersey 2.x as a shared library on WebLogic 12.1.2

Google DFP with AdSense fallback is causing infinite scroll pages to go haywire

Workaround for Mobile Safari scrollTop() not updating during scroll

Skipping execution of Maven plugins that do not have a native skip option

Unmarshalling an XML fragment representing a JAXB object without XmlRootElement

Injecting a ContainerRequestContext into a Jersey entity provider class

Obfuscating PHP source code with Maven and YAK Pro PO

Making use of corner shelves with easy to make slide out draws

Octotree breaks GitLab Issue Boards

Recent Galleries

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

Good Friday Electronics fun Easter Bunny LED PCB Kit IBEABU-01.0

Top Categories

Blogs I follow

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth

Friends

RAWS Parts Online
Alpha Dimensions Hosting
Kristensen Photography
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Follow me on... 
     
...or subscribe for updates!

Don't show this again