阅读:2550回复:4
MO中的图形编辑
<P>你好,我想请教你关于在MO下做编辑的问题
我用下面代码得到curRec 后 For Each aLayer In frmMain.mapDisp.Layers If aLayer.Visible And aLayer.LayerType = moMapLayer Then Set curRec = aLayer.SearchByDistance(Loc, theTol, "") 'Loop through selected features and store pointers. If Not curRec Is Nothing Then Exit For End If Next aLayer</P> <P> 在图中 做修改得editPoly,进行编辑后, curRec.Edit curRec("shape").value = editPoly curRec.Update curRec.StopEditing curRec中,选中要素的修改( curRec("shape").value = editPoly),影响到了同层的其他要素,curRec的下一个记录被修改得editPoly替代了,为什么会出现这样呢?</P> <P> 此致! </P> |
|
1楼#
发布于:2004-07-09 12:20
<P>curRec("shape").value = editPoly相当于新增了一个图形</P><P>原来的图形并没有改变</P><P>recadd是一个图层的recordset</P><P> If recadd.Updatable Then
With frmMain.g_selectedFeatures '/是一个选择集只有一个点 .Edit .Delete .MoveNext .AutoFlush = True .StopEditing frmMain.mapDisp.Refresh End With With recadd .AddNew .AutoFlush = True .Fields("shape").value = addPt For fldnum = 0 To lblfld.Count - 1 .Fields(lblfld(fldnum).Caption).value = " " ; txtfld(fldnum).text Next .Update .StopEditing End With Else MsgBox "不能修改当前层,请检查文件属性!" End If For fldnum = 0 To frmMain.mapDisp.Layers.Count - 1 If frmMain.mapDisp.Layers(fldnum).Name = frmMain.g_ActiveLayer.Name Then frmMain.mapDisp.RefreshLayer fldnum, frmMain.mapDisp.Extent End If Next</P><img src="images/post/smile/dvbbs/em03.gif" /> |
|
2楼#
发布于:2004-05-09 20:30
不在图层中循环查找 又 怎么 能选中看到的图形要素 , 不循环的话那岂不是只能编辑当前层的图形要素 了?从程序的运行结果来看, 影响的不是多个图层中的要素,而是 影响了同一层的其它图形要素。这是为何?
|
|
3楼#
发布于:2004-05-04 17:03
<P>For Each aLayer In frmMain.mapDisp.Layers</P><P>你已经在图层中循环查找,所以影响的是多个图层中的要素,只要不循环就可以了</P>
|
|
4楼#
发布于:2004-04-30 15:35
<P>SearchByDistance(Loc, theTol, "")的范围错误?麻烦你看一看错在哪,如何改写这段?</P><P> Private Sub Identify(x As Single, y As Single)</P><P> Const SEARCHTOLPIXELS = 3</P><P> Dim Loc As New MapObjects2.Point</P><P> Dim theTol As Double</P><P> Dim aLayer As MapLayer</P><P> Set Loc = frmMain.mapDisp.ToMapPoint(x, y):</P><P> theTol = frmMain.mapDisp.ToMapDistance(SEARCHTOLPIXELS * Screen.TwipsPerPixelX)</P><P> For Each aLayer In frmMain.mapDisp.Layers</P><P> If aLayer.Visible And aLayer.LayerType = moMapLayer Then</P><P> Set curRec = aLayer.SearchByDistance(Loc, theTol, "")</P><P> If Not curRec Is Nothing Then Exit For</P><P> End If</P><P> Next aLayer</P><P> Screen.MousePointer = 0</P><P>End Sub</P>
|
|
5楼#
发布于:2004-04-30 14:43
可能是你SearchByDistance(Loc, theTol, "")的范围错误,所以把其他的记录也修改了
|
|
|