3163d413 by 杨威

设置专题树透明度

1 parent 1ebfcc8e
...@@ -2,15 +2,18 @@ ...@@ -2,15 +2,18 @@
2 "label":"专题树", 2 "label":"专题树",
3 "id":"1", 3 "id":"1",
4 "type":"layerGroup", 4 "type":"layerGroup",
5 "alpha":100,
5 "children":[ 6 "children":[
6 { 7 {
7 "label":"西安市阎良区", 8 "label":"西安市阎良区",
8 "id":"1-1", 9 "id":"1-1",
9 "type":"layerGroup", 10 "type":"layerGroup",
11 "alpha":100,
10 "children":[{ 12 "children":[{
11 "label":"行政区划", 13 "label":"行政区划",
12 "id":"1-1-1", 14 "id":"1-1-1",
13 "type":"layerGroup", 15 "type":"layerGroup",
16 "alpha":100,
14 "children":[ 17 "children":[
15 { 18 {
16 "label":"行政区界限", 19 "label":"行政区界限",
...@@ -32,6 +35,7 @@ ...@@ -32,6 +35,7 @@
32 "label":"地籍分区", 35 "label":"地籍分区",
33 "id":"1-1-2", 36 "id":"1-1-2",
34 "type":"layerGroup", 37 "type":"layerGroup",
38 "alpha":100,
35 "children":[ 39 "children":[
36 { 40 {
37 "label":"地籍区", 41 "label":"地籍区",
...@@ -53,6 +57,7 @@ ...@@ -53,6 +57,7 @@
53 "label":"不动产单元", 57 "label":"不动产单元",
54 "id":"1-1-3", 58 "id":"1-1-3",
55 "type":"layerGroup", 59 "type":"layerGroup",
60 "alpha":100,
56 "children":[ 61 "children":[
57 { 62 {
58 "label":"线状定着物", 63 "label":"线状定着物",
...@@ -130,6 +135,7 @@ ...@@ -130,6 +135,7 @@
130 "label":"自然地理", 135 "label":"自然地理",
131 "id":"1-1-4", 136 "id":"1-1-4",
132 "type":"layerGroup", 137 "type":"layerGroup",
138 "alpha":100,
133 "children":[ 139 "children":[
134 { 140 {
135 "label":"辅助面", 141 "label":"辅助面",
......
...@@ -157,6 +157,17 @@ export default { ...@@ -157,6 +157,17 @@ export default {
157 } 157 }
158 } 158 }
159 layer.sublayers = items; 159 layer.sublayers = items;
160 },
161 //设置图层透明度
162 setLayerOpacity(viewId,layers,value){
163 var view = maps[viewId],
164 layer = view.map.findLayerById("testLayer");
165 for(var i = 0;i < layers.length;i++){
166 var sublayer = layer.findSublayerById(layers[i].layerId);
167 if(sublayer){
168 sublayer.opacity = value/100;
169 }
170 }
160 } 171 }
161 } 172 }
162 } 173 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
31 <span class="custom-tree-node" slot-scope="{ node, data }"> 31 <span class="custom-tree-node" slot-scope="{ node, data }">
32 <span>{{ node.label }}</span> 32 <span>{{ node.label }}</span>
33 <span class="setOpacity" v-if="data.type == 'layerGroup'"> 33 <span class="setOpacity" v-if="data.type == 'layerGroup'">
34 <el-slider v-model="data.alpha" ref="data.id" :format-tooltip="formatTooltip" @change="alphaChange(data)"></el-slider> 34 <el-slider v-model="data.alpha" ref="data.id" :format-tooltip="formatTooltip" @change="alphaChange(data)"></el-slider>
35 </span> 35 </span>
36 </span> 36 </span>
37 </el-tree> 37 </el-tree>
...@@ -114,7 +114,12 @@ ...@@ -114,7 +114,12 @@
114 return val+"%"; 114 return val+"%";
115 }, 115 },
116 alphaChange(nodeData){ 116 alphaChange(nodeData){
117 117 if(nodeData.alpha == 0){
118 return;
119 }
120 var ids = [];
121 this.getChildrens(nodeData,ids);
122 this.setLayerOpacity(this.viewId,ids,nodeData.alpha);
118 } 123 }
119 } 124 }
120 } 125 }
......