Search code examples
wordpressgoogle-mapsgoogle-maps-api-3advanced-custom-fields

ACF Google map sometimes not loading properly, throws "Uncaught ReferenceError: google is not defined"


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)

Google is not defined error


Solution

  • If anybody got stuck with the same issue, it worked for me when I changed document.ready to window.load. In the official ACF documentation, its document.ready

    enter image description here"