示例#1
0
        private MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (annotation is MKUserLocation)
            {
                return(null);
            }

            var customPin = GetCustomPin(annotation as MKPointAnnotation);

            if (customPin == null)
            {
                throw new Exception("Custom pin not found");
            }

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

            return(annotationView);
        }
示例#2
0
        private MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            var customAnnotation = annotation as MKAnnotationClass;

            if (customAnnotation == null)
            {
                return(null);
            }

            var annotationView = mapView.DequeueReusableAnnotation(_annotationIdentifierDefaultClusterPin);

            if (annotationView == null)
            {
                annotationView = new MKAnnotationView(customAnnotation, _annotationIdentifierDefaultClusterPin);
            }
            else
            {
                annotationView.Annotation = customAnnotation;
            }
            annotationView.CanShowCallout = true;
            annotationView.Selected       = true;
            annotationView.Draggable      = true;

            return(annotationView);
        }
示例#3
0
            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;
            }
示例#4
0
        public override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
        {
            var pinAnnotationView = view;

            if (pinAnnotationView == null)
            {
                return;
            }

            if (_previouslySelectedNativePin != null)
            {
                ResetPrevioslySelectedPin();
            }

            view.Image = UIImage.FromFile("defaultPin.png").Scale(new CGSize(40, 50));
            var extendedMapAnnotation = pinAnnotationView.Annotation as ExtendedMapAnnotation;

            if (extendedMapAnnotation != null)
            {
                extendedMapAnnotation.AnnotationClicked(mapView);
            }

            _previouslySelectedPin       = extendedMapAnnotation;
            _previouslySelectedNativePin = view;
        }
示例#5
0
        private MKAnnotationView CreateModeZoneAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            // queue for reuse the pin if it's already exist
            var annotationView = mapView.DequeueReusableAnnotation(_idModeZoneAnotation);

            if (annotationView == null)
            {
                // not existing, we create a new one
                annotationView = new MKAnnotationView(annotation, _idModeZoneAnotation);
            }
            // image of the annotation display on the map
            if ((annotation as ModeZoneAnnotation).IsLastAnnotation)
            {
                annotationView.Image = UIImage.FromBundle("MapPinLast");
            }
            else
            {
                annotationView.Image = UIImage.FromBundle("MapPin");
            }
            annotationView.CanShowCallout = true;
            annotationView.Selected       = true;
            annotationView.Draggable      = true;

            return(annotationView);
        }
示例#6
0
        private static MKAnnotationView GetViewForAnnotation(CustomMapRenderer instance, MKMapView view, IMKAnnotation annotation)
        {
            if (annotation is MKUserLocation)
            {
                return(null);
            }

            if (!(annotation is MKPointAnnotation pointAnnotation))
            {
                return(null);
            }

            var customPin = instance.GetCustomPin(pointAnnotation);

            if (customPin == null)
            {
                return(null);
            }

            var annotationView = new MKAnnotationView(annotation, customPin.Image)
            {
                //CurrentPin = customPin,
                //PinTouch = customPin.PinClicked
            };

            annotationView.Image = UIImage.FromFile(customPin.Image + ".png");

            return(annotationView);
        }
 public override void ChangedDragState(MKMapView mapView, MKAnnotationView annotationView, MKAnnotationViewDragState newState, MKAnnotationViewDragState oldState)
 {
     if (newState == MKAnnotationViewDragState.Ending)
     {
         //((TaqueriaMapAnnotation)annotationView).SetCoordinate()
     }
 }
示例#8
0
        protected void AttachGestureToPin(MKAnnotationView mapPin, IMKAnnotation annotation)
        {
            var recognizers = mapPin.GestureRecognizers;

            if (recognizers != null)
            {
                foreach (var r in recognizers)
                {
                    mapPin.RemoveGestureRecognizer(r);
                }
            }

#if __MOBILE__
            var recognizer = new UITapGestureRecognizer(g => OnCalloutClicked(annotation))
            {
                ShouldReceiveTouch = (gestureRecognizer, touch) =>
                {
                    _lastTouchedView = touch.View;
                    return(true);
                }
            };
#else
            var recognizer = new NSClickGestureRecognizer(g => OnCalloutClicked(annotation));
#endif
            mapPin.AddGestureRecognizer(recognizer);
        }
            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;
            }
示例#10
0
        private MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (annotation is MKUserLocation)
            {
                return(null);
            }

            var customPin = GetCustomPin(annotation as MKPointAnnotation);

            if (customPin == null)
            {
                throw new Exception("Custom pin not found");
            }

            annotationView = mapView.DequeueReusableAnnotation(customPin.Id.ToString());
            if (annotationView == null)
            {
                annotationView = new CustomMKAnnotationView(annotation, customPin.Id.ToString())
                {
                    CalloutOffset = new CGPoint(0, 0),
                    Image         = UIImage.FromFile("pin.png"),
                    Id            = customPin.Id.ToString()
                };
            }
            annotationView.CanShowCallout = true;

            return(annotationView);
        }
	  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;
		}
示例#12
0
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (annotation is MKUserLocation)
            {
                return(null);
            }
            var customPin = GetCustomPin(annotation as MKPointAnnotation);

            if (customPin == null)
            {
                throw new Exception("Custom pin not found");
            }
            annotationView = mapView.DequeueReusableAnnotation(customPin.Id.ToString());
            if (annotationView == null)
            {
                annotationView = new CustomMKAnnotationView(annotation, customPin.Id.ToString());
                annotationView.CalloutOffset = new CGPoint(0, 0);
                ((CustomMKAnnotationView)annotationView).Name           = customPin.Name;
                ((CustomMKAnnotationView)annotationView).PinDescription = customPin.Description;
                ((CustomMKAnnotationView)annotationView).Rating         = customPin.Rating;
            }
            return(annotationView);
        }
        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            string resuseId = annotation is StoreAnnotation ? "pin" : "cluster";
            var    pinView  = mapView.DequeueReusableAnnotation(resuseId);

            if (pinView == null)
            {
                if (annotation is StoreAnnotation)
                {
                    pinView              = new MKAnnotationView(annotation, "pin");
                    pinView.Image        = UIImage.FromBundle("banana_pin.png");
                    pinView.CenterOffset = new CoreGraphics.CGPoint(0, -20);

                    pinView.CanShowCallout            = true;
                    pinView.LeftCalloutAccessoryView  = new UIImageView(UIImage.FromBundle("banana.png"));
                    pinView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);
                }
                else
                {
                    pinView = new MKMarkerAnnotationView(annotation, "cluster");
                }
            }
            else
            {
                pinView.Annotation = annotation;
            }
            pinView.ClusteringIdentifier = "banana";
            return(pinView);
        }
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (IsUserLocation(mapView, annotation))
            {
                return(null);
            }

            var customPin = GetCustomPin(annotation);

            if (customPin == null)
            {
                return(null);
            }

            annotationView = mapView.DequeueReusableAnnotation(customPin.Id.ToString());
            if (annotationView == null)
            {
                annotationView               = new CustomMKAnnotationView(annotation, customPin.Id.ToString());
                annotationView.Image         = UIImage.FromFile("iLocationView");
                annotationView.CalloutOffset = new CGPoint(0, 0);
                ((CustomMKAnnotationView)annotationView).Id = customPin.Id.ToString();
            }
            annotationView.CanShowCallout = true;

            return(annotationView);
        }
示例#15
0
		private MKAnnotationView OnGetViewForAnnotation(MKMapView mapView, AnnotationAlias annotation)
		{
			if (annotation is MapControlAnnotation mapAnnotation)
			{
				var annotationView = mapView.DequeueReusableAnnotation(MapControlAnnotation.AnnotationId);

				if (annotationView == null)
				{
					annotationView = new MKAnnotationView(mapAnnotation, MapControlAnnotation.AnnotationId);
					annotationView.Add(mapAnnotation.Content);
				}

				if (mapAnnotation.Content is FrameworkElement element)
				{
					element.Measure(new Size((float)Bounds.Width, (float)Bounds.Height));
					var size = element.DesiredSize;
					element.Arrange(new Rect(0, 0, size.Width, size.Height));

					// Set the frame size, or the pin will not be selectable.
					annotationView.Frame = new CoreGraphics.CGRect(0, 0, size.Width, size.Height);
					mapAnnotation.Content.Frame = new CoreGraphics.CGRect(0, 0, size.Width, size.Height);
				}

				return annotationView;
			}

			return null;
		}
示例#16
0
        protected override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (annotation is MKUserLocation)
            {
                return(null);
            }

            var anno = annotation as MKPointAnnotation;

            if (anno == null)
            {
                return(null);
            }

            var pin = GetPin(anno);

            if (pin == null)
            {
                throw new Exception("pin not found");
            }

            annotationView = mapView.DequeueReusableAnnotation(pin.MarkerId.ToString());
            if (annotationView == null)
            {
                annotationView               = new CustomMKAnnotationView(annotation, pin.MarkerId.ToString());
                annotationView.Image         = UIImage.FromFile("pin.png");
                annotationView.CalloutOffset = new CGPoint(0, 0);
            }
            annotationView.CanShowCallout = true;

            return(annotationView);
        }
示例#17
0
        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");
            }

            // add custom image for map pin
            annotationView = mapView.DequeueReusableAnnotation(customPin.Id);
            if (annotationView == null)
            {
                annotationView       = new MKAnnotationView(annotation, customPin.Id);
                annotationView.Image = UIImage.FromFile(customPin.Url).Scale(new SizeF()
                {
                    Height = 20, Width = 20
                });
            }
            // hide default callout
            annotationView.CanShowCallout = false;
            return(annotationView);
        }
        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)
                {
                    Image         = UIImage.FromFile("NearMe.png"),
                    CalloutOffset = new CGPoint(0, 0),
                    //LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("kiwibuy_logo.png")),
                    RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure)
                };
                ((CustomMKAnnotationView)annotationView).Id  = customPin.Id;
                ((CustomMKAnnotationView)annotationView).Url = customPin.Url;
            }
            annotationView.CanShowCallout = true;
            return(annotationView);
        }
示例#19
0
        //View do PINO
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            //Exclui se o ponto for a posição do usuário
            if (annotation is MKUserLocation)
            {
                return(null);
            }

            var PinoFoto = ((MapAnnotation)annotation).PinoFoto;


            if (PinoFoto == null)
            {
                throw new Exception("Pino não encontrado");
            }

            MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(PinoFoto.POST.Id.ToString());

            if (annotationView == null)
            {
                annotationView = new CustomMKAnnotationView(annotation, PinoFoto.POST.Id.ToString());
                ((CustomMKAnnotationView)annotationView).POST = PinoFoto.POST;

                annotationView.Image         = UIImage.FromFile("PinoFoto.png");
                annotationView.CenterOffset  = new CGPoint(0, -28.5);
                annotationView.CalloutOffset = new CGPoint(0, 0);
            }
            annotationView.CanShowCallout = false;

            return(annotationView);
        }
示例#20
0
        private MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            var anno      = annotation as MKPointAnnotation;
            var customPin = GetCustomPin(anno);

            if (customPin == null)
            {
                return(null);
            }

            annotationView = mapView.DequeueReusableAnnotation("pin");
            if (annotationView == null)
            {
                annotationView = new MKAnnotationView(annotation, "pin");
                ColorPointAnnotation colorPointAnnotation = annotation as ColorPointAnnotation;
                if (colorPointAnnotation != null)
                {
                    annotationView.Image = GetPinImage(colorPointAnnotation.pinColor);
                }
            }
            annotationView.CanShowCallout = true;

            return(annotationView);
        }
示例#21
0
            public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
            {
                MKAnnotationView annotationView = null;

                if (annotation is MKUserLocation)
                {
                    return(null);
                }

                if (annotation is FoodMarkerAnnotation)
                {
                    AnnotationService service = new AnnotationService();
                    annotationView = service.GetAnnotationView(mapView, annotation);
                }
                else if (annotation is MKClusterAnnotation)
                {
                    AnnotationService service = new AnnotationService();
                    annotationView = service.GetClusterAnnotationView(mapView, annotation);
                }
                else if (annotation != null)
                {
                    var unwrappedAnnotation = MKAnnotationWrapperExtensions.UnwrapClusterAnnotation(annotation);

                    return(GetViewForAnnotation(mapView, unwrappedAnnotation));
                }

                return(annotationView);
            }
示例#22
0
        public void Null()
        {
            using (var def = new MKAnnotationView()) {
                def.Annotation = null;
                def.Annotation = new MKPolygon();
                Assert.IsNotNull(def.Annotation, "Annotation NN");
                def.Annotation = null;
                Assert.IsNull(def.Annotation, "Annotation N");

                def.Image = null;
                def.Image = new UIImage();
                Assert.IsNotNull(def.Image, "Image NN");
                def.Image = null;
                Assert.IsNull(def.Image, "Image N");

                def.LeftCalloutAccessoryView = null;
                def.LeftCalloutAccessoryView = new UIView();
                Assert.IsNotNull(def.LeftCalloutAccessoryView, "LeftCalloutAccessoryView NN");
                def.LeftCalloutAccessoryView = null;
                Assert.IsNull(def.LeftCalloutAccessoryView, "LeftCalloutAccessoryView N");

                def.RightCalloutAccessoryView = null;
                def.RightCalloutAccessoryView = new UIView();
                Assert.IsNotNull(def.RightCalloutAccessoryView, "RightCalloutAccessoryView NN");
                def.RightCalloutAccessoryView = null;
                Assert.IsNull(def.RightCalloutAccessoryView, "RightCalloutAccessoryView N");
            }
        }
示例#23
0
        public override void ChangedDragState(MKMapView mapView, MKAnnotationView annotationView, MKAnnotationViewDragState newState, MKAnnotationViewDragState oldState)
        {
            if (annotationView.Annotation is BindingMKAnnotation annotation)
            {
                switch (newState)
                {
                case MKAnnotationViewDragState.Starting:
                    if (MarkerDragStart?.CanExecute(annotation.Annotation) ?? false)
                    {
                        MarkerDragStart.Execute(annotation.Annotation);
                    }
                    break;

                case MKAnnotationViewDragState.Ending:
                    if (MarkerDragEnd?.CanExecute(annotation.Annotation) ?? false)
                    {
                        MarkerDragEnd.Execute(annotation.Annotation);
                    }
                    break;

                case MKAnnotationViewDragState.Dragging:
                    if (MarkerDrag?.CanExecute(annotation.Annotation) ?? false)
                    {
                        MarkerDrag.Execute(annotation.Annotation);
                    }
                    break;
                }
            }
        }
示例#24
0
 public sealed override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
 {
     if (view.Annotation is BindingMKAnnotation annotation)
     {
         if (MarkerClick?.CanExecute(annotation.Annotation) ?? false)
         {
             MarkerClick.Execute(annotation.Annotation);
             view.Selected = false;
         }
     }
     else if (view.Annotation is IBindingMKMapOverlay overlay)
     {
         if (OverlayClicked?.CanExecute(overlay.Annotation) ?? false)
         {
             OverlayClicked.Execute(overlay.Annotation);
             view.Selected = false;
         }
     }
     else if (view.Annotation == mapView.UserLocation)
     {
         var loc = view.Annotation.Coordinate.ToBinding2DLocation();
         if (MyLocationClick?.CanExecute(loc) ?? false)
         {
             MyLocationClick.Execute(loc);
             view.Selected = false;
         }
     }
 }
        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            string annotationIdentifier = @"annotationIdentifier";
            var    pinView = mapView.DequeueReusableAnnotation(annotationIdentifier);

            if (pinView == null)
            {
                pinView = new MKAnnotationView(annotation, annotationIdentifier);

                var pointAnn = annotation as MKPointAnnotation;
                if (pointAnn != null)
                {
                    if (pointAnn.Title == "Driver Location")
                    {
                        pinView.Image = UIImage.FromBundle("car.png");
                    }
                    else
                    {
                        pinView.Image = UIImage.FromBundle("pin.png");
                    }
                }
            }
            else
            {
                pinView.Annotation = annotation;
            }

            return(pinView);
        }
示例#26
0
            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);
            }
示例#27
0
        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);
        }
        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            if (annotation == null)
            {
                return(null);
            }


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

            detailButton.TouchUpInside += (s, e) =>
            {
                var a = ((AnnotationOverride)annotation).Coordinate;

                if (a.Latitude.Equals(Location.MyCoordonate[0]) && a.Longitude.Equals(Location.MyCoordonate[1]))
                {
                    return;
                }

                LocationHelper.GoogleMap(Location.MyCoordonate, new[] { a.Latitude, a.Longitude });
            };

            var pnn = new MKAnnotationView(annotation, "icon")
            {
                RightCalloutAccessoryView = detailButton,
                CanShowCallout            = true,
                Image = (annotation as AnnotationOverride)?.ImageAnnotation
            };

            _items.Add(annotation);
            return(pnn);
        }
示例#29
0
        protected virtual MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView 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 = mapView.DequeueReusableAnnotation(defaultPinId);
            if (mapPin == null)
            {
                mapPin = new MKPinAnnotationView(annotation, defaultPinId);
                mapPin.CanShowCallout = true;
            }

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

            return(mapPin);
        }
示例#30
0
        //UIImage venueImage;

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

            if (mkAnnotation is MKUserLocation)
            {
                return(null);
            }

            if (mkAnnotation is UserAnnotation)
            {
                // show conference annotation
                annotationView = mapView.DequeueReusableAnnotation(annotationId);

                if (annotationView == null)
                {
                    annotationView = new MKAnnotationView(mkAnnotation, annotationId);
                }

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

            return(annotationView);
        }
示例#31
0
        private MKAnnotationView CreateHistoricAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            // queue for reuse the pin if it's already exist
            var annotationView = mapView.DequeueReusableAnnotation(_idHistoricAnnotation);

            if (annotationView == null)
            {
                // not existing, we create a new one
                annotationView = new MKAnnotationView(annotation, _idHistoricAnnotation);
            }
            // image of the annotation display on the map
            annotationView.Image          = UIImage.FromBundle("MapPin");
            annotationView.CanShowCallout = true;

            var seekiosLastLocationLabel = new UILabel();

            seekiosLastLocationLabel.LineBreakMode = UILineBreakMode.WordWrap;
            seekiosLastLocationLabel.Lines         = new nint(1);
            seekiosLastLocationLabel.Text          = ((HistoricAnnotation)annotation).Content;
            seekiosLastLocationLabel.Font          = UIFont.FromName("Helvetica", 14f);
            seekiosLastLocationLabel.TextColor     = UIColor.LightGray;
            seekiosLastLocationLabel.SizeToFit();
            seekiosLastLocationLabel.SetNeedsDisplay();

            // add the view in the annotation view
            annotationView.LeftCalloutAccessoryView = seekiosLastLocationLabel;

            return(annotationView);
        }
示例#32
0
 public override void CalloutAccessoryControlTapped(MKMapView mapView, MKAnnotationView view, UIControl control)
 {
     if (view.Annotation != null)
     {
         //this.controller.RemovePIN((MapKit.MKAnnotation)view.Annotation);
     }
 }
示例#33
0
        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView    annotationView = null;
            StoreAnnotationView myView         = null;

            if (annotation is MKUserLocation)
            {
                return(null);
            }
            //var tmpPoint = _servicePoints?.Where(x => (x.Id == ((StoreAnnotation)annotation).Point.Id)).ToList().FirstOrDefault();// .Coordinate.Latitude) && (x.Lon == annotation.Coordinate.Longitude)).ToList().Fir;
            if (annotation is StoreAnnotation)
            {
                annotation     = annotation as StoreAnnotation;
                annotationView = mapView.DequeueReusableAnnotation(annotationId);
                if (annotationView == null)
                {
                    annotationView = new StoreAnnotationView();
                }
                myView       = StoreAnnotationView.Create();
                myView.Frame = new CGRect(0, 0, 30, 30);
                myView.UpdateView(((StoreAnnotation)annotation).Point);
                myView.Annotation             = annotation;
                annotationView.Annotation     = annotation;
                annotationView                = myView;
                annotationView.ContentMode    = UIViewContentMode.ScaleAspectFit;
                annotationView.CanShowCallout = true;
                var button = new UIButton();
                button.Bounds = new CGRect(0, 0, 22, 22);
                button.SetImage(UIImage.FromBundle("Directions").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);
                button.TintColor = UIColor.FromRGB(239, 60, 57);
                annotationView.RightCalloutAccessoryView = button;                // UIButton.FromType(UIButtonType.InfoDark);
            }
            return(myView);
        }
示例#34
0
        public void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView annotationView)
        {
            var annotation = annotationView.Annotation as BNRMapPoint;

                if (annotation != null) {
                    Console.WriteLine("Weak DidSelectAnnotationView: {0}", annotation.Title);
                }
        }
        public override void CalloutAccessoryControlTapped(MKMapView mapView, MKAnnotationView view, UIControl control)
        {
            // make sure its the right annotation
            var ann = view.Annotation as HeritagePropertyAnnotation;

            // call the callback
            if (ann != null && this.CalloutTappedCallback != null)
                CalloutTappedCallback(ann.Property);
        }
示例#36
0
        public override void DidDeselectAnnotationView(MKMapView mapView, MKAnnotationView view)
        {
            // remove the image view when the conference annotation is deselected
            if (view.Annotation is ConferenceAnnotation) {

                venueView.RemoveFromSuperview ();
                venueView.Dispose ();
                venueView = null;
            }
        }
示例#37
0
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
        {
            var annotationView = new MKAnnotationView(annotation, "ExampleAnnotation");

            annotationView.CanShowCallout = true;

            annotationView.SetStyleId("sample-annotation");

            return annotationView;
        }
示例#38
0
		public override void DidDeselectAnnotationView (MKMapView mapView, MKAnnotationView view)
		{
			if (view.Annotation is MyAnnotation)
			{
				var myAnnotation = (MyAnnotation)view.Annotation;				
				if (myAnnotation.AssociatedCalloutMapAnnotation != null)
				{
					mapView.RemoveAnnotation(myAnnotation.AssociatedCalloutMapAnnotation);
				}
			}
		}
示例#39
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// get access
			locationManager = new CLLocationManager ();
			locationManager.RequestWhenInUseAuthorization ();

			// create the annotation
			var sdAnnotation = new MKPointAnnotation {
				Title = "SDWebImage Annotation",
			};

			// create the view
			string pId = "sdwebimage";
			mapView.GetViewForAnnotation = (mapView, annotation) => {
				if (annotation is MKUserLocation)
					return null;

				// create annotation view
				var pinView = mapView.DequeueReusableAnnotation (pId);
				if (pinView == null) {
					pinView = new MKAnnotationView (annotation, pId);

					// get the image
					pinView.SetImage (
						new NSUrl ("http://radiotray.sourceforge.net/radio.png"),
						UIImage.FromBundle ("placeholder.png"),
						(image, error, cacheType, imageUrl) => {
							if (error != null) {
								Console.WriteLine ("Error: " + error);
							} else {
								Console.WriteLine ("Done: " + pinView.GetImageUrl ());
							}
						});
				}

				return pinView;
			};

			// add the annotation
			mapView.AddAnnotation (sdAnnotation);

			// move it
			mapView.DidUpdateUserLocation += (sender, e) => {
				var loc = e.UserLocation.Coordinate;
				sdAnnotation.Coordinate = new CLLocationCoordinate2D (loc.Latitude, loc.Longitude);

				mapView.SetCenterCoordinate (sdAnnotation.Coordinate, true);
			};

			// start tracking
			mapView.ShowsUserLocation = true;
		}
 public override void CalloutAccessoryControlTapped(MKMapView mapView, MKAnnotationView view, UIControl control)
 {
     var pinAnnotation = view.Annotation as UnifiedPointAnnotation;
     if (pinAnnotation != null)
     {
         var pinSelectedCommand = _renderer.Element.PinCalloutTappedCommand;
         if (pinSelectedCommand.CanExecute(pinAnnotation.Data))
         {
             pinSelectedCommand.Execute(pinAnnotation.Data);
         }
     }
 }
        public void DidSelectAnnotationView (MKMapView mapView, MKAnnotationView annotationView)
        {
            var sampleAnnotation = annotationView.Annotation as SampleMapAnnotation;

            if (sampleAnnotation != null) {

                //demo accessing the coordinate of the selected annotation to zoom in on it
                mapView.Region = MKCoordinateRegion.FromDistance (sampleAnnotation.Coordinate, 500, 500);

                //demo accessing the title of the selected annotation
                Console.WriteLine ("{0} was tapped", sampleAnnotation.Title);
            }
        }
        private void UpdateAnnotationImageIfIsVehicle(MKAnnotationView view, string imageFilePath = null)
        {
            var correspondingKayValuePair = this.cachedAnnotations.FirstOrDefault(pair => pair.Value == view);
            var correspondingVehicleAnnotation = correspondingKayValuePair.Key as VehicleAnnotation;

            if (correspondingVehicleAnnotation == null)
            {
                return;
            }

            var actualImageFilePath = imageFilePath ?? this.GetImageFilePath(correspondingVehicleAnnotation);

            view.Image = UIImage.FromFile(actualImageFilePath);
        }
示例#43
0
        public override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
        {
            // show an image view when the conference annotation view is selected
            if (view.Annotation is ConferenceAnnotation) {

                venueView = new UIImageView ();
                venueView.ContentMode = UIViewContentMode.ScaleAspectFit;
                venueImage = UIImage.FromFile ("venue.png");
                venueView.Image = venueImage;
                view.AddSubview (venueView);

                UIView.Animate (0.4, () => {
                    venueView.Frame = new CGRect (-75, -75, 200, 200); });
            }
        }
		public override void DidSelectAnnotationView (MKMapView mapView, MKAnnotationView view)
		{
			var customView = view as CustomMKPinAnnotationView;

			customPinView = new UIView();

			if (customView.FormsIdentifier == "Xamarin") {
				customPinView = new XamarinPinView ();
				customPinView.Center = new CGPoint (0, - (view.Frame.Height + 15));
				view.AddSubview (customPinView);
			} else if (customView.FormsIdentifier == "Train") {
				customPinView = new TrainPinView ();
				customPinView.Center = new CGPoint (0, - (view.Frame.Height + 15));
				view.AddSubview (customPinView);
			}
		}
	  public override async void DidDeselectAnnotationView(MKMapView mapView, MKAnnotationView view)
	  {
      //Call reset with delay in case another pin is selected
	    await Task.Delay(TimeSpan.FromMilliseconds(100)).ContinueWith((result) =>
	    {
         Device.BeginInvokeOnMainThread(() =>
         {
           if (_previouslySelectedNativePin != null && view == _previouslySelectedNativePin)
           {
             if (MapTapped != null)
               MapTapped.Invoke(this, new EventArgs());

             ResetPrevioslySelectedPin();
           }
         });
	    });
	  }
            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;
            }
	  public override void DidSelectAnnotationView (MKMapView mapView, MKAnnotationView view)
		{
			var pinAnnotationView = view;

		  if (pinAnnotationView == null) return;

      if(_previouslySelectedNativePin != null)
        ResetPrevioslySelectedPin();
			
      view.Image = UIImage.FromFile("defaultPin.png").Scale(new CGSize(40,50));
      var extendedMapAnnotation = pinAnnotationView.Annotation as ExtendedMapAnnotation;

		  if (extendedMapAnnotation != null) {
		    extendedMapAnnotation.AnnotationClicked (mapView);
		  }

      _previouslySelectedPin = extendedMapAnnotation;
      _previouslySelectedNativePin = view;
		}
示例#48
0
        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;
        }
        public override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
        {
            if (_selectedAnnotation is UnifiedPointAnnotation)
            {
                var prevAnnotation = (UnifiedPointAnnotation)_selectedAnnotation;
                UpdateImage(_selectedAnnotationView, prevAnnotation.Data, false);
                UpdatePinColor(_selectedAnnotationView, prevAnnotation.Data, false);
            }

            var unifiedPoint = view.Annotation as UnifiedPointAnnotation;
            _selectedAnnotation = unifiedPoint;
            _selectedAnnotationView = view;

            if (unifiedPoint != null)
            {
                _renderer.SelectedItem = unifiedPoint.Data;
                var isSelected = unifiedPoint.Data.SelectedImage != null;

                UpdateImage(view, unifiedPoint.Data, isSelected);
                UpdatePinColor(view, unifiedPoint.Data, true);
            }
        }
 public override void ChangedDragState (MKMapView mapView, MKAnnotationView annotationView, MKAnnotationViewDragState newState, MKAnnotationViewDragState oldState)
 {
     Console.WriteLine ("drag state changed");
 }
 public override void DidAddAnnotationViews (MKMapView mapView, MKAnnotationView[] views)
 {
     Console.WriteLine ("TODO: add region code to zoom in here...");
 }
		public void DidSelectAnnotationView (MKMapView mapView,
			MKAnnotationView annotationView)
		{
				
		}
 public override void CalloutAccessoryControlTapped (MKMapView mapView, MKAnnotationView view, UIControl control)
 {
     var annotation = view.Annotation as RestaurantAnnotation;
     
     if (annotation != null) {
         string message = String.Format ("{0} tapped", annotation.Title);
         UIAlertView alert = new UIAlertView ("Annotation Tapped", message, null, "OK");
         alert.Show ();
     }
 }
		/// Because we set anView.Draggable = true; we need to also handle the Ending drag event, or else our annotation will forever be "floating" over the map
		public override void ChangedDragState (MKMapView mapView, MKAnnotationView annotationView, MKAnnotationViewDragState newState, MKAnnotationViewDragState oldState)
		{
			switch (newState) {
			case MKAnnotationViewDragState.Ending:
				annotationView.SetDragState (MKAnnotationViewDragState.None, false);
				break;
			}
		}
		public override void ChangedDragState (MKMapView mapView, MKAnnotationView annotationView, MKAnnotationViewDragState newState, MKAnnotationViewDragState oldState)
		{
			if(newState == MKAnnotationViewDragState.Ending){
				_controller.Latitude = _controller.locationManagerDelegate.CurrentAnnotation.Coordinate.Latitude.ToString();
				_controller.Longitude = _controller.locationManagerDelegate.CurrentAnnotation.Coordinate.Longitude.ToString();
			}
		}
        // TODO: Step 3g - Add event handler for accessory being tapped
        public override void CalloutAccessoryControlTapped (MKMapView mapView, MKAnnotationView view, UIControl control)
        {
            var customAn = view.Annotation as CustomAnnotation;

            var alert = new UIAlertView(customAn != null ? "Custom Annotation" : "Generic Annotation", 
                customAn != null ? customAn.Title : "Title Text", 
                null, "OK");

            alert.Show ();
        }
 // TODO: Step 3h - Add event handler for marker being tapped
 public override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
 {
     var alert = new UIAlertView("Marker was tapped", "Marker tapped", null, "OK");
     alert.Show ();
 }
			/// <summary>
			/// This is the callback for when the detail disclosure is clicked
			/// </summary>
			public override void CalloutAccessoryControlTapped (MKMapView mapView, MKAnnotationView view, UIControl control)
			{
				var menuViewModel = ServiceContainer.Resolve<MenuViewModel>();
				menuViewModel.MenuIndex = SectionIndex.Summary;
				assignmentViewModel.SelectedAssignment = GetAssignment (view.Annotation as MKPlacemark);
				controller.PerformSegue ("AssignmentDetails", controller);
			}
 public override void DidSelectAnnotationView (MKMapView mapView, MKAnnotationView view)
 {
     MKUserLocation userLocationAnnotation = view.Annotation as MKUserLocation;
     
     if (userLocationAnnotation != null) {
         CLLocationCoordinate2D coord = userLocationAnnotation.Location.Coordinate;
         MKCoordinateRegion region = MKCoordinateRegion.FromDistance (coord, 500, 500);
         
         mapView.CenterCoordinate = coord;
         mapView.Region = region;
         
         userLocationAnnotation.Title = "I am here";
     }
 }
示例#60
-1
		public override void DidSelectAnnotationView (MKMapView mapView, MKAnnotationView view)
		{
			try
			{
				if (view.Annotation is MyAnnotation)
				{
					var myAnnotation = (MyAnnotation)view.Annotation;
					
					CalloutMapAnnotation calloutAnnotation = myAnnotation.AssociatedCalloutMapAnnotation;
					if (calloutAnnotation == null)
					{
						calloutAnnotation = new CalloutMapAnnotation(myAnnotation.Coordinate, myAnnotation.Title, "");
					}
					else
					{
						calloutAnnotation.Coordinate = myAnnotation.Coordinate;
					}
					
					myAnnotation.AssociatedCalloutMapAnnotation = calloutAnnotation;
					calloutAnnotation.ParentAnnotation = myAnnotation;
				
					mapView.AddAnnotation(calloutAnnotation);
					selectedAnnotationView = view;
				}
			}
			catch (Exception ex)
			{
				Util.LogException("DidSelectAnnotationView", ex);
			}
		}