• mapx连接数据库


    MIConnection Connection = new MIConnection();
                Connection.Open();            
                MapInfo.Data.SpatialSchemaXY xy = new MapInfo.Data.SpatialSchemaXY();
                xy.XColumn = "id";
                xy.YColumn = "age";
                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=wingao;Database=mapxdb;Uid=sa;Pwd=1;", "select * from CH_SHENGHUI", 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);
                Connection.Close();
                MessageBox.Show("OK!");
    
    http://www.cnblogs.com/dachie/archive/2010/08/17/1801598.html
    
    

    TableInfoNative tableInfoNative = new TableInfoNative(layerName);
                
        tableInfoNative.TablePath = @"d:\test.tab";
                
        tableInfoNative.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn( MapInfo.Engine.Session.Current.CoordSysFactory.CreateLongLat(MapInfo.Geometry.DatumID.WGS84)));

        tableInfoNative.Columns.Add(ColumnFactory.CreateStyleColumn());

        tableInfoNative.Columns.Add(ColumnFactory.CreateStringColumn("Name", 100));

        tableInfoNative.Columns.Add(ColumnFactory.CreateStringColumn("LineType", 100));
        tableInfoNative.WriteTabFile();

    //保存tab

    MapInfo.Data.Table t = MapInfo.Engine.Session.Current.Catalog.CreateTable(tableInfoNative);
        MapInfo.Engine.Session.Current.Catalog.CloseTable("test");

    //加载到mapControl

    Table tb = Session.Current.Catalog.CreateTable(tableInfoNative);

        FeatureLayer tempLayer = new FeatureLayer(tb, layerName);

        mapcontrol.Map.Layers.Add(tempLayer);

      

  • 相关阅读:
    eclipse中创建完整的maven项目
    Nginx+tomcat配置集群负载均衡
    Git的安装与使用
    Angularjs checkbox的ng属性
    chrome渲染hover状态tranform相邻元素抖动bug
    nodejs创建express+ejs项目
    ubuntu常用命令
    ubuntu查看命令
    sublime text2卸载和重新安装
    fiddler代理
  • 原文地址:https://www.cnblogs.com/bjxly/p/2311402.html
Copyright © 2020-2023  润新知