获得要素图层通过UID获取
1 ///
2 /// 获得要素图层UID获取(第一种方法)
3 ///
4 /// IMap对象
5 ///
6 public List GetFeatureLayersUID(IMap pMap)
7 {
8 UID uid = new UIDClass();
9 uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
10 IEnumLayer Layer = pMap.Layers[uid, true];
11 ILayer ilayer = Layer.Next();
12 //遍历地图
13 while (ilayer != null)
14 {
15 pList.Add(ilayer as IFeatureLayer);
16 ilayer = Layer.Next();
17 }
18 return pList;
19
20 }
1 ///
2 /// 获得要素图层
3 ///
4 /// IMap对象
5 ///
6 public List GetFeatureLayers(IMap pMap)
7 {
8 //遍历地图(需要递归判断)
9 for (int i = 0; i )
10 {
11 GetIFeatureLayer(pMap.get_Layer(i));
12 }
13 return pList;
14 }
15
16 ///
17 /// 执行得到所有图层
18 ///
19 /// 图层对象
20 ///
21 public void GetIFeatureLayer(ILayer layer)
22 {
23 if (layer is IFeatureLayer)
24 {
25 //获得图层要素
26 pFeatLayer = layer as IFeatureLayer;
27 pList.Add(pFeatLayer);
28 }
29 else if (layer is CadAnnotationLayer)
30 {
31 }
32 else if (layer is IRasterLayer)
33 {
34 }
35 else if (layer is ILasDatasetLayer)
36 {
37 }
38 else if (layer is IGroupLayer)
39 {
40 //遍历图层组
41 pCompLayer = layer as ICompositeLayer;
42 getlist(pCompLayer);
43 }
44
45
46 }
47 ///
48 /// 递归所有图层
49 ///
50 /// IGroupLayer中所有的图层
51 ///
52 public void getlist(ICompositeLayer pCompLayer)
53 {
54 for (int j = 0; j )
55 {
56 if (pCompLayer.get_Layer(j) is IFeatureLayer)
57 {
58 pFeatLayer = pCompLayer.get_Layer(j) as IFeatureLayer;
59 pList.Add(pFeatLayer);
60 }
61 else if (pCompLayer.get_Layer(j) is IGroupLayer)
62 {
63 getlist(pCompLayer.get_Layer(j) as ICompositeLayer);
64 }
65 else if (pCompLayer.get_Layer(j) is CadAnnotationLayer)
66 {
67 continue;
68 }
69 else if (pCompLayer.get_Layer(j) is IRasterLayer)
70 {
71 continue;
72 }
73 else if (pCompLayer.get_Layer(j) is ILasDatasetLayer)
74 {
75 continue;
76 }
77 }
78 }