直接上代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>百度地图</title>
<style type="text/css">
body,
html,
#map {
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
font-family: "微软雅黑";
}
</style>
</head>
<body>
<div id="map"></div>
</body>
<script type="text/javascript">
function init() {
var map = new BMapGL.Map('map');
var point = new BMapGL.Point(116.404, 39.915);
map.centerAndZoom(point, 12);
map.enableScrollWheelZoom(true);
}
function loadScript() {
var script = document.createElement("script");
script.src = "https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=秘钥&callback=init";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
</html>