I’m using ACF for google Maps on my WordPress website. Sometimes it works fine but mostly the map is not rendering after the page load and the console is throwing the following error:
Uncaught ReferenceError: google is not defined
at initMap ((index):616)
at HTMLDivElement.<anonymous> ((index):1178)
at Function.each (jquery.min.js?ver=3.6.0:2)
at s.fn.init.each (jquery.min.js?ver=3.6.0:2)
at HTMLDocument.<anonymous> ((index):1176)
at e (jquery.min.js?ver=3.6.0:2)
at t (jquery.min.js?ver=3.6.0:2)
2
Answers
If anybody got stuck with the same issue, it worked for me when I changed
document.ready
towindow.load
. In the official ACF documentation, itsdocument.ready
"
It looks like you need to add a map key.
If it exists then make sure that it is in the header.