Class: SwipeControl

SwipeControl

new SwipeControl(leadingLayers, trailingLayers, options)

engineExtensions/baseExtend/control/SwipeControl.js, line 17

卷帘控件

Name Type Description
leadingLayers Array.<L.Layer>

左侧或者上部图层列表,根据卷帘的模式调整。需要保证传入的图层上具备getContainer方法,当前不支持矢量图层进行卷帘。

trailingLayers Array.<L.Layer>

右侧或者下部图层列表,根据卷帘的模式调整。需要保证传入的图层上具备getContainer方法,当前不支持矢量图层进行卷帘。

options Object

构造参数

Name Type Default Description
mode String 'horizontal' 可选

卷帘的模式。当前仅支持两种模式,'horizontal'水平和'vertical'垂直两种模式

region Number 0.5 可选

区域信息,当region为0.5时,沿着水平卷帘或垂直卷帘方向50%的区域。当前值域范围为0-1

Example
const swipeControl= new SwipeControl(leadingLayers, trailingLayers)
 // 添加到leaflet地图中
 swipeControl.addTo(leafletMap);
 // 移除
 swipeControl.remove();
 // 更新卷帘的模式
 swipeControl.setMode('vertical');
 // 更新区域
 swipeControl.setRegion(0.5);

Extends

  • L.Control

Methods

addTo(map)

engineExtensions/baseExtend/control/SwipeControl.js, line 151

添加到地图中

Name Type Description
map L.Map

leaflet地图对象

enable(enabled)

engineExtensions/baseExtend/control/SwipeControl.js, line 197

开启或关闭工具

Name Type Description
enabled Boolean

remove()

engineExtensions/baseExtend/control/SwipeControl.js, line 162

销毁对象

setLeadingLayers(leadingLayers){*}

engineExtensions/baseExtend/control/SwipeControl.js, line 212

动态设置左侧或者上部图层列表

Name Type Description
leadingLayers Array.<L.Layer>
Returns:
Type Description
*

setMode(mode)

engineExtensions/baseExtend/control/SwipeControl.js, line 189

动态修改模式

Name Type Description
mode String

模式,当前仅支持两种模式,'horizontal'水平和'vertical'垂直两种模式

setRegion(region)

engineExtensions/baseExtend/control/SwipeControl.js, line 181

动态修改区域值

Name Type Description
region Number

区域值

setTrailingLayers(leadingLayers){*}

engineExtensions/baseExtend/control/SwipeControl.js, line 223

动态设置右侧或者下部图层列表

Name Type Description
leadingLayers Array.<L.Layer>
Returns:
Type Description
*