ExpiredKeyMapError on newly generated API key

2019-02-17 23:38发布

问题:

I have just generated an API Key to enable us to display a Google map on our website but I'm getting the ExpiredKeyMapError. This is the exact same issue as this stackoverflow query from 8 months ago, but that has never received a solution: Google Maps ExpiredKeyMapError with recently created API Key

When the page first loads, the map shows for a split second and then it disappears, to be replaced with a grey box that says:

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

And when I pull up the console, this is the error message I get:

Google Maps API error: ExpiredKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#expired-key-map-error
SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status code 403, Forbidden

and that last line just keeps repeating.

Any help much appreciated because I have no idea how to solve this myself.

回答1:

I discovered that it was not working because I hadn't separately enabled the Google maps javascript API. Once I'd done that, the map started working a few minutes later.



回答2:

I had the same error after generating a new API key, but I had JavaScript API already enabled and everything correctly setup.

While searching for an answer and checking what else I can do, the key started to work. So every single time you create a new key, be patient and expect it to work within 1-8 minutes.