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)
CodePudding user response:
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.
CodePudding user response:
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