[英]Loading the google map using ajax
I am trying to implement google maps in to my page. 我正在尝试将google maps实现到我的页面中。 I couldn't able to acheive it. 我无法实现。 I am just getting an empty container. 我刚得到一个空容器。 I am doing something wrong here ? 我在这里做错什么了?
<div class="container">
<div class="map">
<div id="map-container" class="z-depth-1-half map-container" style="height: 500px;"></div>
</div>
</div>
These are the script files 这些是脚本文件
<script type="text/javascript" src="https://maps.google.com/maps/api/js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 8 }); } </script>
Simple : Your script must be: <script async defer src="//maps.googleapis.com/maps/api/js?key=YourApiKey&callback=initMap"></script>
简单 :您的脚本必须为: <script async defer src="//maps.googleapis.com/maps/api/js?key=YourApiKey&callback=initMap"></script>
If necessary, post an screen on your console web. 如有必要,在控制台Web上发布一个屏幕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.