VB+MO 两个点之间的距离
01-05
两个点之间的距离
Dim p1 As Point
Dim p2 As Point
Private Sub Command1_Click()
If p1 Is Nothing Then
Set p1 = Map1.Extent.Center
End If
Map1.Refresh
End Sub
Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE) Dim sym As New Symbol
sym.Color = moBlue
If Not p1 Is Nothing Then
Map1.DrawShape p1, sym
End If
If Not p2 Is Nothing Then
Map1.DrawShape p2, sym
End If
End Sub
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim dist As Double
If p1 Is Nothing Then
MsgBox "先点击显示点 "
Exit Sub
Else
Set p2 = Map1.ToMapPoint(X, Y)
dist = p2.DistanceTo(p1)
Map1.TrackingLayer.Refresh True
Label1.Caption = "距离=" & Format(dist, "fixed")
End If
End Sub