skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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"


  2. It looks like you need to add a map key.

    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    

    If it exists then make sure that it is in the header.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search