阅读:2747回复:6
不知道有没有人用Engine实现过ArcMap增加数据图层的对话框?
<P>我现在要做个这样的东东,由于要脱离ARCGIS平台,所以不能用esriCatalogUI.IGxDialog,要自己写一个,想想都很麻烦,shape文件还有tif倒好说,就是在geodatabase里面的那些东西???</P>
<P>不知道有没有人做过类似的,指导一下</P> |
|
|
1楼#
发布于:2005-12-22 16:33
<P>好象有点难</P>
|
|
2楼#
发布于:2005-12-24 14:05
<P>可以实现!已经做到,只是要考虑的类型复杂一点!</P>
[此贴子已经被作者于2005-12-24 14:06:22编辑过]
|
|
|
3楼#
发布于:2005-12-28 07:02
<P>waterblue<img src="images/post/smile/dvbbs/em05.gif" /></P>
<P>能不能把代码贴出来,好让大家一块提高</P><img src="images/post/smile/dvbbs/em01.gif" /> |
|
4楼#
发布于:2005-12-30 09:36
关注一下
|
|
|
5楼#
发布于:2006-01-09 14:42
<P><FONT size=1>花了3天时间做了个简单的:)主要代码如下</FONT></P>
<P><FONT size=1> Dim pFeatureClassContainer As IFeatureClassContainer<BR> Dim i As Integer, j As Integer<BR> Dim lSelectFCID As Long<BR> Dim i_Layers As Collection<BR> Set i_Layers = New Collection<BR> <BR> Dim i_EnumDataset As esriGeoDatabase.IEnumDataset<BR> Dim i_FeatWS As esriGeoDatabase.IFeatureWorkspace<BR> Dim i_FeatCls As esriGeoDatabase.IFeatureClass<BR> Dim i_FeatLyr As esriCarto.IFeatureLayer<BR> Dim className As String, sDataSet As String, sFileName As String<BR> Dim i_FDOGraphicsLayerFactory As esriCarto.IFDOGraphicsLayerFactory</FONT></P> <P><FONT size=1> Set pFeatureClassContainer = m_FeatureDataset<BR> For i = 1 To lvwLayer.ListItems.Count<BR> If lvwLayer.ListItems.Item(i).Selected Then<BR> If bFeatureClass Then '选中的要素类<BR> lSelectFCID = lvwLayer.ListItems.Item(i).SubItems(2)<BR> Set i_FeatCls = pFeatureClassContainer.ClassByID(lSelectFCID)<BR> If i_FeatCls.FeatureType = esriFTAnnotation Then<BR> Set i_FDOGraphicsLayerFactory = New FDOGraphicsLayerFactory<BR> Set i_FeatLyr = i_FDOGraphicsLayerFactory.OpenGraphicsLayer(i_FeatCls.FeatureDataset.Workspace, i_FeatCls.FeatureDataset, i_FeatCls.AliasName)<BR> Else<BR> Set i_FeatLyr = New FeatureLayer<BR> Set i_FeatLyr.FeatureClass = i_FeatCls<BR> i_FeatLyr.Name = i_FeatCls.AliasName<BR> End If<BR> i_Layers.Add i_FeatLyr<BR> <BR> ElseIf bFeatureDataset Then '选中的是要素集<BR> sDataSet = lvwLayer.ListItems.Item(i).Text<BR> Set m_FeatureDataset = f_FDataset_GetFeatureDataset(m_pAccessWorkspace, sDataSet)<BR> Set pFeatureClassContainer = m_FeatureDataset<BR> For j = 0 To pFeatureClassContainer.ClassCount - 1<BR> Set i_FeatCls = pFeatureClassContainer.Class(j)<BR> If i_FeatCls.FeatureType = esriFTAnnotation Then<BR> Set i_FDOGraphicsLayerFactory = New FDOGraphicsLayerFactory<BR> Set i_FeatLyr = i_FDOGraphicsLayerFactory.OpenGraphicsLayer(i_FeatCls.FeatureDataset.Workspace, i_FeatCls.FeatureDataset, i_FeatCls.AliasName)<BR> Else<BR> Set i_FeatLyr = New FeatureLayer<BR> Set i_FeatLyr.FeatureClass = i_FeatCls<BR> i_FeatLyr.Name = i_FeatCls.AliasName<BR> End If<BR> i_Layers.Add i_FeatLyr<BR> Next j<BR> ElseIf Right(lvwLayer.ListItems.Item(i).Text, 4) = ".shp" Then 'shapefile<BR> sFileName = lvwLayer.ListItems.Item(i).Text<BR> sFileName = Left(sFileName, Len(sFileName) - 4)<BR> Set i_FeatLyr = New FeatureLayer<BR> Set i_FeatLyr = AddShapeFile(File1.Path, sFileName)<BR> i_Layers.Add i_FeatLyr<BR> ElseIf Right(lvwLayer.ListItems.Item(i).Text, 4) = ".tif" Then '栅格图<BR> sFileName = lvwLayer.ListItems.Item(i).Text<BR> sFileName = File1.Path ; "\" ; sFileName<BR> Dim i_RLayer As IRasterLayer<BR> Set i_RLayer = New RasterLayer<BR> i_RLayer.CreateFromFilePath sFileName<BR> i_Layers.Add i_RLayer<BR> End If<BR> End If<BR> Next i<BR> <BR> ' now add the newly created layers in geometry order to the map<BR> <BR> '增加Raster图层 (RasterLayer)<BR> For i = 1 To i_Layers.Count<BR> If TypeOf i_Layers.Item(i) Is IRasterLayer Then<BR> CurrentMap.AddLayer i_Layers.Item(i)<BR> End If<BR> Next i</FONT></P> <P><FONT size=1> '增加矢量图层---------------------------------------------------<BR> '增加多边形图层<BR> For i = 1 To i_Layers.Count<BR> If TypeOf i_Layers.Item(i) Is IFeatureLayer Then<BR> If Not TypeOf i_Layers.Item(i) Is FDOGraphicsLayer Then<BR> Set i_FeatLyr = i_Layers.Item(i)<BR> Set i_FeatCls = i_FeatLyr.FeatureClass<BR> If (i_FeatCls.ShapeType = esriGeometryPolygon Or _<BR> i_FeatCls.ShapeType = esriGeometryEnvelope) Then<BR> CurrentMap.AddLayer i_Layers.Item(i)<BR> End If<BR> End If<BR> End If<BR> Next i<BR> <BR> '线图层<BR> For i = 1 To i_Layers.Count<BR> If TypeOf i_Layers.Item(i) Is IFeatureLayer Then<BR> If Not TypeOf i_Layers.Item(i) Is FDOGraphicsLayer Then<BR> Set i_FeatLyr = i_Layers.Item(i)<BR> Set i_FeatCls = i_FeatLyr.FeatureClass<BR> If (i_FeatCls.ShapeType = esriGeometryLine Or _<BR> i_FeatCls.ShapeType = esriGeometryPath Or _<BR> i_FeatCls.ShapeType = esriGeometryBezier3Curve Or _<BR> i_FeatCls.ShapeType = esriGeometryCircularArc Or _<BR> i_FeatCls.ShapeType = esriGeometryEllipticArc Or _<BR> i_FeatCls.ShapeType = esriGeometryPath Or _<BR> i_FeatCls.ShapeType = esriGeometryPolyline) Then<BR> <BR> CurrentMap.AddLayer i_Layers.Item(i)<BR> <BR> End If<BR> End If<BR> End If<BR> Next i<BR> <BR> '点图层<BR> For i = 1 To i_Layers.Count<BR> If TypeOf i_Layers.Item(i) Is IFeatureLayer Then<BR> If Not TypeOf i_Layers.Item(i) Is FDOGraphicsLayer Then<BR> Set i_FeatLyr = i_Layers.Item(i)<BR> Set i_FeatCls = i_FeatLyr.FeatureClass<BR> If (i_FeatCls.ShapeType = esriGeometryMultipoint Or _<BR> i_FeatCls.ShapeType = esriGeometryPoint) Then<BR> CurrentMap.AddLayer i_Layers.Item(i)<BR> End If<BR> End If<BR> End If<BR> Next i<BR> <BR> 'annotation图层 (FDOGraphicsLayers)<BR> For i = 1 To i_Layers.Count<BR> If TypeOf i_Layers.Item(i) Is IFeatureLayer Then<BR> If TypeOf i_Layers.Item(i) Is FDOGraphicsLayer Then<BR> CurrentMap.AddLayer i_Layers.Item(i)<BR> End If<BR> End If<BR> Next i<BR> '--------------------------------------------------------------------------<BR> <BR> <BR> 'The layers are in the correct order now add them to the map<BR> CurrentActiveView.Refresh<BR> </FONT></P> |
|
|
6楼#
发布于:2006-01-13 08:49
呵,谢谢楼主,上次在GISCHINA上看到过一个前人做好的加载图层工具,好像和ARCGIS的一模一样,呵,你可以借签一下
|
|
|