Javascript 将Google地图API加载到wordpress post中

Javascript 将Google地图API加载到wordpress post中,javascript,wordpress,google-maps,Javascript,Wordpress,Google Maps,我正在尝试将谷歌地图加载到帖子中 在标题中,我加载: <script type="text/javascript" src="http://dev.ateo.dk/wp-content/themes/ateo/js/parking.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"&g

我正在尝试将谷歌地图加载到帖子中

在标题中,我加载:

    <script type="text/javascript" src="http://dev.ateo.dk/wp-content/themes/ateo/js/parking.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
    <script src="//maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>

在wordpress i load中的帖子中:

<div id="map_div"></div>

您可以在这里看到.js:


地图根本没有显示出来,所以我希望你们能帮我做这件事。

正如@Anto Jurković在评论中提到的那样,你最后需要包括你的
parking.js

当这些对象还不存在时,您正在初始化地图和其他对象,因为jquery和Google地图将在稍后加载。此外,在加载maps javascript时,您没有提供API密钥,因此Google不会向您提供地图

因此,它必须是:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
<script src="//maps.google.com/maps/api/js?key=YOUR_API_KEY&sensor=true" type="text/javascript"></script>
<script type="text/javascript" src="http://dev.ateo.dk/wp-content/themes/ateo/js/parking.js"></script>

在Google Maps v3官方文档中有记录


TL;DR:您可以通过谷歌开发者控制台获得它

以上所有功能都不起作用。什么时候加载脚本并不重要,脚本也应该使用我发现的wordpress中的functions.php加载


div应该有一个size属性,这导致地图被显示

你必须在最后包含你的
parking.js
脚本。我现在尝试了这个,所以序列如你所述,但这没有任何区别。你在谷歌地图中缺少APIkey include,它一定是这样的:
我会更新我的答案