代碼
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微軟雅黑";} </style> <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=sSelQoVi2L3KofLo1HOobonW"></script> <title>設置地圖最大、最小級別</title> </head> <body> <div id="allmap"></div> </body> </html> <script type="text/javascript"> // 百度地圖API功能 var map = new BMap.Map("allmap",{minZoom:6,maxZoom:8}); // 創建Map實例,設置地圖允許的最小/大級別,級別越大越清晰,越能看到細節 //map.centerAndZoom(new BMap.Point(116.4035,39.915),9); // 超過按設置的最大算 map.centerAndZoom(new BMap.Point(116.4035,39.915),4); // 少於最小的按設置的最小算 map.enableScrollWheelZoom(true); // 設置了最大級別和最小級別之后,滾動的范圍也受制於最大與最小,根據實際使用情況進行設置 </script>
有所規矩,才成方圓
最小的6級別
最大的8級別