【VB开源代码栏目提醒】:网学会员在VB开源代码频道为大家收集整理了“VB Mapx5 0中新建图层及属性的源代码 - 技术总结“提供大家参考,希望对大家有所帮助!
VBMapx5.0中新建图层及属性的源代码 以下内容只有回复后才可以浏览 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.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 make database connection and get a recordset Set db DBEngine.OpenDatabaseC:Program FilesMapInfoMapX 5.0datamapstats.mdb Set rs db.OpenRecordsetUS_Cust well use feature factory later Set ff Map1.FeatureFactory define the columnar structure of the new table were 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.Layers1 Set ds Map1.Datasets.AddmiDataSetLayer lyrNew Set rvs ds.Rowvalues0 for each records in the Us_Cust table well make a point feature and add it to the newly created layer. Using the Rowvalues object from that layers dataset well supply attribute data for each point feature added rs.MoveFirst Do While Not rs.EOF rvs.ItemCompany.value rs.FieldsCompany rvs.ItemCity.value rs.FieldsCity rvs.ItemState.value rs.FieldsState rvs.ItemOrder_Amt.value rs.FieldsOrder_Amt ptNew.Set rs.FieldsX rs.FieldsY Set ftrNew ff.CreateSymbolptNew Set ftrNew lyrNew.AddFeatureftrNew rvs rs.MoveNext Loop close database connection Set rs Nothing Set db Nothing End Sub