Here is a function that could be useful if you want to determine the distance between two coordinates. The distance is returned in Miles.
B4X:
'
' Return Distance between two points
'
Sub distance(lat1 As Double, lon1 As Double, lat2 As Double, lon2 As Double) As Double
Dim theta As Double
Dim dist As Double
theta = lon1 - lon2
dist = Sin(deg2rad(lat1)) * Sin(deg2rad(lat2)) + Cos(deg2rad(lat1)) * Cos(deg2rad(lat2)) * Cos(deg2rad(theta))
dist = ACos(dist)
dist = rad2deg(dist)
Return dist * 60 * 1.1515
End Sub
'
' This function converts decimal degrees to radians
'
Sub deg2rad(Deg As Double) As Double
Dim pi As Double= 3.14159265358979
Return Deg * pi / 180
End Sub
'
' This function converts radians to decimal degrees
'
Sub rad2deg(Rad As Double) As Double
Dim pi As Double= 3.14159265358979
Return Rad * 180 / pi
End Sub