地图控件:overview、scale、toolbar

地图常用控件:
1、AMap.MapType:地图类型切换插件,用来切换固定的几个常用图层
2、AMap.OverView:地图鹰眼插件,默认在地图右下角显示缩略图
3、AMap.Scale:地图比例尺插件
4、AMap.ToolBar:地图工具条插件,可以用来控制地图的缩放和平移

地图插件添加:map.addControl( new AMap.插件名() )

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.11&key=9de88a718781910c9a1c81230827d1ce&plugin=AMap.Scale,AMap.OverView,,AMap.ToolBar,AMap.Autocomplete"></script>
        <title>地图控件:overview、scale、toolbar</title>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            #container{
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
            }
            #panel{
                position: fixed;
                background: white;
                top: 10px;
                right: 10px;
                width: 280px;
            }
            #search{
                width: 200px;
                height: 160px;
                position: absolute;
                left: 10px;
                top: 10px;
                background: white;
            }
        </style>
    </head>
    <body>
        <div id="container"></div>
        
        
        <script>
            var map = new AMap.Map('container',{
                zoom:11,
                center:[116.379391,39.861536],
                
            });
            
            map.addControl(new AMap.OverView());
            map.addControl(new AMap.Scale());
            map.addControl(new AMap.ToolBar());
        </script>
    </body>
</html>

猜你喜欢

转载自www.cnblogs.com/rickdiculous/p/11440457.html
今日推荐