Pregunta

In Windows Phone 8 when i have a longitude and latitude for a specific location, how can i calculate the distance between my device and this specific location.

I need a message box to be shown and say to user that is 2 km between you and this specific point.

¿Fue útil?

Solución 2

When you want to calculate the distance, you best use the GeoCoordinate class. It has a method called GetDistanceTo that will give you the distance from the used GeoCoordinate to a given other GeoCoordinate.

Details on MSDN here http://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.getdistanceto(v=vs.110).aspx

Otros consejos

you can get device current location like this:

var geolocator = new Geolocator();
Geoposition position = await geolocator.GetGeopositionAsync();
Geocoordinate geoCoordinate1= position.Coordinate;

then you can use:

geoCoordinate1.GetDistanceTo(geoCoordinate2);

where geoCoordinate2 is the one which you have already.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top