本文整理汇总了C#中MapControl.TrySetViewBoundsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MapControl.TrySetViewBoundsAsync方法的具体用法?C# MapControl.TrySetViewBoundsAsync怎么用?C# MapControl.TrySetViewBoundsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapControl
的用法示例。
在下文中一共展示了MapControl.TrySetViewBoundsAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateRoute
public static async void CalculateRoute(MapControl mapControl,double startLatitude, double startLongitude, double endLatitude, double endLongitude)
{
BasicGeoposition startLocation = new BasicGeoposition();
startLocation.Latitude = startLatitude;
startLocation.Longitude = startLongitude;
Geopoint startPoint = new Geopoint(startLocation);
BasicGeoposition endLocation = new BasicGeoposition();
endLocation.Latitude = endLatitude;
endLocation.Longitude = endLongitude;
Geopoint endPoint = new Geopoint(endLocation);
MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(
startPoint,
endPoint,
MapRouteOptimization.Time,
MapRouteRestrictions.None);
if (routeResult.Status == MapRouteFinderStatus.Success)
{
MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
viewOfRoute.RouteColor = Colors.Aqua;
viewOfRoute.OutlineColor = Colors.Black;
mapControl.Routes.Add(viewOfRoute);
await mapControl.TrySetViewBoundsAsync(
routeResult.Route.BoundingBox,
null,
Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow);
var distance = routeResult.Route.LengthInMeters.ToString();
}
}
示例2: setViewOnMap
public async Task setViewOnMap(List<BasicGeoposition> positions, MapControl map)
{
if (positions.Count == 0)
return;
var bounds = GeoboundingBox.TryCompute(positions);
double viewWidth = ApplicationView.GetForCurrentView().VisibleBounds.Width;
var margin = new Thickness((viewWidth >= 500 ? 300 : 10), 10, 10, 10);
bool isSuccessful = await map.TrySetViewBoundsAsync(bounds, margin, MapAnimationKind.Default);
if (isSuccessful && positions.Count < 2)
map.ZoomLevel = 15;
else if (!isSuccessful && positions.Count > 0)
{
map.Center = new Geopoint(positions[0]);
map.ZoomLevel = 15;
}
}