I am developping a UWP application, and now im trying to calculate the distance between two points I alreday have their latitude and longitude . any ideas how to do that ?
Asked
Active
Viewed 1,937 times
0
-
1Also look at http://stackoverflow.com/questions/12446694/equivelant-of-net-geocoordinate-getdistanceto-in-windows-8-metro-style-apps – ezaspi Jul 11 '16 at 15:02
1 Answers
0
<maps:Map x:Name="myMap" Tap="ReadMapTap" />
And then translate the tap location into a GeoCoordinate like so:
void ReadMapTap(object sender, System.Windows.Input.GestureEventArgs e)
{
GeoCoordinate tapLocation =
distanceMap.ConvertViewportPointToGeoCoordinate(e.GetPosition((UIElement)sender));
}
Then we just create another GeoCoordinate, like maybe Microsoft campus:
GeoCoordinate Msft = new GeoCoordinate(47.6396, -122.1300);
And just ask one of our GeoCoordinates how far it is to the other one.
double distanceToMSFT = tapLocation.GetDistanceTo(Msft);
MessageBox.Show("It is " + distanceToMSFT.ToString() + " meters from there to Microsoft!");

suulisin
- 1,414
- 1
- 10
- 17
-
please let me know if it works for you and dont forget to voteup and accept and an answer if it helps you – suulisin Apr 30 '16 at 16:22
-
@nawfel So you want the exact method? Sorry nobody is going to do that work for you – Rahul Jha Apr 30 '16 at 18:47
-
i dont want any method @rahul im looking for how a distance betwwen places could be calculated – nawfel Apr 30 '16 at 23:17
-
1Please note that the GeoCoordinate class you are reffering to is not available in UWP. There is a class called Geocoordinate (without the capital C), but this class has no GetDistanceTo method. https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geocoordinate.aspx – Kristoffer Berge Nov 08 '16 at 23:58