本文整理汇总了C#中Place.GetDistance方法的典型用法代码示例。如果您正苦于以下问题:C# Place.GetDistance方法的具体用法?C# Place.GetDistance怎么用?C# Place.GetDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Place
的用法示例。
在下文中一共展示了Place.GetDistance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDistanceToPlace
public static string GetDistanceToPlace (Place place, Position position)
{
if (Math.Abs (position.Latitude) < double.Epsilon && Math.Abs (position.Longitude) < double.Epsilon)
return string.Empty;
string distance = place.GetDistance (position.Latitude, position.Longitude,
CultureInfo.CurrentCulture.Name != "en-US" ?
CoffeeFilter.Shared.GeolocationUtils.DistanceUnit.Kilometers :
CoffeeFilter.Shared.GeolocationUtils.DistanceUnit.Miles).ToString ("##.###", CultureInfo.CurrentUICulture);
return string.Format ("{0} {1}", distance, CultureInfo.CurrentCulture.Name != "en-US" ? "km" : "mi.");
}
示例2: CreateNewInstance
public static PlaceFragment CreateNewInstance(Place place, Position position)
{
var b = new Bundle ();
b.PutString ("name", place.Name);
b.PutString ("distance", place.GetDistance (position.Latitude,
position.Longitude, CultureInfo.CurrentCulture.Name != "en-US" ?
CoffeeFilter.Shared.GeolocationUtils.DistanceUnit.Kilometers :
CoffeeFilter.Shared.GeolocationUtils.DistanceUnit.Miles).ToString ("##.###", CultureInfo.CurrentUICulture));
b.PutString ("rating", place.Rating.ToString ("#.#", CultureInfo.CurrentUICulture));
b.PutDouble ("lat", place.Geometry.Location.Latitude);
b.PutDouble ("lng", place.Geometry.Location.Longitude);
b.PutString ("placeId", place.PlaceId);
return new PlaceFragment {
Arguments = b
};
}