高德地图——控件的添加&删除

控件属性
visible //bool 默认true
ov=new AMap.OverView();
ov.hide(); //ov.show(); 显示/隐藏---表示控件的添加与删除

 

 

<!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>控件的添加与删除</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;
                height: 200px;
            }
            #search{
                width: 200px;
                height: 160px;
                position: absolute;
                left: 10px;
                top: 10px;
                background: white;
            }
        </style>
    </head>
    <body>
        <div id="container"></div>
        <div id="panel">
            <button id="yy">鹰眼</button>
            <button id="gjt">工具条</button>
            <button id="blc">比例尺</button>
        </div>
        
        <script>
            var map = new AMap.Map('container',{
                zoom:11,
                center:[116.379391,39.861536],
                
            });
            
            var oV = new AMap.OverView({
                visible:true
            });
            var oS = new AMap.Scale();
            var oT = new AMap.ToolBar();
            map.addControl(oV);
            map.addControl(oS);
            map.addControl(oT);
            
            let yyNode = git = blc = false;
            yy.onclick = function(){
                if(yyNode == true){
                    oV.hide();
                }else{
                    oV.show();
                }
                yyNode = !yyNode;
            };
            
        </script>
    </body>
</html>

 

posted @ 2019-08-31 21:25  是桂  阅读(1578)  评论(0编辑  收藏  举报