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


C# MKMapView.DequeueReusableAnnotation方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: GetViewForAnnotation

		public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
		{
			var pet = ((CustomAnnotation)annotation).Model;
			var petAnnotationType = GetPetAnnotationType (pet);

			var pin = (MapAnnotationView)mapView.DequeueReusableAnnotation(petAnnotationType);
			string pinImage = petAnnotationType + ".png";
			if (pin == null)
			{
				pin = new MapAnnotationView(annotation, petAnnotationType);
				pin.Image = UIImage.FromBundle(pinImage);
				pin.CenterOffset = new PointF (0, -15);
			}
			else
			{
				pin.Annotation = annotation;
			}

			pin.Draggable = _pinIsDraggable;
			pin.CanShowCallout = _canShowCallout;

			if (_canShowCallout) 
			{
				Task.Run( async () => pin.LeftCalloutAccessoryView = await GetImage(pet));
				pin.RightCalloutAccessoryView = GetDetailButton (pet);
			}
			return pin;
		}
开发者ID:sgraphics,项目名称:BindableMapTest,代码行数:28,代码来源:MonkeyMapDelegate.cs

示例8: 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

示例9: ViewDidLoad

        public override void ViewDidLoad()
        {
            mapView = new MKMapView();
            RectangleF frame = new RectangleF(0,0,320,360);

            mapView.Frame = frame;
            mapView.ShowsUserLocation = true;

            var myAnnotation = new MyAnnotation(new CLLocationCoordinate2D(0,0), "Home", "is where the heart is");
            mapView.AddAnnotationObject(myAnnotation);

            UIButton detailButton = UIButton.FromType(UIButtonType.DetailDisclosure);

            mapView.GetViewForAnnotation = delegate(MKMapView mapViewForAnnotation, NSObject annotation) {

                var anv = mapView.DequeueReusableAnnotation("thislocation");
                if (anv == null)
                {
                    anv = new MKPinAnnotationView(annotation, "thislocation");

                    detailButton.TouchUpInside += (s, e) => {
                        Console.WriteLine ("Tapped");
                    };
                    anv.RightCalloutAccessoryView = detailButton;
                }
                else
                {
                    anv.Annotation = annotation;
                }
                anv.CanShowCallout = true;
                return anv;
            };

            View.AddSubview(mapView);
        }
开发者ID:amnextking,项目名称:monotouch-bindings,代码行数:35,代码来源:TweetViewController.cs

示例10: GetViewForAnnotation

        MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
        {
            //Stop annotations
            if (annotation is StopAnnotation) {
                StopAnnotation stopAnn = annotation as StopAnnotation;

                //dequeue or create
                MKPinAnnotationView pin = mapView.DequeueReusableAnnotation(STOP_PIN_ID) as MKPinAnnotationView;
                if (pin==null){
                    pin = new MKPinAnnotationView(stopAnn, STOP_PIN_ID);
                    pin.CanShowCallout=true;
                }

                return pin;
            }//end is stop annotations
            return null;
        }
开发者ID:jboolean,项目名称:RIT-Bus,代码行数:17,代码来源:BusStopMapViewController.cs

示例11: 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;
                }

                pin.Draggable = true;

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

示例12: GetViewForAnnotation

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

            if (annotation is MKUserLocation)
                return null;

            if (annotation is ConferenceAnnotation) {

                // show conference annotation
                annotationView = mapView.DequeueReusableAnnotation (annotationId);

                if (annotationView == null)
                    annotationView = new MKAnnotationView (annotation, annotationId);

                annotationView.Image = UIImage.FromFile ("conference.png");
                annotationView.CanShowCallout = true;
            }

            return annotationView;
        }
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:21,代码来源:MapDelegate.cs

示例13: GetViewForAnnotation

		public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation)
#endif
		{
			MKPinAnnotationView mapPin = null;

			// https://bugzilla.xamarin.com/show_bug.cgi?id=26416
			var userLocationAnnotation = Runtime.GetNSObject(annotation.Handle) as MKUserLocation;
			if (userLocationAnnotation != null)
				return null;

			const string defaultPinId = "defaultPin";
			mapPin = (MKPinAnnotationView)mapView.DequeueReusableAnnotation(defaultPinId);
			if (mapPin == null)
			{
				mapPin = new MKPinAnnotationView(annotation, defaultPinId);
				mapPin.CanShowCallout = true;
			}

			mapPin.Annotation = annotation;
			AttachGestureToPin(mapPin, annotation);

			return mapPin;
		}
开发者ID:ytn3rd,项目名称:Xamarin.Forms,代码行数:23,代码来源:MapRenderer.cs

示例14: GetViewForAnnotation

        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
        {
            // if it's the user location just return 
            if (annotation is MKUserLocation)
                return null;

            MKAnnotationView anView;

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

            // if we didn't deque reuse
            if (anView == null)
                anView = new MKPinAnnotationView(annotation, pId);

            // set the accessory and pin
            ((MKPinAnnotationView)anView).PinColor = MKPinAnnotationColor.Red;
            anView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);
            anView.CanShowCallout = true;

            // return the view
            return anView;
        }
开发者ID:RhysPartlett,项目名称:oakville-heritage-properties,代码行数:23,代码来源:HeritagePropertyMapViewDelegate.cs

示例15: GetViewForAnnotation

        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            if (Runtime.GetNSObject(annotation.Handle) is MKUserLocation)
            {
                return null;
            }

            var unifiedAnnotation = annotation as IUnifiedAnnotation;
            if (unifiedAnnotation == null)
            {
                return null;
            }

            var pinAnnotation = annotation as UnifiedPointAnnotation;
            if (pinAnnotation != null)
            {
                var data = pinAnnotation.Data;
                MKAnnotationView annotationView = null;

                if (data.Image == null)
                {
                    // Handle standard pins
                    var pinAnnotationView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation(MKPinAnnotationIdentifier) ??
                        new MKPinAnnotationView(annotation, MKPinAnnotationIdentifier);

                    pinAnnotationView.PinTintColor = data.Color.ToUIColor();
                    annotationView = pinAnnotationView;
                }
                else {
                    // Handle pins with an image as pin icon
                    annotationView = mapView.DequeueReusableAnnotation(MKAnnotationIdentifier) ??
                        new MKAnnotationView(annotation, MKAnnotationIdentifier);

                    UpdateImage(annotationView, pinAnnotation.Data);
                }

                // Only show the callout if there is something to display
                annotationView.CanShowCallout = string.IsNullOrWhiteSpace(pinAnnotation.Data.Title) == false;

                if (annotationView.CanShowCallout
                    && _renderer.Element.PinCalloutTappedCommand != null
                    && pinAnnotation.Data != null)
                {
                    annotationView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);
                }

                annotationView.Annotation = annotation;
                return annotationView;
            }

            return null;
        }
开发者ID:fiveninedigital,项目名称:UnifiedMaps,代码行数:52,代码来源:UnifiedMapDelegate.cs


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