VBA之添加Shape图层
2012-11-08 02:44
239 查看
参考DeskTop帮助文档
准备:添加一个Button控件
Tools—>Customize—>Commands tab—> UIControl—>IButtonControl
在该Button的Click事件中添加以下代码:
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Dim pWorkSpace As IFeatureWorkspace
'Change ‘e:\street’ to the source location of the shapefile you wish to add
Set pWorkSpace = pWorkspaceFactory.OpenFromFile("e:\street", 0)
Dim pClass As IFeatureClass
'Change polygon to the name of the shapefile you wish to add
Set pClass = pWorkSpace.OpenFeatureClass("polygon")
Dim pLayer As IFeatureLayer
Set pLayer = New FeatureLayer
Set pLayer.FeatureClass = pClass
pLayer.Name = pClass.AliasName
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
pMxDoc.AddLayer pLayer
pMxDoc.ActiveView.PartialRefresh esriViewGeography, pLayer, Nothing
准备:添加一个Button控件
Tools—>Customize—>Commands tab—> UIControl—>IButtonControl
在该Button的Click事件中添加以下代码:
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Dim pWorkSpace As IFeatureWorkspace
'Change ‘e:\street’ to the source location of the shapefile you wish to add
Set pWorkSpace = pWorkspaceFactory.OpenFromFile("e:\street", 0)
Dim pClass As IFeatureClass
'Change polygon to the name of the shapefile you wish to add
Set pClass = pWorkSpace.OpenFeatureClass("polygon")
Dim pLayer As IFeatureLayer
Set pLayer = New FeatureLayer
Set pLayer.FeatureClass = pClass
pLayer.Name = pClass.AliasName
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
pMxDoc.AddLayer pLayer
pMxDoc.ActiveView.PartialRefresh esriViewGeography, pLayer, Nothing
相关文章推荐
- 在当前地图窗口添加一个Shape文件为一个图层(VBA)
- vba为每行中最小值单元格添加背景颜色
- VBA 添加简单菜单(有分割线)
- ArcObject之添加矢量图层
- arcengine C#关于动态添加图层
- ArcGIS的shapefile图层有别名和真实名称,获取真实名称的方法
- MapServer6.4.1教程学习--添加栅格图层(1-5)
- android动态添加图层
- 向SDE图层中添加大量数据时,出现ORA-00604以及ORA-01000的解决办法
- VBA添加表格
- Android 使用shape添加边框
- MapObjects的二次开发之添加图层
- VBA Tips:为VBA program添加数字签名
- 高德地图实现公交路线-添加标记-轨迹回放-中心点-图层
- 使用shape或者layer-list实现view周边添加边框
- 通过宏(vba)在邮件合并中添加附件
- 创建点实体图层--向量图层,为什么在图层管理器中没有添加点、线、面的按钮?
- vba 为图片添加链接
- 在Delphi下基于MapWinGIS添加和删除图层标注的方法
- VBA 工作表的添加与删除