默认头像
路人甲
路人甲
  • 注册日期2004-04-08
  • 发帖数22
  • QQ89497003
  • 铜币93枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1235回复:2

请教图层新建问题

楼主#
更多 发布于:2005-03-24 16:35
哪位高手指点一下,用ao如何新建一个图层,要求:图层的参数和当前的工程中的其他图层的参数一样。再平台中arcgis使用arccatclog新建图层在arcmap中添加。怎样在ao中实现这两个功能呀。请高手帮忙,谢谢!!!!!!!!!
喜欢0 评分0
默认头像
路人甲
路人甲
  • 注册日期2005-01-14
  • 发帖数114
  • QQ
  • 铜币414枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2005-03-26 18:36
我也用的这个方法可以建立新的图层
女口果人尔能看日月白这段言舌,那言兑日月人尔白勺目艮目青有严重白勺散光 
举报 回复(0) 喜欢(0)     评分
默认头像
路人甲
路人甲
  • 注册日期2004-04-08
  • 发帖数22
  • QQ89497003
  • 铜币93枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2005-03-25 19:00

自己来解决吧,不知这个方法是否可行

Public Sub newlayer(et As esriGeometryType, dtname As String, lname As String) '图层类型,数据库名,图层名称 Dim pFeatClass As IFeatureClass Dim pLayer As IFeatureLayer Dim player1 As IFeatureLayer Dim pf As IFeatureClass Dim igeofea As IGeoFeatureLayer Set pLayer = New FeatureLayer Set igeofea = New FeatureLayer

Set igeofea.SpatialReference = MapControl1.SpatialReference '设置参数 Set pLayer = igeofea pLayer.Name = lname Set pLayer.FeatureClass = CreateShapefile(et, dtname, lname)

m_pMapDocument.ActiveView.FocusMap.AddLayer pLayer End Sub

Public Function CreateShapefile(et As esriGeometryType, spath As String, sName As String) As IFeatureClass ' Dont include .shp extension      ' Open the folder to contain the shapefile as a workspace   Dim pFWS As IFeatureWorkspace   Dim pWorkspaceFactory As IWorkspaceFactory   Set pWorkspaceFactory = New ShapefileWorkspaceFactory   Set pFWS = pWorkspaceFactory.OpenFromFile(spath, 0)      ' Set up a simple fields collection   Dim pFields As IFields   Dim pFieldsEdit As IFieldsEdit   Set pFields = New Fields   Set pFieldsEdit = pFields      Dim pField As IField   Dim pFieldEdit As IFieldEdit      ' Make the shape field   ' it will need a geometry definition, with a spatial reference   Set pField = New Field   Set pFieldEdit = pField   pFieldEdit.Name = "Shape"   pFieldEdit.Type = esriFieldTypeGeometry      Dim pGeomDef As IGeometryDef   Dim pGeomDefEdit As IGeometryDefEdit   Set pGeomDef = New GeometryDef   Set pGeomDefEdit = pGeomDef   With pGeomDefEdit     .GeometryType = et ' 图层类型     Set .SpatialReference = New UnknownCoordinateSystem   End With   Set pFieldEdit.GeometryDef = pGeomDef   pFieldsEdit.AddField pField

 ' Add another miscellaneous text field   Set pField = New Field   Set pFieldEdit = pField   With pFieldEdit       .Length = 30       .Name = "MiscText"       .Type = esriFieldTypeString   End With   pFieldsEdit.AddField pField      ' Create the shapefile   ' (some parameters apply to geodatabase options and can be defaulted as Nothing)   Dim pFeatClass As IFeatureClass   Set pFeatClass = pFWS.CreateFeatureClass(sName, pFields, Nothing, _                                            Nothing, esriFTSimple, "Shape", "")                                              Set CreateShapefile = pFeatClass End Function

举报 回复(0) 喜欢(0)     评分
默认头像

返回顶部