程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#調用Google Earth Com API開發(四)(3)

C#調用Google Earth Com API開發(四)(3)

編輯:關於C語言

3、讀取圖層

1: ...
2: /// <summary>
3: /// 顯示圖層
4: /// </summary>
5: protected void ShowLayers()
6: {
7:   Thread.Sleep(500);
8:   // 獲取所有圖層信息
9:   FeatureCollectionGE layers = GeApp.GetLayersDatabases();
10:   // 獲取工具面板
11:   GEToolPad toolPad = GetToolPad();
12:   // 顯示所有圖層
13:   toolPad.ShowLayers(layers);
14: }
15: ...
16: /// <summary>
17: /// 將給定的圖層集合顯示在“圖層”選項卡的樹形控件中
18: /// </summary>
19: /// <param name="layers">圖層集合</param>
20: public void ShowLayers(FeatureCollectionGE layers)
21: {
22:   if (this.InvokeRequired)
23:   {
24:     Action method = delegate {
25:       InternalShowLayers(layers);
26:     };
27:     try
28:     {
29:       this.Invoke(method);
30:     }
31:     catch { }
32:   }
33:   else
34:   {
35:     InternalShowLayers(layers);
36:   }
37: }
38: /// <summary>
39: /// 將給定的圖層集合顯示在“圖層”選項卡的樹形控件中.被公共函數ShowLayers調用
40: /// </summary>
41: /// <param name="layers"></param>
42: protected void InternalShowLayers(FeatureCollectionGE layers)
43: {
44:   this.tvLayers.Nodes.Clear();
45:
46:   if (layers == null || layers.Count <= 0)
47:   {
48:     return;
49:   }
50:
51:   foreach (FeatureGE layer in layers)
52:   {
53:     TreeNode node = new TreeNode(layer.Name);
54:     node.Checked = layer.Visibility > 0;
55:     node.Tag = layer;
56:
57:     ShowChidrenLayers(layer, node);
58:
59:     node.Expand();
60:
61:     this.tvLayers.Nodes.Add(node);
62:   }
63: }
64: /// <summary>
65: /// 顯示指定圖層的子圖層
66: /// </summary>
67: /// <param name="layer">當前圖層</param>
68: /// <param name="node">當前節點</param>
69: protected void ShowChidrenLayers(FeatureGE layer, TreeNode node)
70: {
71:   FeatureCollectionGE layers = layer.GetChildren();
72:
73:   foreach (FeatureGE child in layers)
74:   {
75:     TreeNode tn = new TreeNode(child.Name);
76:     tn.Checked = child.Visibility > 0;
77:     tn.Tag = child;
78:
79:     ShowChidrenLayers(child, tn);
80:
81:     node.Nodes.Add(tn);
82:   }
83: }

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved