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


C# MapView.AddMarkerToPosition方法代码示例

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


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

示例1: OnLaunched

        // Invoked when the application is launched normally by the end user.
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            // Register CARTO license
            bool registered = MapView.RegisterLicense(License);

            if (registered)
            {
                Carto.Utils.Log.ShowDebug = true;
            }

            MapView = new MapView();

            // Add base map

            // TODO: Crashes here for some reason
            CartoOnlineVectorTileLayer baseLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDark);
            MapView.Layers.Add(baseLayer);

            // Set default location and zoom
            Projection projection = MapView.Options.BaseProjection;

            MapPos tallinn = projection.FromWgs84(new MapPos(24.646469, 59.426939));
            MapView.AddMarkerToPosition(tallinn);

            MapView.SetFocusPos(tallinn, 0);
            MapView.SetZoom(3, 0);

            Window.Current.Content = MapView;
            Window.Current.Activate();
        }
开发者ID:CartoDB,项目名称:mobile-dotnet-samples,代码行数:31,代码来源:App.xaml.cs

示例2: OnCreate

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Register license
            MapView.RegisterLicense(LICENSE, ApplicationContext);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            MapView = (MapView)FindViewById(Resource.Id.mapView);

            // Add base map
            CartoOnlineVectorTileLayer 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);

            Marker marker = MapView.AddMarkerToPosition(berlin);

            // Add simple event listener that changes size and/or color on map click
            MapView.MapEventListener = new HelloMapEventListener(marker);
        }
开发者ID:CartoDB,项目名称:mobile-dotnet-samples,代码行数:29,代码来源:MainActivity.cs

示例3: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            MapView = View as MapView;

            // Add base map
            CartoOnlineVectorTileLayer 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);

            Marker marker = MapView.AddMarkerToPosition(berlin);

            // Add simple event listener that changes size and/or color on map click
            MapView.MapEventListener = new HelloMapEventListener(marker);
        }
开发者ID:CartoDB,项目名称:mobile-dotnet-samples,代码行数:24,代码来源:ViewController.cs

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