Wordpress 加载Google地图时出现问题-传感器不需要
我试图在WordPress网站上运行Google地图。代码在这个平台上运行得很好,但是当我把它交给WordPress时,我得到了这个错误 谷歌地图API警告:SensorNotRequired: 我也试过这个代码Wordpress 加载Google地图时出现问题-传感器不需要,wordpress,google-maps,google-maps-api-3,Wordpress,Google Maps,Google Maps Api 3,我试图在WordPress网站上运行Google地图。代码在这个平台上运行得很好,但是当我把它交给WordPress时,我得到了这个错误 谷歌地图API警告:SensorNotRequired: 我也试过这个代码 <script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script> 但
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
但结果是一样的
最后,我尝试从API中获取一个密钥并使用它
<script src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&callback=initMap"
async defer></script>
现在我得到了这个错误
未捕获类型错误:window.initMap不是函数
您能告诉我发生这种情况的原因以及我如何解决它吗?而不是:
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
尝试:
从:
谷歌地图不再需要传感器参数
JavaScript API。它不会阻止GoogleMapsJavaScriptAPI
工作正常,但我们建议您拆下传感器
来自脚本元素的参数
谢谢scaisEdge,但是你能告诉我其他脚本有什么问题吗?是的,在第一个脚本中,你有一个不正确的sensor=true,如果你不需要sensor,省略这个子句更好,在第二个脚本中,调用一个名为initMap的回调函数,但是这个函数在你的代码中不存在,所以你会得到错误。我希望这是有用的
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?v=3"></script>