C# 调用 Google Earth Com API开发(四)
2009-05-26 08:29:06 来源:WEB开发网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: }
呵呵,代码很简单。按照此代码修改第三篇的源程序就可以实现本篇的功能了。
图片看不清楚?请点击这里查看原图(大图)。
系列文章:
C#调用 GoogleEarth COM API开发(一)
C# 调用 Google Earth Com API开发(二)
C# 调用 Google Earth Com API开发(三)
- ››Google搜索引擎的奥秘
- ››Google测试搜索结果页面右侧内容更丰富的信息栏
- ››调用已注册会员人数和最新会员名称
- ››Google Dart精粹:应用构建,快照和隔离体
- ››google的代码审查
- ››google analytics清晰追踪爬虫的爬行信息
- ››Google+中文用户在两千万Google+大军中是少数派
- ››Google AdWords最昂贵点击成本的20种关键词分类
- ››Google运作经理Bryan Power给出的GOOGLE求职意见
- ››Google用户体验的十大设计原则
- ››Google Analytics(分析)能为网站带来什么
- ››Google goggles图片搜索 如何优化一个wap网站
更多精彩
赞助商链接