如何使用 Windows Phone 地图控件找到离我当前位置最近的兴趣点?
How can I find the nearest point of intrest to my current location with the Windows Phone Map control?
我需要在 windows phone 8.1.
上使用地图控件找出离用户当前位置最近的位置(在本例中是医生办公室)
我在 XML 文件(纬度、经度)中提供了我的位置信息。
是否有函数可以 return 计算出我 XML 文件中所有点的距离?
有什么方法可以 运行 异步或在后台运行?
有什么方法可以让地图上的图钉动起来(例如,让它看起来像是在跳跃)?
为了计算距离,我总是在 BasicGeoposition
class 上使用以下扩展方法。
要在后台执行此操作,请使用 Task.Run(() => )
.
public static double GetDistanceTo(this BasicGeoposition from, double toLatitude, double toLongitude)
{
if (double.IsNaN(from.Latitude) || double.IsNaN(from.Longitude))
{
throw new ArgumentException("On of the given Latitude or Longitudes is not correct");
}
else
{
double latitude = from.Latitude * 0.0174532925199433;
double longitude = from.Longitude * 0.0174532925199433;
double num = toLatitude * 0.0174532925199433;
double longitude1 = toLongitude * 0.0174532925199433;
double num1 = longitude1 - longitude;
double num2 = num - latitude;
double num3 = Math.Pow(Math.Sin(num2 / 2), 2) + Math.Cos(latitude) * Math.Cos(num) * Math.Pow(Math.Sin(num1 / 2), 2);
double num4 = 2 * Math.Atan2(Math.Sqrt(num3), Math.Sqrt(1 - num3));
double num5 = 6376500 * num4;
return num5;
}
}
我需要在 windows phone 8.1.
上使用地图控件找出离用户当前位置最近的位置(在本例中是医生办公室)我在 XML 文件(纬度、经度)中提供了我的位置信息。
是否有函数可以 return 计算出我 XML 文件中所有点的距离?
有什么方法可以 运行 异步或在后台运行?
有什么方法可以让地图上的图钉动起来(例如,让它看起来像是在跳跃)?
为了计算距离,我总是在 BasicGeoposition
class 上使用以下扩展方法。
要在后台执行此操作,请使用 Task.Run(() => )
.
public static double GetDistanceTo(this BasicGeoposition from, double toLatitude, double toLongitude)
{
if (double.IsNaN(from.Latitude) || double.IsNaN(from.Longitude))
{
throw new ArgumentException("On of the given Latitude or Longitudes is not correct");
}
else
{
double latitude = from.Latitude * 0.0174532925199433;
double longitude = from.Longitude * 0.0174532925199433;
double num = toLatitude * 0.0174532925199433;
double longitude1 = toLongitude * 0.0174532925199433;
double num1 = longitude1 - longitude;
double num2 = num - latitude;
double num3 = Math.Pow(Math.Sin(num2 / 2), 2) + Math.Cos(latitude) * Math.Cos(num) * Math.Pow(Math.Sin(num1 / 2), 2);
double num4 = 2 * Math.Atan2(Math.Sqrt(num3), Math.Sqrt(1 - num3));
double num5 = 6376500 * num4;
return num5;
}
}