|
阅读:1341回复:1
请各位朋友帮我写一下注释,就写在程序边上
<P>Dim m_ptsDemo As MapObjects2.Points
Dim m_nNum As Integer Dim m_Evt As GeoEvent Dim m_bIsMove As Boolean</P> <P>Private Sub Form_Load() Dim Layer As MapLayer Dim dc As New DataConnection dc.Database = App.Path If Not dc.Connect Then MsgBox "在指定的文件夹下没找到图层数据文件,退出GIS!" Unload Me Exit Sub End If Set Layer = New MapLayer Set Layer.GeoDataset = dc.FindGeoDataset("图层 1_l") Layer.Name = "图层 1" Layer.Symbol.Color = moRed Layer.Symbol.Size = 2 Map1.Layers.Add Layer Map1.Refresh Map1.TrackingLayer.SymbolCount = 2 With Map1.TrackingLayer.Symbol(0) .SymbolType = moPointSymbol .Color = moBlue .Style = 0 .Size = 8 End With With Map1.TrackingLayer.Symbol(1) .SymbolType = moLineSymbol .Color = moBlue .Style = 0 .Size = 5 End With m_bIsMove = True Num = 0 End Sub</P> <P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim p1 As MapObjects2.Point Dim theTol Dim line theTol = Map1.ToMapDistance(300) Set Layer1 = Map1.Layers(0) Set p1 = Map1.ToMapPoint(X, Y) Set recs1 = Layer1.SearchByDistance(p1, theTol, "") Timer1.Interval = 0 If Button = 2 Then Timer1.Interval = 0 Map1.TrackingLayer.ClearEvents Exit Sub Else Map1.TrackingLayer.ClearEvents m_nNum = 0 End If If Not recs1.EOF And Map1.Layers(0).Visible = True Then Set line = recs1("Shape").Value Set m_ptsDemo = New MapObjects2.Points For Each pt In line.Parts(0) m_ptsDemo.Add pt Next pt p1.X = m_ptsDemo.Item(0).X p1.Y = m_ptsDemo.Item(0).Y Set m_Evnt = Map1.TrackingLayer.AddEvent(p1, 0) m_bIsMove = True Timer1.Interval = 500 End If End Sub</P> <P>Private Sub Timer1_Timer() Dim count As Integer Dim X, Y If m_bIsMove And Map1.TrackingLayer.EventCount > 0 Then count = m_nNum If count >= m_ptsDemo.count Then Timer1.Interval = 0 MsgBox "END" Exit Sub End If Set m_Evnt = Map1.TrackingLayer.Event(0) m_nNum = m_nNum + 1 X = m_ptsDemo.Item(count).X Y = m_ptsDemo.Item(count).Y m_Evnt.MoveTo X, Y End If End Sub </P> |
|
|
1楼#
发布于:2004-08-31 08:59
<P>这不是MO自带的例子吗?看看运行情况再理解程序吧!</P>
|
|
|