百度地圖Api: http://lbsyun.baidu.com/
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World!</title>
<style type="text/css">
html {
height: 100%
}
body {
height: 100%;
margin: 0px;
padding: 0px
}
#container {
height: 100%
}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=2337624829697af4d7d4884ea113c174">
</script>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
var map = new BMap.Map("container"); // 建立地圖執行個體
var point = new BMap.Point(116.404, 39.915); // 建立點坐标
map.centerAndZoom(point, 10); // 初始化地圖,設定中心點坐标和地圖級别
</script>
</body>
</html>
JavaScript API支援異步加載,您可以在引用腳本的時候添加callback參數,當腳本加載完成後callback函數會被立刻調用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>異步加載</title>
<script type="text/javascript">
function initialize() {
var mp = new BMap.Map('map');
mp.centerAndZoom(new BMap.Point(121.491, 31.233), 11);
}
function loadScript() {
var script = document.createElement("script");
script.src = "http://api.map.baidu.com/api?v=2.0&ak=2337624829697af4d7d4884ea113c174&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
<style type="text/css">
#map {
height: 100%
}
body {
height: 100%;
margin: 0px;
padding: 0px
}
html {
height: 100%
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>
轉載于:https://www.cnblogs.com/yyxiangjava/p/5667763.html