在VB+Mapx5.0中新建图层及属性的源代码
来源:互联网 发布:大数据查询引擎 编辑:程序博客网 时间:2024/05/02 00:51
代码:
Private Sub Command1_Click()
'this sample used the new AddField methods and the LayerInfo object to make a new tab
'file. for each record in the Us_Cust table (found in mapstats.mdb) it adds a point
'feature to the new table. for each feature added to the table, selected attribute
'data from Us_Cust is associated with that point (the company name, order ammount, city
'and state).
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim flds As New MapXLib.FieldsDim lyrNew As MapXLib.Layer
Dim ptNew As New MapXLib.Point
Dim ftrNew As MapXLib.Feature
Dim ff As MapXLib.FeatureFactory
Dim li As New MapXLib.LayerInfo
Dim rvs As New MapXLib.Rowvalues
Dim ds As MapXLib.Dataset
'make database connection and get a recordset
Set db = DBEngine.OpenDatabase("C:/Program Files/MapInfo/MapX 5.0/data/mapstats.mdb")
Set rs = db.OpenRecordset("US_Cust")
'we'll use feature factory laterSet ff = Map1.FeatureFactory
'define the columnar structure of the new table we're going to create
flds.AddStringField "Company", 50
flds.AddStringField "City", 50
flds.AddStringField "State", 2
flds.AddNumericField "Order_Amt", 12, 2
'define the LayerInfo object
li.Type = miLayerInfoTypeNewTable
li.AddParameter "FileSpec", App.Path & "/custtab.tab"
li.AddParameter "Name", "mycustomers"
li.AddParameter "Fields", flds
'add the new layer to the top of the map
Map1.Layers.Add li, 1
'make a dataset from the new layer and get its Rowvalues collection
Set lyrNew = Map1.Layers(1)
Set ds = Map1.Datasets.Add(miDataSetLayer, lyrNew)
Set rvs = ds.Rowvalues(0)
'for each records in the Us_Cust table we'll make a point feature and add it
'to the newly created layer. Using the Rowvalues object from that layer's
'dataset we'll supply attribute data for each point feature addedrs.MoveFirst
Do While Not rs.EOF
rvs.Item("Company").value = rs.Fields("Company")
rvs.Item("City").value = rs.Fields("City")
rvs.Item("State").value = rs.Fields("State")
rvs.Item("Order_Amt").value = rs.Fields("Order_Amt")
ptNew.Set rs.Fields("X"), rs.Fields("Y")
Set ftrNew = ff.CreateSymbol(ptNew)
Set ftrNew = lyrNew.AddFeature(ftrNew, rvs)
rs.MoveNextLoop
'close database connection
Set rs = Nothing
Set db = Nothing
End Sub
- 在VB+Mapx5.0中新建图层及属性的源代码
- 如何在c#中使用mapx5.0(二)
- 如何在c#中使用mapx5.0(三)
- vb+mapx5 沿线标注的实现方法
- vb+mapx5 沿线标注的实现方法
- C#中调用mapx5.0
- c#中调用mapx5.0
- c#中操作Mapx5.02的方法
- VB中WinSock控件的属性、方法、事件及应用
- VB中WinSock控件的属性、方法、事件及应用
- VB中WinSock控件的属性、方法、事件及应用
- VB中WinSock控件的属性、方法、事件及应用
- cdr中新建和删除图层的教程
- .Net中如何操作IIS(源代码) 及iis的属性
- CALayer 的属性分析(几何及图层关系属性)
- MAPInfo Professional v10.0026及MapX5.0安装说明
- VC+mapX5.0 在指定经纬度显示车辆图标
- VC+mapX5.0 在指定经纬度显示车辆图标
- TDD,测试代码可以代替文档吗?
- ASP.NET MVC 入门4、Controller与Action
- 【ExtJs学习系列】Ext2.0框架的Grid使用介绍(五)
- asp中rs.open sql,conn,1,1中各参数的意义
- 查找最近的实体
- 在VB+Mapx5.0中新建图层及属性的源代码
- javascript:判断浏览器类型和客户端操作系统 (2009-06-02更新)
- 图元“复制”“剪切”“粘贴”代码
- 基于MAPX控件的鹰眼图实现
- Java程序的加密和反加密
- 2440 GPIO 控制方法
- ASP.NET MVC 入门5、View与ViewData
- ASP.NET MVC 入门6、TempData
- 第一次,比较棘手