# new SwipeControl(leadingLayers, trailingLayers, options)
参数:
| 名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
leadingLayers |
Array.<L.Layer> | 左侧或者上部图层列表,根据卷帘的模式调整。需要保证传入的图层上具备getContainer方法,当前不支持矢量图层进行卷帘。 |
|
trailingLayers |
Array.<L.Layer> | 右侧或者下部图层列表,根据卷帘的模式调整。需要保证传入的图层上具备getContainer方法,当前不支持矢量图层进行卷帘。 |
|
options |
Object | 构造参数 |
|
mode |
String | 'horizontal' | 卷帘的模式。当前仅支持两种模式,'horizontal'水平和'vertical'垂直两种模式 |
region |
Number | 0.5 | 区域信息,当region为0.5时,沿着水平卷帘或垂直卷帘方向50%的区域。当前值域范围为0-1 |
示例
const swipeControl= new SwipeControl(leadingLayers, trailingLayers)
// 添加到leaflet地图中
swipeControl.addTo(leafletMap);
// 移除
swipeControl.remove();
// 更新卷帘的模式
swipeControl.setMode('vertical');
// 更新区域
swipeControl.setRegion(0.5);
继承关系
- L.Control
