<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="Content-Type" content="text/html; 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=1.5&ak=83E4862c1e77e7b01856563eb22e334b"> @*<script type="text/javascript" src="http://api.map.baidu.com/api?key=46ce9d0614bf7aefe0ba562f8cf87194&v=1.0&services=false"></script>*@ </script> </head> <body> @*官方网站地址 http://developer.baidu.com/map/index.php?title=jspopular*@ <div id="container" style="520px;height:340px;border:1px solid gray"></div> <script type="text/javascript"> var myCity = new BMap.LocalCity(); var map = new BMap.Map("container"); // 创建Map实例 map.addControl(new BMap.NavigationControl());//缩放平移控件 map.addControl(new BMap.ScaleControl()); //比例尺 myCity.get(function (result){ // 初始化地图,设置中心点坐标和地图级别 map.centerAndZoom(new BMap.Point(result.center.lng, result.center.lat), result.level); //添加地图类型控件 map.addControl(new BMap.MapTypeControl()); //开启鼠标滚轮缩放 map.enableScrollWheelZoom(true); }); </script> </body> </html>