mardi 30 mai 2017

"Google is not defined" error - Trying to create infowindow Google Maps

In Google Maps API, I want to create an infowindow everytime I place a marker (markers all stored in an array).
When declaring the infowindow:

var infowindow = new google.maps.InfoWindow();

I get the error 'google is not defined'.

This only stops if I move this line of code inside the function that creates markers, but then I would be creating the variable infowindow everytime I placed a marker which I understand is bad practice?

I would prefer to declare infowindow at the start of my JS, and then just use it everytime a marker is placed.
I couldn't find anything that helped from the other answers on SO, I've tried reordering the JS files but nothing as worked so far.

Any tips would be welcome




Aucun commentaire:

Enregistrer un commentaire