Home  >  Article  >  Database  >  OpenLayers深入浅出(2)

OpenLayers深入浅出(2)

WBOY
WBOYOriginal
2016-06-07 15:27:321607browse

一、map控件介绍: 1、创建图层控件显隐组建new OpenLayers.Control.LayerSwitcher()如图: 2、鹰控件 new OpenLayers.Control.OverviewMap() 添加鹰方式:map.addControl(new OpenLayers.Control.OverviewMap()); 3、地图点击控件 当点击地图时,点击的点移

一、map控件介绍:


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

OpenLayers深入浅出(2)

2、鹰眼控件

new OpenLayers.Control.OverviewMap()

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

3、地图点击控件

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

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

OpenLayers深入浅出(2)

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));

OpenLayers深入浅出(2)

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时,地图只能放缩一次。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn