The Lean Cheat Sheet for When You Can’t Avoid Plugins

Download the FREE Plugin Cheat Sheet: Proven lightweight picks to reduce page weight, boost speed, and streamline your WordPress stack.

Lean Plugin Cheat Sheet Preview

How to Fix Google Maps JavaScript API Errors

Seeing a Google Maps error on your site can be frustrating, but the fix is usually simple. Most issues almost always boil down to one of four things: your key, billing, restrictions, or missing APIs. Here’s the fast route to get Maps working again.

Step 1: Spot the error in your console

Open your site, press F12, and check the Console tab. Look for a code like:

  • InvalidKeyMapError → key missing or wrong.
  • ApiNotActivatedMapError → API not enabled.
  • RefererNotAllowedMapError → domain restrictions mismatch.
  • BillingNotEnabledMapError → billing not linked.

Once you know the code, you know the cure.

Step 2: Check your key is valid

In the Google Cloud Console, go to APIs & Services → Credentials. You should see an API key. Copy it into your site where the Maps script or plugin asks for it.

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

⚠️ Replace YOUR_API_KEY with the actual key from your Google Cloud Console.

No key showing? Create one. Wrong key in your site? Swap it out.

Step 3: Enable the right APIs

Still seeing errors? Head to APIs & Services → Library. At minimum, enable:

  • Maps JavaScript API (the core)
  • Any extras you actually use, like Places or Geocoding

This clears the ApiNotActivatedMapError. No need to tick everything, just what your site calls.

Step 4: Switch billing on

A map saying “For development purposes only” means billing isn’t active. Link a billing account under Billing → Overview, and double-check it’s tied to the same project as your key. That’s the only way past BillingNotEnabledMapError.

Step 5: Fix your restrictions

This one trips people up most.

1. Edit your API key in Google Cloud Console → Credentials.
2. Under Application restrictions, choose HTTP referrers (websites).
3. Add your site’s domain in two patterns to cover root + subdomains. For example, if your site is myshop.co.uk:

myshop.co.uk/*
*.myshop.co.uk/*

4. Save, wait a few minutes, then reload your map.
5. Under API restrictions, tick Maps JavaScript API (plus any extras you enabled).

Step 6: Update and test again

Drop the corrected key back into your site. Clear any caching plugin or CDN. Then reload with DevTools open. If you did the steps above, the error should vanish and your map should load.

While you’re at it, you can trim other scripts to keep things fast. Our guide on removing jQuery in WordPress shows how.

Step 7: Lock it down and keep it lean

A couple of quick after-care moves:

  • Rotate keys if you think an old one leaked.
  • Keep restrictions tight, never leave a key unrestricted.
  • For a lighter site, swap big interactive maps for a static preview or lazy-load iframe. You’ll save weight and carbon. See How to Load Google Maps Without Slowing Down a Site for step-by-step options.

Wrap-up

Google Maps errors look scary, but 90% of the time it’s just one of four quick fixes. Follow this checklist, retest, and your map will be back, loading cleanly, without weighing down the page.

Try it now: open your console, spot the error, and apply the matching step.

Profile photo of Neil Beckett

Neil Beckett

Neil is the founder of LeanWebs, with over ten years of experience in WordPress development. What started as a love for site speed turned into a mission to build faster, lighter, more sustainable websites.