编辑下面的代码:【加编码】
<html> <head> <script> function initialize() { var mapProp = { center: new google.maps.LatLng(51.508742,-0.120850), zoom:7, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("googleMap"),mapProp); } function loadScript() { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false&callback=initialize"; document.body.appendChild(script); } window.onload = loadScript; </script> </head> <body> <div id="googleMap" style="width:500px;height:500px;"></div> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂