zoukankan      html  css  js  c++  java
  • 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);

      

  • 相关阅读:
    常见存储过程分页PK赛——简单测试分析常见存储过程分页速度
    简单的ASP.NET无刷新分页
    程序员45个好习惯
    手机应用兼职开发平台,欢迎有识之士参加...
    DotNetRemoting分布式安全部署(整理+原创)
    刚刚整理的截获SQL错误代码弹出提示信息类.
    485modbus通讯协议
    485通信
    ucoss在stm32上的移植
    使用OFFICE组件出问题环境配置
  • 原文地址:https://www.cnblogs.com/bjxly/p/2311402.html
Copyright © 2011-2022 走看看