Sub updateDirections
Dim source, destination As String
Dim jo As JavaObject
Dim Points As List
Dim res As Int
Dim curloc As LatLng
curloc.Initialize(LastLoc.Latitude, LastLoc.Longitude)
Points.Initialize
jo.InitializeStatic("com.poly.PolyUtil")
Points = pline.Points
Dim tolerance As Double
tolerance = 10
res = jo.RunMethod("locationIndexOnPath", Array(curloc, Points, False, tolerance))
Dim res1 As Double
Dim p1, p2 As LatLng
Dim pathdata As String
p1.Initialize(LastLoc.Latitude, LastLoc.Longitude)
pathdata = pathdata & "last loc " & LastLoc.Latitude & ", " & LastLoc.Longitude & CRLF
If res = -1 Then
source = LastLoc.Latitude & "," & LastLoc.Longitude
destination = DestLoc.Latitude & "," & DestLoc.Longitude
p2 = Points.Get(0)
GetDirections(source, destination)
Else
p2 = Points.Get(res)
If res = 0 Then
Dim resll As LatLng
jo.InitializeStatic("com.poly.PolyUtil")
resll = jo.RunMethod("intersectOnLine", Array(curloc, Points.Get(0), Points.Get(1)))
If resll.Latitude <> 0 And resll.Longitude <> 0 Then
Points.Set(0, resll)
pline.Points = Points
pline.Color = Colors.Red
End If
Else
If Points.Size > 2 Then
For i = 0 To res - 1
Points.RemoveAt(0)
Next
pline.Points = Points
pline.Color = Colors.Green
End If
End If
End If
End Sub