mo+vb实现沿国界运动

来源:互联网 发布:淘宝卖家信誉度怎么看 编辑:程序博客网 时间:2024/05/17 07:37
 Dim ploygon As MapObjects2.Polygon
Dim Num As Integer
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Num = 0
Dim recs1 As MapObjects2.Recordset
Dim p1 As MapObjects2.Point
Set Layer1 = Map1.Layers(0)
Set p1 = Map1.ToMapPoint(X, Y)
Set recs1 = Layer1.SearchByDistance(p1, 0.1, "")
Timer1.Interval = 0
If Not recs1.EOF And Map1.Layers(0).Visible = True Then
Set ploygon = recs1("Shape").Value
Timer1.Interval = 10
End If
End Sub
Private Sub Timer1_Timer()
On Error GoTo error
Dim poly As New MapObjects2.Polygon
If ploygon.Parts(0).Count <= 0 Then
Timer1.Interval = 0
Num = 0
Exit Sub
End If
Dim pt As New MapObjects2.Point
Dim pts As New MapObjects2.Points
If Map1.TrackingLayer.EventCount > 0 Then
Map1.TrackingLayer.ClearEvents
End If
pt.X = ploygon.Parts(0).Item(Num).X
pt.Y = ploygon.Parts(0).Item(Num).Y
Map1.TrackingLayer.AddEvent pt, 0
Num = Num + 1
error:
End Sub
Private Sub Form_Load()
Num = 0
Map1.TrackingLayer.SymbolCount = 1
With Map1.TrackingLayer.Symbol(0)
.SymbolType = moFillSymbol
.Color = moRed
.Style = 0
.Size = 1
.OutlineColor = moRed
End With
End Sub
程序可以任意选择多边形对象进行沿国界运动!!
原创粉丝点击