wuhanpl
路人甲
路人甲
  • 注册日期2006-05-06
  • 发帖数20
  • QQ
  • 铜币340枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1885回复:5

怎样把屏幕上画的点加到已存在的图层中?

楼主#
更多 发布于:2007-05-19 12:10
<P>我想在MapControl控件中画一点后让该点加到已经加载到控件中的图层中,怎么做呀?</P>
喜欢0 评分0
追风浪子
路人甲
路人甲
  • 注册日期2004-06-08
  • 发帖数166
  • QQ
  • 铜币782枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于: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>
举报 回复(0) 喜欢(0)     评分
jmps
路人甲
路人甲
  • 注册日期2007-08-31
  • 发帖数21
  • QQ
  • 铜币197枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于: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>
举报 回复(0) 喜欢(0)     评分
wuhanpl
路人甲
路人甲
  • 注册日期2006-05-06
  • 发帖数20
  • QQ
  • 铜币340枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-05-22 11:56
<P>谢谢,已搞定!</P>
举报 回复(0) 喜欢(0)     评分
haihunyunpo
路人甲
路人甲
  • 注册日期2005-08-29
  • 发帖数21
  • QQ
  • 铜币206枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于: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>
举报 回复(0) 喜欢(0)     评分
lordaeron
路人甲
路人甲
  • 注册日期2005-07-30
  • 发帖数27
  • QQ
  • 铜币226枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2007-05-19 14:34
帮顶
举报 回复(0) 喜欢(0)     评分
游客

返回顶部