wordpress - ACF Google 地图有时无法正确加载,抛出“Uncaught ReferenceError: google is not defined”
问题描述
我在我的 WordPress 网站上将 ACF 用于谷歌地图。有时它可以正常工作,但大多数情况下地图在页面加载后没有呈现,并且控制台抛出以下错误:
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)
解决方案
看起来您需要添加地图键。
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
如果它存在,请确保它在标题中。
推荐阅读
- python - Python函数用data_frame中的子字符串替换字符串
- azure - 如何将 ADLS gen2 文件夹/文件名动态传递到 ADF 或 Databricks 中的 Databricks Notebook
- java - 在不改变 server.xml 或 tomcat/web.xml 的情况下添加 tomcat 监听器 LifecycleListener
- c# - C# 事件调用和同步
- python-3.x - Python - 使用 most_common 的预期列表与给定的数量较少的列表不同
- r - 如何在 R 上创建我的逻辑回归图的可发布表
- javascript - 用于分析 chrome 扩展中的文本的 Javascript
- azure - 在 Azure DevOps 管道中运行使用 Azure API 和其他基础结构的单元测试
- python - 连接到 PostgreSQL 数据库时 Python 打印加载“动画”
- python - Django 模型对象有任何长度函数吗?