- 注册百度开发者账号,获取key
- 在页面引用:<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=您的密钥"></script>
- 创建容器 :
- 放入脚本
具体查询官网教程:http://lbsyun.baidu.com/index.php?title=jspopular/guide/helloworld
代码一
var map = new BMap.Map("container");
var point = new BMap.Point(116.404, 39.915);
代码块二
map.centerAndZoom(point, 15); window.setTimeout(function(){ map.panTo(new BMap.Point(116.409, 39.918)); }, 2000);
注:地图调用报错Uncaught TypeError:Cannot read property 'fc' of undefined
解:代码块二,要放在页面加载后。