阅读:1884回复:5
怎样把屏幕上画的点加到已存在的图层中?
<P>我想在MapControl控件中画一点后让该点加到已经加载到控件中的图层中,怎么做呀?</P>
|
|
1楼#
发布于:2007-05-19 14:34
帮顶
|
|
2楼#
发布于:2007-05-21 21:07
<P>得到要保存到的那个图层的featureclass</P>
<P>然后用feature=<EM>Ifeatureclass.createfeature新建一个要素</EM></P> <P><EM>然后将点的shape赋值给feature.shape</EM></P> <P><EM>然后feature.stor</EM></P> |
|
3楼#
发布于:2007-05-22 11:56
<P>谢谢,已搞定!</P>
|
|
4楼#
发布于:2007-09-13 17:38
<P><STRONG>楼主,我也碰到这个问题,我按照<FONT face=Verdana color=#61b713>haihunyunpo朋友<FONT color=#000000>说的也做不出来,</FONT></FONT></STRONG></P>
<P><STRONG><FONT face=Verdana color=#61b713><FONT color=#000000> 你能把你的源代码共享一下吗,谢谢!</FONT></FONT></STRONG></P> |
|
5楼#
发布于:2007-09-19 10:33
<P>Private Sub CreateFeature(pGeom As IGeometry)<BR> Dim pWorkspaceEdit As IWorkspaceEdit<BR> Dim pFeatureLayer As IFeatureLayer<BR> Dim pFeatureClass As IFeatureClass<BR> Dim pFeature As IFeature<BR> <BR> On Error GoTo CreateFeature_err<BR> <BR> If pGeom Is Nothing Then Exit Sub<BR> If m_pCurrentLayer Is Nothing Then Exit Sub<BR> <BR> ' Create the feature<BR> Set pWorkspaceEdit = GetWorkspaceEdit<BR> Set pFeatureLayer = m_pCurrentLayer<BR> Set pFeatureClass = pFeatureLayer.FeatureClass<BR> pWorkspaceEdit.StartEditOperation<BR> Set pFeature = pFeatureClass.CreateFeature<BR> Set pFeature.Shape = pGeom<BR> pFeature.Store<BR> pWorkspaceEdit.StopEditOperation<BR> <BR> ' Select the feature that's been created<BR> m_pMap.SelectFeature m_pCurrentLayer, pFeature</P>
<P> ' Refresh the relevant area of the active view<BR> Dim pActiveView As IActiveView<BR> Set pActiveView = m_pMap<BR> If pGeom.GeometryType = esriGeometryPoint Then<BR> Dim length As Double<BR> length = ConvertPixelsToMapUnits(m_pMap, 30)<BR> Dim pTopo As ITopologicalOperator<BR> Set pTopo = pGeom<BR> Dim pBuffer As IGeometry<BR> Set pBuffer = pTopo.Buffer(length)<BR> pActiveView.PartialRefresh esriDPGeography Or esriDPSelection, m_pCurrentLayer, pBuffer.Envelope<BR> Else<BR> pActiveView.PartialRefresh esriDPGeography Or esriDPSelection, m_pCurrentLayer, pGeom.Envelope<BR> End If<BR> <BR> Exit Sub<BR>CreateFeature_err:<BR> MsgBox Err.Description<BR>End Sub</P> |
|