Cornelis de Jager
Cornelis de Jager

Reputation: 1

Google Maps Places API: TypeError: autocomplete is undefined

Whenever I am trying to use the Google Maps API places library it gives me this error in the console of my browser:

TypeError: autocomplete is undefined

If I'm not mistaken, that means the places library couldn't load. As for the code, I had my own code but I also copypasted the code from the Places API tutorial(https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform).

In my header I have these two lines included:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=MY_KEY_HERE"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

I also made sure Placis API, Google Maps JavaScript API v3 and Google Maps Geolocation API are all switched on in my Google APIs console.

I am not really sure what the problem is, besides the places library not loading. I should note I am working on a hidden subdomain, could that be the problem?

Thanks in Advance.

Upvotes: 0

Views: 5015

Answers (1)

webmonkey
webmonkey

Reputation: 1093

Please make sure you only load the maps file once (and you should always load the api via https, or with the active protocl):

<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=MY_KEY_HERE&libraries=places&sensor=false"></script>

The subdomain should not be a problem, so you can work with it.

Upvotes: 1

Related Questions