Here are some code snippets that I extracted from an app I have. I don't have anything that gives an isolated, complete example.
I use Google Services. Of course, your path to the gms file will be different. From my Projects Attributes region:
#AdditionalRes: C:\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
These are the libraries I have selected for one of my projects. They are not all specifically required to find the direction and distance between two points.
View attachment 67817
These are my global Google Maps variables, plus I use the excellent MapsExtras found elsewhere on the forum:
Dim mfMap As MapFragment
Dim mpMap As GoogleMap
Dim gmExtra As GoogleMapsExtras
This code maintains a global variable, PhoneBearing, set during a compass change event from my compass library (see above)
Sub GeoRot_Bearing(bng As Double)
PhoneBearing = bng
' Log("PhoneBearing: " & NumberFormat(PhoneBearing, 3, 0))
End Sub
This is the code using Google Maps (and maybe MapsExtras) that computes the distance. You have to use your imagination a little about where the specific variables come from:
' Compute distance
Dim loc1, loc2 As Location
loc1.Initialize2(CurrLoc.loc.Latitude, CurrLoc.loc.Longitude)
loc2.Initialize2(MarkerLoc.Lat, MarkerLoc.Lon)
Dim dist As Float = loc1.DistanceTo(loc2)
I hope this helps. These code snippets can be used together to implement the distance and bearing between two points solution.
Barry.