Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API autocomplete showing "Oops! Something went wrong."

I'm having a difficult time to use Google Places API autocomplete with a API key. In my production site, we are using it without a key, works perfectly until traffic reach the request limit. After some research, found out I will get higher request limit using a API key. However, after I added the key (even no restrictions), the address field in my form is disabled and showing "Oops! Something went wrong.".

Here is Google API URL I am using https://maps.googleapis.com/maps/api/js?key=[my_api_key]&libraries=places&callback=initAutocomplete

I was thinking it must be something wrong with my code. Then I use Google's official autocomplete sample code with my API key and no further modification, same result. Using it without a key always work.

Result and Key settings screenshot

I confused. I don't believe the code is wrong. Anyone can give me a hint?

like image 287
Rick Avatar asked Feb 06 '23 14:02

Rick


1 Answers

Found the problem. I enabled "Google Places API Web Service" in Google Developer. However, this is not enough. I have to enable "Google Maps JavaScript API" as well.

Thanks the reference to Google Maps API error: Google Maps API error: ApiNotActivatedMapError

like image 118
Rick Avatar answered Feb 08 '23 04:02

Rick