返回首页
当前位置: 主页 > GPS学院 > 应用软件 >

GPS应用 MapX中access表图形化为mapinfo表的两种途径(2)

时间:2008-01-18 10:43来源:GPS之家-导航之家 作者:www.gpsuu.com
Private Sub Command1_Click() '可以创建多个字段 'mapx5中可以创建索引,mapx4中不可以 Dim rs As DAO.Recordset Dim db As DAO.Database Dim flds As New MapXLib.Fields Dim lyrNew As MapXLib.Layer Dim ptNew


Private Sub Command1_Click()
'可以创建多个字段
'mapx5中可以创建索引,mapx4中不可以
Dim rs As DAO.Recordset
Dim db As DAO.Database

Dim flds As New MapXLib.Fields

Dim 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
Set db = DBEngine.OpenDatabase(C:Program FilesMapInfoMapX 4.0datamapstats.mdb)
Set rs = db.OpenRecordset(US_Cust)
Set ff = Map1.FeatureFactory
flds.AddStringField Company, 50 ,true 'mapx5中可以创建索引,
'flds.AddStringField Company, 50 'mapx4中不可以创建索引,
flds.AddStringField City, 50
flds.AddStringField State, 2
flds.AddNumericField Order_Amt, 12, 2
li.Type = miLayerInfoTypeNewTable
li.AddParameter FileSpec, App.Path & custtab.tab
li.AddParameter Name, mycustomers
li.AddParameter Fields, flds
Map1.Layers.Add li, 1
'到此为止,已经用access表建好mapinfo表,也设置好了字段,但是没有图元在上面,也没有记录。
'下面从access表中x,y创建点图元,同时把其属性数据也添加进去
'--------------------------------------------------------------------
Set lyrNew = Map1.Layers(1)
Set ds = Map1.Datasets.Add(miDataSetLayer, lyrNew)
Set rvs = ds.Rowvalues(0)
rs.MoveFirst
Do While Not rs.EOF
rvs.Item(Company).value = rs.Fields(Company) 'rvs.Item(Company)可写为rvs(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) ' 图元+属性,即feature+Rowvalues
'Set ftrNew = lyrNew.AddFeature(ftrNew)
'ftrNew.Update True, rvs
rs.MoveNext
Loop
Set rs = Nothing
Set db = Nothing
End Sub

(责任编辑:admin)
[ GPSUU整理发布,版权归原作者所有。]
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------

推荐内容