卷帘
程序员文章站
2022-07-13 11:57:33
...
思路
- 定义要素图层
- new一个卷帘对象
- 开启小部件
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>
上一篇: BZOJ 4415 洛谷 3988 [Shoi2013]发牌
下一篇: java正则解析${}