今天开博了2007-7-16

开博没有太监的客。。。

 

MapXtreme2004新手资料续

1.从ORACLE表中加载图层的问题。。。
MIConnection Connection=new MIConnection();
Connection.Open();
TableInfoServer tis1=new TableInfoServer("WORLD",
   "SRVR=ora8i;UID=wzz;PWD=11111111",
   "select * from world",MapInfo.Data.ServerToolkit.Oci);
MapInfo.Data.Table [] tables=new MapInfo.Data.Table[2];
tables[0]=Connection.Catalog.OpenTable(tis1);
  TableInfoServer tis2=new TableInfoServer("WORLDCAP",
  "SRVR=ora8i;UID=wzz;PWD=11111111",
  "select * from worldcap",MapInfo.Data.ServerToolkit.Oci);
tables[1]=Connection.Catalog.OpenTable(tis2);
MapControl1.Map.Load(new MapInfo.Mapping.MapTableLoader(tables));

2.存在SqlSever中XY坐标点的绑定代码
//XY绑定:含有x,y坐标点的图层放置在Sql Server数据库中,按xy坐标生成点图层
//1.要在存在该表的数据库中建立MAPINFO_MAPCATALOG表,否则会报错:
//"An unhandled exception of type 'MapInfo.Data.TableException' occurred in mapinfo.coreengine.dll.
//Additional information: 不能打开表。 ODBC 错误: ODBC RC=-1, ODBC SQLState=S0002, DBMS RC=208, DBMS Msg=[Microsoft][ODBC SQL Server Driver][SQL Server]对象名 'MAPINFO.MAPINFO_MAPCATALOG' 无效。
//2.要含xy坐标点的表建立主键,否则会报错:
//"Additional information: 不能打开表。因为不能识别唯一键,不能访问远程数据。"

   //建立XY空间方案
   MapInfo.Data.SpatialSchemaXY xy = new MapInfo.Data.SpatialSchemaXY();
   xy.XColumn = "X";
   xy.YColumn = "Y";
   xy.NullPoint = "0.0, 0.0";
   xy.StyleType = MapInfo.Data.StyleType.None;
   xy.DefaultStyle = new MapInfo.Styles.CompositeStyle();
   xy.CoordSys = MapInfo.Engine.Session.Current.CoordSysFactory.CreateLongLat(MapInfo.Geometry.DatumID.WGS84);

   //建立TableInfo
   MapInfo.Data.TableInfoServer ti = new MapInfo.Data.TableInfoServer("Customers","Driver={SQL Server};Server=LIXIAOHUI;Database=test;Uid=sa;Pwd=sa;","select * from Us_Cust",MapInfo.Data.ServerToolkit.Odbc);
   ti.SpatialSchema = xy;
   MapInfo.Data.Table miCustomers = MapInfo.Engine.Session.Current.Catalog.OpenTable (ti);
   MapInfo.Mapping.FeatureLayer featureLayer = new MapInfo.Mapping.FeatureLayer(miCustomers);
   mapControl1.Map.Layers.Add(featureLayer);
   mapControl1.Map.SetView(featureLayer);

3.如何查看整个地图
Map map = mapControl1.Map;
IMapLayerFilter lyrFilter = MapLayerFilterFactory.FilterByType(typeof(FeatureLayer));
MapLayerEnumerator lyrEnum= map.Layers.GetMapLayerEnumerator(lyrFilter);
map.SetView(lyrEnum);
或者:
   Map map = mapControl1.Map;
   IMapLayerFilter lyrFilter = new FilterByLayerType(LayerType.Normal);
   MapLayerEnumerator lyrEnum= map.Layers.GetMapLayerEnumerator(lyrFilter);
   map.SetView(lyrEnum);

posted on 2005-10-27 11:46  胡敏  阅读(2116)  评论(2编辑  收藏  举报

导航