Muhammed Muneer
Muhammed Muneer

Reputation: 123

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

Upvotes: 0

Views: 719

Answers (2)

Muhammed Muneer
Muhammed Muneer

Reputation: 123

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"

Upvotes: 2

Maulik Paddharia
Maulik Paddharia

Reputation: 80

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.

Upvotes: 0

Related Questions