|
阅读:1657回复:2
[分享]利用点分割线的代码(split)
<P>用mo2.0以及以上版本,控件就是mo,和两个option</P>
<P>Option Explicit<BR>Private m_lnWhole As MapObjects2.Line<BR>Private m_lnFirst As MapObjects2.Line<BR>Private m_lnSecond As MapObjects2.Line<BR>Private m_symWhole As MapObjects2.Symbol<BR>Private m_symFirst As MapObjects2.Symbol<BR>Private m_symSecond As MapObjects2.Symbol<BR>'</P> <P>Private Sub Form_Load()</P> <P>'Setup line symbology<BR>Set m_symWhole = New MapObjects2.Symbol<BR>With m_symWhole<BR> .SymbolType = moLineSymbol<BR> .Color = moBlack<BR> .Size = 2<BR>End With<BR>Set m_symFirst = New MapObjects2.Symbol<BR>With m_symFirst<BR> .SymbolType = moLineSymbol<BR> .Color = RGB(255, 200, 200)<BR> .Size = 8<BR>End With<BR>Set m_symSecond = New MapObjects2.Symbol<BR>With m_symSecond<BR> .SymbolType = moLineSymbol<BR> .Color = RGB(200, 255, 200)<BR> .Size = 8<BR>End With</P> <P>'Label instructions<BR>Option1.Caption = "Draw line"<BR>Option2.Caption = "Split line"</P> <P>End Sub</P> <P>Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)</P> <P>'If lines exist, draw them<BR>If Not m_lnFirst Is Nothing Then<BR> Map1.DrawShape m_lnFirst, m_symFirst<BR>End If<BR>If Not m_lnSecond Is Nothing Then<BR> Map1.DrawShape m_lnSecond, m_symSecond<BR>End If<BR>If Not m_lnWhole Is Nothing Then<BR> Map1.DrawShape m_lnWhole, m_symWhole<BR>End If</P> <P>End Sub</P> <P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)</P> <P>Dim pt As MapObjects2.Point<BR>Dim dTol As Double<BR>Dim dMeasure As Double</P> <P>Select Case True<BR> Case Option1 'Draw the line<BR> Set m_lnWhole = Map1.TrackLine<BR> Case Option2 'Split the line at the clicked point<BR> If Not m_lnWhole Is Nothing Then<BR> Set pt = Map1.ToMapPoint(X, Y)<BR> dTol = Map1.ToMapDistance(3 * Screen.TwipsPerPixelX)<BR> If pt.DistanceTo(m_lnWhole) <= dTol Then<BR> m_lnWhole.SetMeasuresAsLength<BR> dMeasure = m_lnWhole.ReturnMeasure(pt)<BR> Set m_lnFirst = m_lnWhole.ReturnLineEvent(0, dMeasure)<BR> Set m_lnSecond = m_lnWhole.ReturnLineEvent(dMeasure, m_lnWhole.Length)<BR> End If<BR> End If<BR>End Select<BR> <BR>'Redraw the map to trigger layer draw events.<BR>Map1.Refresh</P> <P>End Sub<BR></P> |
|
|
|
1楼#
发布于:2007-08-21 20:39
<P>有delphi 源码没?</P>
|
|
|
2楼#
发布于:2006-03-01 17:01
有没有ArcEngine的原代码啊
|
|