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


C# MKMapView.AddOverlay方法代码示例

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


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

示例1: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
			
            // Perform any additional setup after loading the view, typically from a nib.

            // add the map view
            var map = new MKMapView(UIScreen.MainScreen.Bounds);
            View.Add(map);

            // change the map style
            map.MapType = MKMapType.Standard;

            // enable/disable interactions
            // map.ZoomEnabled = false;
            // map.ScrollEnabled = false;

            // show user location
			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				locationManager.RequestWhenInUseAuthorization();
			}
            map.ShowsUserLocation = true;

            // specify a custom map delegate
            var mapDelegate = new MyMapDelegate();
            map.Delegate = mapDelegate;

            // add a point annotation
            map.AddAnnotation(new MKPointAnnotation()
            {
                Title = "MyAnnotation",
                Coordinate = new CLLocationCoordinate2D(42.364260, -71.120824)
            });

            // add a custom annotation
            // map.AddAnnotation(new CustomAnnotation("CustomSpot", new CLLocationCoordinate2D(38.364260, -68.120824)));

            // TODO: Step 4a - draw a circle overlay
            var circleOverlay = MKCircle.Circle(new CLLocationCoordinate2D(33.755, -84.39), 100 * 1609.34); // 1609.34 = meters in a mile
            map.AddOverlay(circleOverlay);

            // TODO: Step 4b - draw a polygon (Wyoming)
            var stateOverlay = MKPolygon.FromCoordinates(new CLLocationCoordinate2D[]
                {
                    new CLLocationCoordinate2D(45.00, -111.00),
                    new CLLocationCoordinate2D(45, -104),
                    new CLLocationCoordinate2D(41, -104),
                    new CLLocationCoordinate2D(41, -111)
                });
            map.AddOverlay(stateOverlay);
        }
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:51,代码来源:MappingAppViewController.cs

示例2: ViewDidLoad

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

            Title = "Pyramids of Giza";

            mapView = new MKMapView(View.Bounds);
            mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
            View.AddSubview(mapView);

            var coords = new CLLocationCoordinate2D(29.976111, 31.132778); // pyramids of giza, egypt
            var span = new MKCoordinateSpan(MilesToLatitudeDegrees(.75), MilesToLongitudeDegrees(.75, coords.Latitude));
            // set the coords and zoom on the map
            mapView.MapType = MKMapType.Satellite;
            mapView.Region = new MKCoordinateRegion(coords, span);

            mapView.OverlayRenderer = (m, o) => {
                if(circleRenderer == null)
                {
                    circleRenderer = new MKCircleRenderer(o as MKCircle);
                    circleRenderer.FillColor = UIColor.Purple;
                    circleRenderer.Alpha = 0.5f;
                }
                return circleRenderer;
            };

            circleOverlay = MKCircle.Circle (coords, 200);
            mapView.AddOverlay (circleOverlay);

            #region Not related to this sample
            int typesWidth=260, typesHeight=30, distanceFromBottom=60;
            mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
            mapTypes.InsertSegment("Road", 0, false);
            mapTypes.InsertSegment("Satellite", 1, false);
            mapTypes.InsertSegment("Hybrid", 2, false);
            mapTypes.SelectedSegment = 1; // Road is the default
            mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
            mapTypes.ValueChanged += (s, e) => {
                switch(mapTypes.SelectedSegment) {
                case 0:
                    mapView.MapType = MKMapType.Standard;
                    break;
                case 1:
                    mapView.MapType = MKMapType.Satellite;
                    break;
                case 2:
                    mapView.MapType = MKMapType.Hybrid;
                    break;
                }
            };
            View.AddSubview(mapTypes);
            #endregion
        }
开发者ID:omxeliw,项目名称:recipes,代码行数:53,代码来源:MapViewController.cs

示例3: ViewDidLoad

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

            //
            // Create our map view and add it as as subview.
            //
            _mapView = new MKMapView();
            _mapView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height);
            View.AddSubview(_mapView);
            _mapView.Delegate = new MapViewDelegate(this);

            LoadRoute();

            if (RouteLine != null)
            {
                _mapView.AddOverlay(RouteLine);
            }
            ZoomInOnRoute();
        }
开发者ID:fluffyclaret,项目名称:MapStuff,代码行数:20,代码来源:os4MapsViewController.cs


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