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.

有帮助吗?

解决方案 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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top