4

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?

Zulan
  • 21,896
  • 6
  • 49
  • 109
Rick
  • 121
  • 1
  • 4
  • it seems you have to authorize the full path, not only the domain. i am facing the same issue, my console.log shows "site to be authorized is domain.com/path/page.php. – mach May 26 '20 at 19:24

2 Answers2

8

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

Community
  • 1
  • 1
Rick
  • 121
  • 1
  • 4
0

In your Google API Manager -> Credentials, did you setup

enter image description here

You can also check your console, Google will tell you why "something went wrong".

Yanga
  • 2,885
  • 1
  • 29
  • 32
  • I did this setup already. It's in my attached screenshot. In console, there is nothing wrong as I can see. But the field become disabled after this call. maps.googleapis.com/maps/api/js/AuthenticationService.Authenticate?1shttps%3A%2F%2Fwww.pinkcherry.ca%2Fautocomplete-key.php&4sAIzaSyAh9yKs6I75Jbj0SaekamF9TV0E5a58p-o&callback=_xdc_._l4ycye&token=62969 It returns "/**/_xdc_._l4ycye && _xdc_._l4ycye( [0,11,0] )" which I don't know what it means. – Rick Dec 07 '16 at 19:02