高德地图插件

时间:2016-01-01 22:55:31   收藏:0   阅读:8224

AMap.ToolBar

加载工具条以及设置工具条类型

    //加载工具条插件
    mapObj.plugin(["AMap.ToolBar"],function(){
        //加载工具条
        tool = new AMap.ToolBar({
            //初始化定义配置
            direction:false,//隐藏方向导航
            ruler:false//隐藏视野级别控制尺
            //autoPosition:false//禁止自动定位
        });
        mapObj.addControl(tool);
    });

方法:

<a href="javascript:tool.showDirection()">显示方向导航键盘</a>  
<a href="javascript:tool.hideDirection()">隐藏方向导航键盘</a> <a href="javascript:tool.showRuler()">显示级别控制尺</a>
<a href="javascript:tool.hideRuler()">隐藏级别控制尺</a> <a href="javascript:tool.show()">显示工具条</a>
<a href="javascript:tool.hide()">隐藏工具条</a>
<a href="javascript:tool.doLocation();void(0)">位置定位</a>

 

AMap.OverView 眼鹰
加载眼鹰以及设置眼鹰类型
    mapObj.plugin(["AMap.OverView"],function(){
        //加载鹰眼
        view = new AMap.OverView({
            //visible:false //初始化隐藏鹰眼
        });
        mapObj.addControl(view);
    });

设置眼鹰

<a href="javascript:view.show()">显示鹰眼</a>
<a href="javascript:view.hide()">隐藏鹰眼</a> 
<a href="javascript:view.open()">最大化鹰眼</a>
<a href="javascript:view.close()">最小化鹰眼</a>

 

 

 

AMap.Scale    比例尺插件

加载比例尺插件 以及设置比例尺插件 类型

 

    mapObj.plugin(["AMap.ToolBar","AMap.OverView,AMap.Scale"],function(){
        //加载比例尺
        scale = new AMap.Scale();
        mapObj.addControl(scale);
    });

 

设置比例尺

 

 

<a href="javascript:scale.show()">显示比例尺</a> <a href="javascript:scale.hide()">隐藏比例尺</a>

 

 

 

圆编辑插件 (AMap.Circle)

加载圆编辑插件插件以及设置圆编辑插件插件类型

 

var circle = new AMap.Circle({
    map: mapObj,
    center:new AMap.LngLat("116.40332221984863","39.90025505675715"),
    radius:1000,
    strokeColor: "#F33",
    strokeOpacity: 1,
    strokeWeight: 3,
    fillColor: "ee2200",
    fillOpacity: 0.35
});
 
mapObj.plugin(["AMap.CircleEditor"],function(){
    circleEditor = new AMap.CircleEditor(mapObj,circle);
});

 

设置圆编辑插件

 

<a href="javascript:circleEditor.open()">显示圆编辑插件</a>  <a href="javascript:circleEditor.close()">隐藏圆编辑插件</a>  

 

 

 

 

 

 

 

 

 

折线、多边形编辑插件 AMap.PolyEditor

加载折线、多边形编辑插件插件以及设置折线、多边形编辑插件插件类型

 

//编辑折线  
function editLine(){
    var arr=new Array();//经纬度坐标数组
    arr.push(new AMap.LngLat("116.368904","39.913423"));
    arr.push(new AMap.LngLat("116.382122","39.901176"));
    arr.push(new AMap.LngLat("116.387271","39.912501"));
    arr.push(new AMap.LngLat("116.398258","39.904600"));
     
    //定义折线对象
    polyline=new AMap.Polyline({
        path:arr,     //设置折线的节点数组
        strokeColor:"#F00",
        strokeOpacity:0.4,
        strokeWeight:3,
        strokeStyle:"dashed",
        strokeDasharray:[10,5]
    });
     
    polyline.setMap(mapObj);//地图上添加折线 【添加直线】
     
    //构造折线编辑对象,并开启折线的编辑状态
    mapObj.plugin(["AMap.PolyEditor"],function(){
        polylineEditor = new AMap.PolyEditor(mapObj,polyline);
        polylineEditor.open();
    });                                 
}

 

设置折线、多边形编辑插件

 

<a href="javascript:circleEditor.open()">显示折线、多边形编辑插件</a>  <a href="javascript:circleEditor.close()">隐藏折线、多边形编辑插件</a>  

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!