```
Sub decodePoly(encoded As String, poly As List)
Private b, index, Lat, Lng, dlat, dlng, flat, flng, shift, result As Int : index = 0 : Lat = 0 : Lng = 0
Private MyPoint As LatLng
Private Lat1, Lng1 As Double
Do While index < encoded.Length
shift = 0 : result = 0
Do While True
b = Asc(encoded.SubString2(index, index + 1)) - 63 : index = index + 1
result = Bit.OR(result, Bit.ShiftLeft( Bit.AND( b, 0x1f), shift))
shift = shift + 5
If b < 0x20 Then Exit
Loop
If Bit.AND(result, 1) = 1 Then
dlat = Bit.Not(Bit.ShiftRight(result, 1))
Else
dlat = Bit.ShiftRight(result, 1)
End If
Lat = Lat + dlat
shift = 0 : result = 0
Do While True
b = Asc(encoded.SubString2(index, index + 1)) - 63 : index = index + 1
result = Bit.OR(result, Bit.ShiftLeft(Bit.AND(b, 0x1f), shift))
shift = shift + 5
If b < 0x20 Then Exit
Loop
If Bit.AND(result, 1) = 1 Then
dlng = Bit.Not(Bit.ShiftRight(result, 1))
Else
dlng = Bit.ShiftRight(result, 1)
End If
Lng = Lng + dlng
flat = Lat
flng = Lng
Dim mpiCurrent As MapPointItem
mpiCurrent.Initialize
mpiCurrent.iPassed = 0
Lat1 = flat / 1E5
Lng1 = flng / 1E5
MyPoint.Initialize(Lat1,Lng1)
WayPoints.Add(MyPoint)
Log(WayPoints)
Loop
End Sub
```