代码
body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
#allmap{width:100%;height:500px;}
p{margin-left:5px; font-size:14px;}
设置地图显示范围将地图显示范围设定在指定区域,地图拖出该区域后会重新弹回。
//百度地图API功能
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 13);
// map.centerAndZoom(new BMap.Point(116.027143, 39.772348),13); // 测试为左下角的位置
// map.centerAndZoom(new BMap.Point(116.832025, 40.126349),13); // 测试为右上角的位置
map.enableScrollWheelZoom(); // 允许滚动
var b = new BMap.Bounds(new BMap.Point(116.027143, 39.772348),new BMap.Point(116.832025, 40.126349)); // 范围 左下角,右上角的点位置
try { // js中尽然还有try catch方法,可以避免bug引起的错误
BMapLib.AreaR