OpenLayers 2 map使用

一、map控件介绍:


1、创建图层控件显隐组建new OpenLayers.Control.LayerSwitcher()如图:

2、鹰眼控件

new OpenLayers.Control.OverviewMap()

添加鹰眼方式: map.addControl(new OpenLayers.Control.OverviewMap());

3、地图点击控件

当点击地图时,点击的点移到地图中心位置。

   var click = new OpenLayers.Control.Click();
            map.addControl(click);


4、显示地图坐标位置的控件

   map.addControl( new OpenLayers.Control.MousePosition() );

5、selectFeature(box)控件

  var sf = new OpenLayers.Control.SelectFeature(boxes);
                map.addControl(sf);
                sf.activate();

6、显示编辑控件

      map.addControl(new OpenLayers.Control.EditingToolbar(vlayer));

7、拖拽控件

 var dragFeature = new OpenLayers.Control.DragFeature(layer);

dragFeature .activate();

8、导航历史控件

 nav = new OpenLayers.Control.NavigationHistory();

9、navtoolbar工具

 var panel = new OpenLayers.Control.NavToolbar();通过这个工具可以进行对地图的放大和漫游



map中常用的控件  controls: [
                        new OpenLayers.Control.Navigation(),//导航
                        new OpenLayers.Control.PanZoomBar(),//漫游
                        new OpenLayers.Control.LayerSwitcher({‘ascending’:false}),//overlayers
                        new OpenLayers.Control.ScaleLine(),//比例尺
                        new OpenLayers.Control.Permalink(‘permalink’),//永久链接
                        new OpenLayers.Control.MousePosition(),//显示鼠标坐标
                        new OpenLayers.Control.OverviewMap(),//鹰眼
                        new OpenLayers.Control.KeyboardDefaults()//键盘
                    ]

二、map属性介绍:

numZoomLevels:运行缩放的比例个数,如值为2时,地图只能放缩一次。

转载自:https://blog.csdn.net/CecePony/article/details/80183312

You may also like...