大智

快乐工作中生活

 

MapEase

这是我用MapEase编的程,希望对你有参考作用  
   
  private   MEDataEngine.MeDataConnection   conn;       //map链接  
  private   AxMapEase.AxMeMap   mapMain;  
   
  private   void   FormMain_Load(object   sender,   System.EventArgs   e)  
  {  
          conn   =   new     MEDataEngine.MeDataConnectionClass();       //链接实例化  
          InitMapData();  
  }  
   
  //加载层  
  private   void   InitMapData()  
  {  
                    conn.Database   =   GetDataPath("..\\..\\..\\Data108");     //打开map所在目录      
  if   (!conn.Open())  
  {  
  MessageBox.Show("Could   not   connect   to   the   geo   database.");  
  return;  
  }  
   
  ///********************************************************  
  ///初始化mapMain  
  ///********************************************************  
  MeMapModel   mapModel1   =   new   MeMapModelClass();  
  mapModel1.BackColor   =   (MEMap.Colors)0xE3F6E1;  
   
  AddLayer("VDTable",   mapModel1);       //"VDTable"——table名  
   
  mapMain.MapModel   =   mapModel1;  
  mapMain.MouseTool   =   new   MePanToolClass();  
  }  
   
  private   void   AddLayer(string   dsName,   MeMapModel   mapModel)  
  {  
  //   get   geo   data   source   from   connection  
  MeSetVDataSource   dataSource;  
  dataSource   =   (MeSetVDataSource)conn.FindDataSource(dsName);  
  if   (dataSource   ==   null)  
  {  
  MessageBox.Show("Could   not   find   the   geo   data   source:   "   +   dsName); return;  
  }  
   
  //   open   the   geo   data   source  
  if   (!dataSource.Open(true,   true))  
  {  
  MessageBox.Show("Failed   to   open   the   geo   data   source:   "   +   dsName);  
  return;  
  }  
   
  //   create   a   geo   dataset   object   from   the   geo   data   source  
  MEDataEngine.MeVectorDataset   dataset   =   new   MEDataEngine.MeVectorDataset();  
  dataset.Open(dataSource,   mapModel.CoordinateSystem,   null);  
   
  //   then   add   the   dataset   to   the   map   model//s   Datasets   collection  
  mapModel.Datasets.Add(dataset);  
   
  //   create   layer   from   dataset  
  MeVectorLayer   layer   =   new   MeVectorLayerClass();  
  layer.Name   =   mapModel.Layers.GetDefaultName(dataset.Name);  
  MeRecordset   rs   =   new   MeRecordsetClass();  
  rs.Open(dataset,   null);  
  layer.DataSource   =   rs;  
   
  //   add   to   the   layers   collection  
  mapModel.Layers.Add(layer);  
  }

posted on 2007-12-12 21:32  lgzh  阅读(322)  评论(1编辑  收藏  举报

导航