阅读:3011回复:0
在mo中连接任意多个用鼠标点取的点
工程控件:map ctrole,check box,两个command
Option Explicit Dim lineConnectDots As New MapObjects2.Line Private Sub Command1_Click() If Map1.TrackingLayer.EventCount > 1 Then Dim TL As MapObjects2.TrackingLayer Dim partsColl As MapObjects2.Parts Dim pointsColl As New MapObjects2.Points 'Dim geoEvnt As MapObjects.GeoEvent Dim pointNew As New MapObjects2.Point Dim i As Long Set TL = Map1.TrackingLayer For i = 0 To (TL.EventCount - 1) pointNew.x = TL.Event(i).x pointNew.y = TL.Event(i).y pointsColl.Add pointNew Next Set partsColl = lineConnectDots.Parts partsColl.Add pointsColl Map1.TrackingLayer.Refresh True End If End Sub Private Sub Command2_Click() Map1.TrackingLayer.ClearEvents Set lineConnectDots = Nothing End Sub Private Sub Form_Load() Check1.Caption = "Add GeoEvents" Command1.Caption = "Connect the dots" Command2.Caption = "Clear the track" End Sub Private Sub Map1_BeforeTrackingLayerDraw(ByVal hDC As Stdole.OLE_HANDLE) If Not lineConnectDots Is Nothing Then Dim sym As New MapObjects2.Symbol Map1.DrawShape lineConnectDots, sym End If End Sub Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Check1 Then Dim pt As New MapObjects2.Point Set pt = Map1.ToMapPoint(x, y) Map1.TrackingLayer.AddEvent pt, 0 Map1.TrackingLayer.Refresh False End If End Sub |
|
|