卷帘

思路
  1. 定义要素图层
  2. new一个卷帘对象
  3. 开启小部件
    PS:要素图层需要添加在map容器中才能在卷帘对象中设置layers
实用方法
swipeWidget01.disable();//禁用小部件
swipeWidget23.enable();//启用小部件
完整代码
<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Layer Swipe</title>
    <link rel="stylesheet" type="text/css" href="esri.css" />
    <link rel="stylesheet" type="text/css" href="tundra.css" />
    <style>
        html,
        body,
        #map {
            padding: 0;
            margin: 0;
            height: 100%;
            position: relative;
        }
    </style>
     <script src="https://js.arcgis.com/3.29/"></script>
</head>

<body class="calcite">
<div id="map" class="map">
    <div id="swipeDiv"></div>
</div>
</body>

<script>
    require([
        "esri/map",
        "esri/layers/FeatureLayer",
        "esri/dijit/LayerSwipe",
        "dojo/domReady!"
    ], function (
        Map, FeatureLayer, LayerSwipe
    ) {
        var map = new Map("map");
        thingslayer0 = new FeatureLayer("http://localhost:6080/arcgis/rest/services/gaofen/bazhou/MapServer" + "/0", {
            mode: FeatureLayer.MODE_ONDEMAND,
            outFields: ["*"]
        });
        thingslayer1 = new FeatureLayer("http://localhost:6080/arcgis/rest/services/gaofen/bazhou/MapServer" + "/1", {
            mode: FeatureLayer.MODE_ONDEMAND,
            outFields: ["*"]
        });
        //矢量
        map.addLayer(thingslayer0);
        map.addLayer(thingslayer1);
        var swipeWidget = new LayerSwipe({
            type: "vertical",
            map: map,
            // 要卷帘哪些图层
            layers: [thingslayer0, thingslayer1],
        }, "swipeDiv");
        swipeWidget.startup();
    });
</script>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值