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

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

 2009-05-26 08:29:06 来源:WEB开发网   
核心提示: 2、读取PlaceMarksGoogle Earth COM API中提供了两个读取PlaceMarks的函数,一个是GetTemporaryPlaces(),C# 调用 Google Earth Com API开发(四)(2),用来读取临时位置;另一个是GetMyPlaces(),用来读

2、读取PlaceMarks

Google Earth COM API中提供了两个读取PlaceMarks的函数。一个是GetTemporaryPlaces(),用来读取临时位置;另一个是GetMyPlaces(),用来读取自定义位置,即GoogleEarth中显示的“我的位置”。呵呵

  1: ...
   2: /// <summary>
   3: /// 显示位置“PlaceMarks”。位置分为两种,一种时TemporaryPlaces,另一种为MyPlaces
   4: /// </summary>
   5: protected void ShowPlaces()
   6: {
   7:   Thread.Sleep(500);
   8:   // 获取MyPlaces
   9:   FeatureGE myPlace = GeApp.GetMyPlaces();
  10:   // 获取临时位置
  11:   FeatureGE temporaryPlace = GeApp.GetTemporaryPlaces();
  12:   // 
  13:   List<FeatureGE> places = new List<FeatureGE>();
  14:   places.Add(myPlace);
  15:   places.Add(temporaryPlace);
  16:  
  17:   // 获取工具面板
  18:   GEToolPad toolPad = GetToolPad();
  19:   // 显示所有位置
  20:   toolPad.ShowPlaces(places);
  21: }
  22: ...
  23: /// <summary>
  24: /// 显示所有PlaceMarks(位置)
  25: /// </summary>
  26: /// <param name="places"></param>
  27: public void ShowPlaces(List<FeatureGE> places)
  28: {
  29:   if (this.InvokeRequired)
  30:   {
  31:     Action method = delegate {
  32:       InternalShowPlaces(places);
  33:     };
  34:  
  35:     try
  36:     {
  37:       this.Invoke(method);
  38:     }
  39:     catch { }
  40:   }
  41:   else
  42:   {
  43:     InternalShowPlaces(places);
  44:   }
  45: }
  46: /// <summary>
  47: /// 显示所有PlaceMarks(位置)。被ShowPlaces函数调用
  48: /// </summary>
  49: /// <param name="places"></param>
  50: protected void InternalShowPlaces(List<FeatureGE> places)
  51: {
  52:   this.tvPlaces.Nodes.Clear();
  53:  
  54:   if (places == null || places.Count <= 0)
  55:     return;
  56:  
  57:   foreach (FeatureGE place in places)
  58:   {
  59:     TreeNode node = new TreeNode(place.Name);
  60:     node.Checked = place.Visibility > 0;
  61:     node.Tag = place;
  62:  
  63:     ShowChildrenPlaces(place, node);
  64:  
  65:     node.Expand();
  66:  
  67:     this.tvPlaces.Nodes.Add(node);
  68:   }
  69: }
  70: /// <summary>
  71: /// 显示指定PlaceMark的子PlaceMark
  72: /// </summary>
  73: /// <param name="place">父PlaceMark</param>
  74: /// <param name="node">父节点</param>
  75: protected void ShowChildrenPlaces(FeatureGE place, TreeNode node)
  76: {
  77:   FeatureCollectionGE places = place.GetChildren();
  78:  
  79:   foreach (FeatureGE child in places)
  80:   {
  81:     TreeNode tn = new TreeNode(child.Name);
  82:     tn.Checked = child.Visibility > 0;
  83:     tn.Tag = child;
  84:  
  85:     ShowChildrenPlaces(child, tn);
  86:  
  87:     node.Nodes.Add(tn);
  88:   }
  89: }

Tags:调用 Google Earth

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