2
votes

My app currently uses Location Services. During debugging, I retrieve my current location using GetLastKnownLocationAsync: myposition.Latitude is 40.758896 while myposition.Latitude is -73.985130.

My SQL Database has a list of Walmart stores, and there's a Walmart with Latitude & Longitude of 40.660992 & -73.7267629.

How can I calculate the driving distance between my set of coordinates and Walmart's coordinates? It would be something like Google Maps' Driving Directions or Waze.

I understand that I can use this SO link to calculate the distance between two sets of point, but I assume apps like Google Maps or Waze consider the actual driving distance between two sets of points. The link above would be great if there were a straight street between two points. Obviously, that's not the case.

1
you need to find a GPS service that will provide this data for you. Like developers.google.com/maps/documentation/directions/startJason
Example service would be microsoft.com/en-us/maps/distance-matrixDepechie

1 Answers

0
votes

I have used Xamarin.Essential library to find the distance between two point

You can use something like this

  var location = new Location(21.705723, 72.998199);
  var otherLocation = new Location(22.3142, 73.1752);
  double distance =  location.CalculateDistance(otherLocation,DistanceUnits.Kilometers);