gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
阅读:3011回复:0

在mo中连接任意多个用鼠标点取的点

楼主#
更多 发布于:2003-07-26 22:49
工程控件: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


喜欢0 评分0
GIS麦田守望者,期待与您交流。
游客

返回顶部