当前位置: 首页>>代码示例>>C#>>正文


C# MapControl.TrySetViewBoundsAsync方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:Wizjonersky,项目名称:TaxiCalculator,代码行数:35,代码来源:RouteCalculator.cs

示例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;
     }
 }
开发者ID:ngducnghia,项目名称:TripTrak-2016,代码行数:16,代码来源:HomeViewModel.cs


注:本文中的MapControl.TrySetViewBoundsAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。