<!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" /> <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/LuShu/1.2/src/LuShu_min.js"></script> <title>29.1 添加控件</title> </head> <body> <div class="wrapper"> <div class="container clearfix"> <div class="clearfix"> <div style="clear: both;"> <div style="float: left; width: 500px; height: 340px; border: 1px solid gray" id="container"> </div> </div> </div> </div> </div> </body> </html> <script type="text/javascript"> var map = new BMap.Map("container"); // 创建地图实例 var point = new BMap.Point(116.404, 39.950507); // 创建点坐标 map.centerAndZoom(point, 16); // 初始化地图,设置中心点坐标和地图级别 map.addControl(new BMap.OverviewMapControl({ isOpen: 1 })); //为地图添加鹰眼 //map.addControl(new BMap.NavigationControl()); //为地图添加鱼骨(默认) map.addControl(new BMap.NavigationControl({ type: BMAP_NAVIGATION_CONTROL_SMALL })); //为地图添加鱼骨(迷你型) //map.addControl(new BMap.ScaleControl()); //添加一个带上偏移量的比例尺 map.addControl(new BMap.ScaleControl({ offset: new BMap.Size(5, 40) })); //添加一个带上偏移量的比例尺 map.addControl(new BMap.MapTypeControl()); //为地图添加2D3D切换控件 map.setCurrentCity("北京市"); // 仅当设置城市信息时,MapTypeControl的切换功能才能可用 var myCopyright = new BMap.CopyrightControl({ offset: new BMap.Size(82, 0) }); //设置版权信息偏移量 map.addControl(myCopyright); //为地图添加版权控件 myCopyright.addCopyright({ id: 1, content: ‘<a style="line-height:30px;height:30px;display:block;color:red;background:yellow" href="http://www.cnblogs.com"><img src="http://www.ui-love.com/static/img/uiico.ico" />博客园</a>‘ }); </script>
时间: 2024-10-09 21:59:56