2019-11-21 13:06:13 +08:00
|
|
|
|
---
|
|
|
|
|
title: Control
|
|
|
|
|
order: 3
|
|
|
|
|
---
|
|
|
|
|
# control
|
|
|
|
|
|
|
|
|
|
地图组件 用于控制地图的状态如果平移,缩放,或者展示地图一些的辅助信息如图例,比例尺
|
|
|
|
|
|
|
|
|
|
|
2019-11-28 10:36:15 +08:00
|
|
|
|
L7 目前支持Control
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 10:36:15 +08:00
|
|
|
|
- Zoom 放大缩小
|
|
|
|
|
- Scale 比例尺
|
|
|
|
|
- Layers 图层列表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 构造函数
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### option
|
2019-11-28 10:36:15 +08:00
|
|
|
|
|
|
|
|
|
position: `string` 控件位置支持是个方位
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 10:36:15 +08:00
|
|
|
|
- bottomright
|
|
|
|
|
- topright
|
|
|
|
|
- bottomleft,
|
|
|
|
|
- topleft`
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-28 10:36:15 +08:00
|
|
|
|
组件介绍
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
import { Scale Layers, Zoom } from '@antv/l7';
|
|
|
|
|
|
2019-11-21 13:06:13 +08:00
|
|
|
|
```
|
|
|
|
|
|
2019-11-28 10:36:15 +08:00
|
|
|
|
|
|
|
|
|
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
|
|
|
|
#### Zoom
|
|
|
|
|
放大缩小组件 默认 左上角
|
|
|
|
|
|
|
|
|
|
```javascript
|
2019-11-28 10:36:15 +08:00
|
|
|
|
const zoomControl = new Zoom({
|
2019-11-21 13:06:13 +08:00
|
|
|
|
position: 'topleft'
|
2019-11-28 10:36:15 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
scene.addControl(zoomControl);
|
|
|
|
|
|
2019-11-21 13:06:13 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### Scale
|
|
|
|
|
比例尺组件默认左下角
|
|
|
|
|
|
|
|
|
|
```javascript
|
2019-11-28 10:36:15 +08:00
|
|
|
|
const zoomControl = new Zoom({
|
|
|
|
|
position: 'topleft'
|
|
|
|
|
})
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 10:36:15 +08:00
|
|
|
|
scene.addControl(zoomControl);
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### layer
|
2019-11-28 10:36:15 +08:00
|
|
|
|
图层列表目前支持可视化的图层控制
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
|
|
|
|
```javascript
|
2019-11-28 10:36:15 +08:00
|
|
|
|
|
|
|
|
|
const overlayers = {
|
|
|
|
|
"点图层": layer,
|
|
|
|
|
|
2019-11-21 13:06:13 +08:00
|
|
|
|
};
|
2019-11-28 10:36:15 +08:00
|
|
|
|
const layersControl = new Layers({
|
|
|
|
|
overlayers
|
|
|
|
|
});
|
|
|
|
|
scene.addControl(layersControl);
|
|
|
|
|
|
2019-11-21 13:06:13 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 方法
|
|
|
|
|
|
|
|
|
|
#### setPosition
|
|
|
|
|
设置组件位置
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
control.setPosition('bottomright');
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### remove
|
|
|
|
|
移除地图组件
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
control.remove();
|
|
|
|
|
```
|
|
|
|
|
|