WEB开发网
开发学院软件开发C语言 C# 调用 Google Earth Com API开发(四) 阅读

C# 调用 Google Earth Com API开发(四)

 2009-05-26 08:29:06 来源:WEB开发网   
核心提示: 3、读取图层1:...2:///<summary>3:///显示图层4:///</summary>5:protectedvoidShowLayers()6:{7:Thread.Sleep(500);8://获取所有图层信息9:FeatureCollectionGEl

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# 调用 Google Earth Com API开发(四)

图片看不清楚?请点击这里查看原图(大图)。

系列文章:

C#调用 GoogleEarth COM API开发(一)

C# 调用 Google Earth Com API开发(二)

C# 调用 Google Earth Com API开发(三)

上一页  1 2 3 

Tags:调用 Google Earth

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接