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


C# MapView.ToView方法代码示例

本文整理汇总了C#中MapView.ToView方法的典型用法代码示例。如果您正苦于以下问题:C# MapView.ToView方法的具体用法?C# MapView.ToView怎么用?C# MapView.ToView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapView的用法示例。


在下文中一共展示了MapView.ToView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainPage

        public MainPage()
        {
            // Be sure to register your license in native code or in an #if case.
            // Even if your package names are identical, licenses are platform-specific.
            // This sample register's license in App.xaml.cs

            AbsoluteLayout view = new AbsoluteLayout();

            // Since MapView is a native element, initialize and set its size natively
            // minimal platform-specific code is needed to create MapView

            #if __ANDROID__
            MapView = new MapView(Xamarin.Forms.Forms.Context);
            #elif WINDOWS_PHONE
            MapView = new MapView();

            Windows.Foundation.Rect bounds = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds;
            MapView.Width = bounds.Width;
            MapView.Height = bounds.Height;
            #elif __IOS__
            MapView = new MapView();
            // Set ScreenBounds in AppDelegate so they would be conveniently available here
            MapView.Frame = iOS.AppDelegate.ScreenBounds;
            #endif

            // all the remaining usage of MapView is cross-platform
            view.Children.Add(MapView.ToView());
            Content = view;

            // Add default base layer
            var baseLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);
            MapView.Layers.Add(baseLayer);

            // Set projection
            Projection projection = MapView.Options.BaseProjection;

            // Set default position and zoom
            // Change projection of map so coordinates would fit on a mercator map
            MapPos berlin = MapView.Options.BaseProjection.FromWgs84(new MapPos(13.38933, 52.51704));
            MapView.SetFocusPos(berlin, 0);
            MapView.SetZoom(10, 0);

            // Custom extension method. cf Extensions.cs
            MapView.AddMarkerToPosition(berlin);

            // Good place to set the sizes and positions of Children,
            // similar to LayoutSubviews of iOS and OnLayout of Android
            view.SizeChanged += OnSizeChanged;

            Button button = new Button();
            button.BackgroundColor = Color.FromRgb(117, 58, 97);
            button.TextColor = Color.White;
            button.Text = "Hide Marker";

            button.VerticalOptions = LayoutOptions.EndAndExpand;
            button.HorizontalOptions = LayoutOptions.EndAndExpand;

            view.Children.Add(button);

            button.Clicked += OnButtonClick;
        }
开发者ID:CartoDB,项目名称:mobile-dotnet-samples,代码行数:61,代码来源:MainPage.cs


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