Knowledge base / Billing & quota

Fix DeletedApiProjectMapError on Google Maps

Every Maps API key belongs to a Google Cloud project, and that project holds the billing link and the enabled APIs. If the project has been shut down, the key on your page has nothing behind it. You may be able to restore the project. If not, you need a new one.

How to tell this is your problem

  • The map loads grey with the “Oops! Something went wrong.” overlay for every visitor.
  • The console shows DeletedApiProjectMapError.
  • In Cloud Console, the project you remember using for Maps is missing from the project picker, or appears as pending deletion.
  • Someone recently tidied up old Cloud projects, left the organisation, or closed an agency account that owned the project.

This is what the console shows:

Google Maps JavaScript API error: DeletedApiProjectMapError
https://developers.google.com/maps/documentation/javascript/error-messages#deleted-api-project-map-error

Why it happens

Google's error reference says the API project may have been deleted from Cloud Console, and tells you to check whether the project that issued the key still exists.

When someone shuts down a Cloud project, Google immediately marks it for deletion and it becomes unusable. Billing and resource usage stop, and any linked Cloud Billing account is disconnected. The project then sits in a pending deletion state for 30 days before Google deletes it permanently. During those 30 days it can be restored.

The usual ways this happens:

  • A clean-up of unused projects. The Maps project had a vague name or no obvious owner, and someone shut it down.
  • A departing developer or agency. The project sat in someone else's account. When they left or closed the account, the project went with it.
  • An organisation change. Projects were removed during a move between Google Workspace or Cloud organisations.
  • The wrong project shut down. Two projects had similar names, and the one serving Maps was removed by mistake.

First, find out who owns the project

  1. 01Copy the key= value from the maps/api/js URL in your page source.
  2. 02In Cloud Console, open the project picker and check every project you can see under APIs & Services → Credentials for that key. If you find it in a live project, this isn't the cause. Recheck the console, because the code may be ApiProjectMapError instead.
  3. 03If you can't find it, ask whoever set up the map: a previous developer, an agency or a colleague. The project may be in an account you don't have access to.

Fix 1: restore the project (within 30 days)

You need permission to restore projects (the resourcemanager.projects.undelete permission, which project owners normally have).

  1. 01In Cloud Console, open the Manage resources page.
  2. 02If you belong to an organisation, select it in the project picker.
  3. 03Below the list of resources, select Resources pending deletion.
  4. 04Tick the project and select Restore, then confirm.
  5. 05Open the restored project's Billing page and link a billing account again. Google doesn't re-enable billing automatically when a project is restored, and it says you may need to wait a few hours before linking billing to a recently restored project.
  6. 06Check APIs & Services to confirm the Maps JavaScript API and any other APIs your site uses are enabled, and that your key and its restrictions are intact under Credentials.

From the command line, the equivalent is:

Shell
gcloud projects undelete PROJECT_ID

Until billing is linked again, expect BillingNotEnabledMapError rather than a working map. Our billing reactivation guide covers that step.

Fix 2: start again with a new project

If the 30 days have passed, or the project was in an account nobody can reach, create a fresh one. The old key can't be moved or recovered.

  1. 01In Cloud Console, create a new project under an account your organisation controls, such as a shared admin account, not a personal one.
  2. 02Link a billing account to it. Google Maps Platform needs an active billing account.
  3. 03Under APIs & Services, enable the Maps JavaScript API, plus any other Maps APIs your site uses, such as Places API or Geocoding API.
  4. 04Create an API key. Under its application restrictions choose Websites and add your domains. Under API restrictions choose Restrict key and select the APIs you just enabled.
  5. 05Replace the old key everywhere on your site: theme settings, maps plugins, page builder widgets and build configuration. See where page builders store the key.
  6. 06Clear page and CDN caches and reload the page in a private window.
Stop it happening again

Give the project a clear name, such as “Website maps (production)”, and add at least two owners from your own organisation. Set a budget alert and quota limits so a new key can't run up an unexpected bill. See how to cap Maps spend.

Confirm it is fixed

Reload the page with the console open. DeletedApiProjectMapError should be gone. If you restored the project and see BillingNotEnabledMapError, billing still needs linking. If you see RefererNotAllowedMapError, add your domain to the key's website restrictions.

Then run a scan. It loads the page from a clean session and reports the Maps errors it finds, so you can confirm visitors get a working map and not a cached copy of the broken one.

Common questions

How long do I have to restore a deleted Google Cloud project?

Google keeps a shut-down project in a pending deletion state for 30 days. After that it is permanently deleted and can't be restored.

Will restoring the project bring my API key back?

The key belongs to the project, so restoring the project should bring it back with it. Check it under Credentials, and re-link billing, because Google doesn't re-enable billing on restore.

Can I move my old key to a new project?

No. Keys can't be moved between projects. A new project needs a new key, and you have to update your site to use it.

Why is this listed under billing?

Shutting down a project disconnects its billing account, and restoring it leaves billing switched off. Most of the work after a restore is getting billing linked again.

Check whether this is your error

A scan tells you in about twelve seconds, from a clean session.

Related articles