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


C# MKMapView类代码示例

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


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

示例1: GetViewForAnnotation

            public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
            {
                var pin = (MKAnnotationView)mapView.DequeueReusableAnnotation("zombie");
                if (pin == null)
                {
                    pin = new MKAnnotationView(annotation, "zombie");
                    pin.Image = UIImage.FromFile("zombie.png");
                    pin.CenterOffset = new PointF(0, -30);
                }
                else
                {
                    pin.Annotation = annotation;
                }

                var zombieAnnotation = (ZombieAnnotation) annotation;
                if (zombieAnnotation.Zombie.IsMale)
                {
                    //pin.PinColor = MKPinAnnotationColor.Purple;
                }
                else
                {
                    //pin.PinColor = MKPinAnnotationColor.Red;
                }

                return pin;
            }
开发者ID:Jake-a-Lake,项目名称:NPlus1DaysOfMvvmCross,代码行数:26,代码来源:FirstView.cs

示例2: ViewDidLoad

        public override void ViewDidLoad()
        {
            var mapView = new MKMapView();
            mapView.Delegate = new MyDelegate();
            View = mapView;

            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;

            var secondViewModel = (SecondViewModel)ViewModel;
            var hanAnnotation = new ZombieAnnotation(secondViewModel.Han);

            mapView.AddAnnotation(hanAnnotation);

            mapView.SetRegion(MKCoordinateRegion.FromDistance(
                new CLLocationCoordinate2D(secondViewModel.Han.Location.Lat, secondViewModel.Han.Location.Lng),
                20000,
                20000), true);

            var button = new UIButton(UIButtonType.RoundedRect);
            button.Frame = new RectangleF(10, 10, 300, 40);
            button.SetTitle("move", UIControlState.Normal);
            Add(button);

            var set = this.CreateBindingSet<SecondView, Core.ViewModels.SecondViewModel>();
            set.Bind(hanAnnotation).For(a => a.Location).To(vm => vm.Han.Location);
            set.Bind(button).For("Title").To(vm => vm.Han.Location);
            set.Apply();
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:32,代码来源:SecondView.cs

示例3: ViewDidLoad

        public override void ViewDidLoad()
        {
            _map = new MKMapView();

            foreach(BusStop busStop in _busStops)
            {
                AddBusStopToMap(_map, busStop);
            }

            AddBusStopToMap(_map, _busStops[0]);

            _map.ShowsUserLocation = true;

            _map.Frame = new RectangleF (0, 0, this.View.Bounds.Width, this.View.Bounds.Height);

            if(_busStops.Length <= 1)
            {
                _map.Region = new MKCoordinateRegion(FindCentre(_busStops), new MKCoordinateSpan(0.005, 0.0005));
            }
            else
            {
                _map.Region = RegionThatFitsAllStops(_busStops);
            }

            this.View.AddSubview (_map);
        }
开发者ID:runegri,项目名称:MuPP,代码行数:26,代码来源:MapViewController.cs

示例4: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			Title = "MapView";
			
			mapView = new MKMapView(View.Bounds);	
			mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;		
			//mapView.MapType = MKMapType.Standard;	// this is the default
			//mapView.MapType = MKMapType.Satellite;
			//mapView.MapType = MKMapType.Hybrid;
			View.AddSubview(mapView);

			// create our location and zoom 
			//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(40.77, -73.98); // new york
			//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(33.93, -118.40); // los angeles
			//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(51.509, -0.1); // london
			CLLocationCoordinate2D coords = new CLLocationCoordinate2D(48.857, 2.351); // paris

			MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));
			
			// set the coords and zoom on the map
			mapView.Region = new MKCoordinateRegion(coords, span);

		}
开发者ID:eduardoguilarducci,项目名称:recipes,代码行数:25,代码来源:MapViewController.cs

示例5: GetViewForAnnotation

		MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
		{
			MKAnnotationView annotationView = null;

			if (annotation is MKUserLocation)
				return null;

			var anno = annotation as MKPointAnnotation;
			var customPin = GetCustomPin(anno);
			if (customPin == null)
			{
				throw new Exception("Custom pin not found");
			}

			annotationView = mapView.DequeueReusableAnnotation(customPin.Id);
			if (annotationView == null)
			{
				annotationView = new CustomMKAnnotationView(annotation, customPin.Id);
				annotationView.Image = UIImage.FromFile("pin.png");
				annotationView.CalloutOffset = new CGPoint(0, 0);
				annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("monkey.png"));
				annotationView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);
				((CustomMKAnnotationView)annotationView).Id = customPin.Id;
				((CustomMKAnnotationView)annotationView).Url = customPin.Url;
			}
			annotationView.CanShowCallout = true;

			return annotationView;
		}
开发者ID:berlamont,项目名称:xamarin-forms-samples,代码行数:29,代码来源:CustomMapRenderer.cs

示例6: Initialize

		private void Initialize ()
		{
			Title = Locale.GetText ("");
			_mapView = new MKMapView ();
			_mapView.AutoresizingMask = UIViewAutoresizing.All;
			_mapView.MapType = MKMapType.Standard;
			_mapView.ShowsUserLocation = true;
			
			_sgMapType = new UISegmentedControl ();
			_sgMapType.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
			_sgMapType.Opaque = true;
			_sgMapType.Alpha = 0.75f;
			_sgMapType.ControlStyle = UISegmentedControlStyle.Bar;
			_sgMapType.InsertSegment ("Map", 0, true);
			_sgMapType.InsertSegment ("Satellite", 1, true);
			_sgMapType.InsertSegment ("Hybrid", 2, true);
			_sgMapType.SelectedSegment = 0;
			_sgMapType.ValueChanged += (s, e) => {
				switch (_sgMapType.SelectedSegment) {
				case 0:
					_mapView.MapType = MKMapType.Standard;
					break;
				case 1:
					_mapView.MapType = MKMapType.Satellite;
					break;
				case 2:
					_mapView.MapType = MKMapType.Hybrid;
					break;
				}
			};
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:31,代码来源:LbkMapViewController.cs

示例7: GetViewForAnnotation

        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            // try and dequeue the annotation view
            MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(annotationIdentifier);
            // if we couldn't dequeue one, create a new one
            if (annotationView == null)
                annotationView = new MKPinAnnotationView(annotation, annotationIdentifier);
            else // if we did dequeue one for reuse, assign the annotation to it
                annotationView.Annotation = annotation;

            // configure our annotation view properties
            annotationView.CanShowCallout = true;
            (annotationView as MKPinAnnotationView).AnimatesDrop = true;
            (annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Red;
            annotationView.Selected = true;

            Assembly ass = this.GetType ().Assembly;

            var annotationImage =
                UIImage.FromBundle((annotation as BasicPinAnnotation).ImageAdress);

            annotationView.LeftCalloutAccessoryView = new UIImageView(
                ResizeImage.MaxResizeImage(annotationImage,(float)40,(float)20));
            return annotationView;
        }
开发者ID:kosomgua,项目名称:MapCross,代码行数:25,代码来源:MapDelegate.cs

示例8: ViewDidLoad

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

            FoundCoords += (object sender, CoordEventArgs e) => {
                storageScreenContent.SetCoords(e.Latitude,e.Longitude);
            };

            map = new MKMapView (UIScreen.MainScreen.Bounds);
            View = map;

            // create search controller
            searchBar = new UISearchBar (new RectangleF (0, 0, View.Frame.Width, 50)) {
                Placeholder = "Enter a search query"
            };
            searchController = new UISearchDisplayController (searchBar, this);
            searchController.Delegate = new SearchDelegate (map);
            SearchSource source = new SearchSource (searchController, map);
            searchController.SearchResultsSource = source;
            source.FoundCoords += (object sender, CoordEventArgs e) => {
                var handler = FoundCoords;
                if(handler != null){
                    handler(this,e);
                }
                this.DismissViewController(true,null);
            };
            View.AddSubview (searchBar);
        }
开发者ID:KuroiAme,项目名称:Indexer,代码行数:28,代码来源:AddressLocationFinder.cs

示例9: GetViewForAnnotation

			UIButton detailButton; // need class-level ref to avoid GC

			/// <summary>
			/// This is very much like the GetCell method on the table delegate
			/// </summary>
			public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation)
			{
				// try and dequeue the annotation view
				MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(annotationIdentifier);
				
				// if we couldn't dequeue one, create a new one
				if (annotationView == null)
					annotationView = new MKPinAnnotationView(annotation, annotationIdentifier);
				else // if we did dequeue one for reuse, assign the annotation to it
					annotationView.Annotation = annotation;
		     
				// configure our annotation view properties
				annotationView.CanShowCallout = true;
				(annotationView as MKPinAnnotationView).AnimatesDrop = true;
				(annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Green;
				annotationView.Selected = true;
				
				// you can add an accessory view, in this case, we'll add a button on the right, and an image on the left
				detailButton = UIButton.FromType(UIButtonType.DetailDisclosure);
				detailButton.TouchUpInside += (s, e) => { 
					var c = (annotation as MKAnnotation).Coordinate;
					new UIAlertView("Annotation Clicked", "You clicked on " +
					c.Latitude.ToString() + ", " +
					c.Longitude.ToString() , null, "OK", null).Show(); 
				};
				annotationView.RightCalloutAccessoryView = detailButton;
				annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromBundle("Images/Icon/29_icon.png"));
				//annotationView.Image = UIImage.FromBundle("Images/Apress-29x29.png");
				
				return annotationView;
			}
开发者ID:Adameg,项目名称:mobile-samples,代码行数:36,代码来源:AnnotatedMapScreen.xib.cs

示例10: GetViewForAnnotation

	  public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation annotation)
		{
      var extendedAnnotation = annotation as ExtendedMapAnnotation;

	    if (extendedAnnotation == null) return null;

	    // try and dequeue the annotation view
	    var annotationView = mapView.DequeueReusableAnnotation(AnnotationIdentifier);

	    // if we couldn't dequeue one, create a new one
	    if (annotationView == null)
	    {
	      annotationView = new MKAnnotationView(extendedAnnotation, AnnotationIdentifier);
	    }
	    else // if we did dequeue one for reuse, assign the annotation to it
	      annotationView.Annotation = extendedAnnotation;

	    // configure our annotation view properties
	    annotationView.CanShowCallout = false;
	    annotationView.Selected = true;

	    if (!string.IsNullOrEmpty(extendedAnnotation.PinIcon))
	    {
	      annotationView.Image = UIImage.FromFile(extendedAnnotation.PinIcon);
	    }

	    return annotationView;
		}
开发者ID:patridge,项目名称:Xamarin.Forms.Plugins,代码行数:28,代码来源:MapDelegate.cs

示例11: MapController

        public MapController(Entity entity)
        {
            try {
                Entity = entity;

                Title = Entity.EntityTypeName;

                _map = new MKMapView ();

                _pin = new Pin(Entity);

                _map.Frame = View.Bounds;
                _map.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

                _map.AddAnnotation(_pin);

                _map.Region = new MKCoordinateRegion (_pin.Coordinate, new MKCoordinateSpan (0.01, 0.01));

                View.AddSubview (_map);

                _map.SelectAnnotation(_pin, true);

            } catch (Exception error) {
                Log.Error (error);
            }
        }
开发者ID:jorik041,项目名称:odata,代码行数:26,代码来源:MapController.cs

示例12: ViewDidLoad

        public override void ViewDidLoad()
        {
            var mapView = new MKMapView();
            View = mapView;

            base.ViewDidLoad();

            var firstViewModel = (FourthViewModel)ViewModel;
            _regionManager = new RegionManager(mapView);

            var button = new UIButton(UIButtonType.RoundedRect);
            button.Frame = new RectangleF(10, 10, 300, 40);
            button.SetTitle("move", UIControlState.Normal);
            Add(button);

            var lat = new UITextField(new RectangleF(10, 50, 130, 40));
            lat.KeyboardType = UIKeyboardType.DecimalPad;
            Add(lat);

            var lng = new UITextField(new RectangleF(160, 50, 130, 40));
            lng.KeyboardType = UIKeyboardType.DecimalPad;
            Add(lng);

            var set = this.CreateBindingSet<FourthView, Core.ViewModels.FourthViewModel>();
            set.Bind(button).To(vm => vm.UpdateCenterCommand);
            set.Bind(lat).To(vm => vm.Lat);
            set.Bind(lng).To(vm => vm.Lng);
            set.Bind(_regionManager).For(r => r.Center).To(vm => vm.Location);
            set.Apply();
        }
开发者ID:Jake-a-Lake,项目名称:NPlus1DaysOfMvvmCross,代码行数:30,代码来源:FourthView.cs

示例13: CreateMapView

 void CreateMapView()
 {
     _mapView = new MKMapView (UIScreen.MainScreen.Bounds);
     _mapView.ShowsUserLocation = true;
     _mapView.Delegate = new MapViewDelegate ();
     View.InsertSubview (_mapView, 0);
 }
开发者ID:hakonfjukstad,项目名称:Avgangsalarm,代码行数:7,代码来源:MapViewController.cs

示例14: GetViewForAnnotation

            public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation)
            {
                MKAnnotationView anView;

                if (annotation is MKUserLocation)
                    return null; 

                if (annotation is MonkeyAnnotation) {

                    // show monkey annotation
                    anView = mapView.DequeueReusableAnnotation (mId);

                    if (anView == null)
                        anView = new MKAnnotationView (annotation, mId);
                
                    anView.Image = UIImage.FromFile ("monkey.png");
                    anView.CanShowCallout = true;
                    anView.Draggable = true;
                    anView.RightCalloutAccessoryView = UIButton.FromType (UIButtonType.DetailDisclosure);

                } else {

                    // show pin annotation
                    anView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation (pId);

                    if (anView == null)
                        anView = new MKPinAnnotationView (annotation, pId);
                
                    ((MKPinAnnotationView)anView).PinColor = MKPinAnnotationColor.Green;
                    anView.CanShowCallout = true;
                }

                return anView;
            }
开发者ID:GSerjo,项目名称:Seminars,代码行数:34,代码来源:MapDemoViewController.cs

示例15: GetViewForAnnotation

		public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation annotation)
		{
			MKAnnotationView annotationView = null;
			MKPointAnnotation anno = null;

			if (annotation is MKUserLocation) {
				return null; 
			} else {
				anno = annotation as MKPointAnnotation;
			}

			string identifier = GetIdentifier (anno);

			if (identifier == "")
				throw new Exception ("No Identifier found for pin");

			annotationView = mapView.DequeueReusableAnnotation (identifier);

			if (annotationView == null)
				annotationView = new CustomMKPinAnnotationView (annotation, identifier);

			//This removes the bubble that pops up with the title and everything
			((CustomMKPinAnnotationView)annotationView).FormsIdentifier = identifier;
			annotationView.CanShowCallout = false;

			return annotationView;
		}
开发者ID:biyyalakamal,项目名称:customer-success-samples,代码行数:27,代码来源:CustomMapDelegate.cs


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