private MKAnnotationView HandleMKMapViewAnnotation(MKMapView mapView, IMKAnnotation annotation) { if (annotation is Bike) { var marker = annotation as Bike; var view = mapView.DequeueReusableAnnotation(MKMapViewDefault.AnnotationViewReuseIdentifier) as BikeView; if (view == null) { view = new BikeView(marker, MKMapViewDefault.AnnotationViewReuseIdentifier); } return(view); } else if (annotation is MKClusterAnnotation) { var cluster = annotation as MKClusterAnnotation; var view = mapView.DequeueReusableAnnotation(MKMapViewDefault.ClusterAnnotationViewReuseIdentifier) as ClusterView; if (view == null) { view = new ClusterView(cluster, MKMapViewDefault.ClusterAnnotationViewReuseIdentifier); } return(view); } else if (annotation != null) { var unwrappedAnnotation = MKAnnotationWrapperExtensions.UnwrapClusterAnnotation(annotation); return(HandleMKMapViewAnnotation(mapView, unwrappedAnnotation)); } return(null); }
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; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { MKAnnotationView result = null; if (annotation is MKUserLocation) { return(result); } if (annotation is MonkeyAnnotation) { // show monkey annotation result = mapView.DequeueReusableAnnotation(MonkeyId) ?? new MKAnnotationView(annotation, MonkeyId); result.Draggable = true; result.CanShowCallout = true; result.Image = UIImage.FromBundle("Monkey"); result.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure); } else { // show pin annotation var annotationView = mapView.DequeueReusableAnnotation(PinId) as MKPinAnnotationView ?? new MKPinAnnotationView(annotation, PinId); annotationView.PinTintColor = UIColor.Red; annotationView.CanShowCallout = true; result = annotationView; } return(result); }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { MKAnnotationView pinView = null; if (annotation is MKUserLocation) { return(pinView); } if (annotation is DriverAnnotation) { pinView = mapView.DequeueReusableAnnotation(driverID) ?? new MKAnnotationView(annotation, driverID); pinView.CanShowCallout = true; pinView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure); pinView.Draggable = true; pinView.Image = ResizeImage(UIImage.FromFile("UberImage.png"), 50, 50); pinView.LeftCalloutAccessoryView = new UIImageView(ResizeImage(UIImage.FromFile("DriverImage.png"), 50, 50)); } else { var annotationView = mapView.DequeueReusableAnnotation(userID) as MKPinAnnotationView ?? new MKPinAnnotationView(annotation, userID); annotationView.PinTintColor = UIColor.Red; annotationView.CanShowCallout = true; pinView = annotationView; } return(pinView); }
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 = _renderer.Element.CanShowCalloutOnTap && !string.IsNullOrWhiteSpace(pinAnnotation.Data.Title); if (annotationView.CanShowCallout && _renderer.Element.PinCalloutTappedCommand != null && pinAnnotation.Data != null) { annotationView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure); } annotationView.Annotation = annotation; return(annotationView); } return(null); }
private MKAnnotationView GetViewForUserAnnotation(UserAnnotation annotation) { var annotationView = _nativeMap.DequeueReusableAnnotation(UserAnnotationView.CustomReuseIdentifier); if (annotationView == null) { annotationView = new UserAnnotationView(annotation); } return(annotationView); }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { if (annotation is ProfileAnnotation) //profile image { MKAnnotationView imageView = mapView.DequeueReusableAnnotation(iId); if (imageView == null) { imageView = new MKAnnotationView(annotation, iId); } ImageCache im = new ImageCache(context); im.LoadImage(imageView, ((ProfileAnnotation)annotation).UserID.ToString(), ((ProfileAnnotation)annotation).image); //draws border inside, as opposed to Android where it is outside imageView.Layer.BorderColor = UIColor.FromName("PrimaryDark").CGColor; imageView.Layer.BorderWidth = 0.5f; imageView.Frame = new CoreGraphics.CGRect(0, 0, (double)Settings.MapIconSize, (double)Settings.MapIconSize); return(imageView); } else if (annotation is MKPointAnnotation) //list view circle center / profile view position marker { if (context is LocationActivity) { MKAnnotationView imageView = mapView.DequeueReusableAnnotation(iId); if (imageView == null) { imageView = new MKAnnotationView(annotation, iId); } imageView.Image = UIImage.FromBundle("IcMapmarker"); imageView.Frame = new CoreGraphics.CGRect(0, 0, 30, 30); return(imageView); } else { MKPinAnnotationView pinView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation(pId); if (pinView == null) { pinView = new MKPinAnnotationView(annotation, pId); } pinView.PinColor = MKPinAnnotationColor.Red; pinView.CanShowCallout = false; return(pinView); } } else //user location. Class = MapKit.MKAnnotationWrapper, title = My Location { return(null); } }
public MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { if (annotation is MKUserLocation) { return(null); } if (annotation is StepAnnotation) { var annotationView = mapView.DequeueReusableAnnotation("StepAnnotation") as MKPinAnnotationView; if (annotationView == null) { annotationView = new MKPinAnnotationView(annotation, "StepAnnotation"); } annotationView.Annotation = annotation; annotationView.PinColor = MKPinAnnotationColor.Green; return(annotationView); } if (annotation is DestinationAnnotation) { var annotationView = mapView.DequeueReusableAnnotation("DesinationAnnotation") as MKPinAnnotationView; if (annotationView == null) { annotationView = new MKPinAnnotationView(annotation, "DesinationAnnotation"); } annotationView.Annotation = annotation; annotationView.PinColor = MKPinAnnotationColor.Purple; return(annotationView); } if (annotation is DirectionAnnotation) { DirectionAnnotation directionAnnotation = annotation as DirectionAnnotation; var annotationView = mapView.DequeueReusableAnnotation("DirectionAnnotation") as MKAnnotationView; if (annotationView == null) { annotationView = new MKAnnotationView(annotation, "DirectionAnnotation"); annotationView.Image = UIImage.FromFile("small_blue_icon_navigate.png"); } annotationView.Annotation = annotation; CGAffineTransform transform = CGAffineTransform.MakeRotation((nfloat)directionAnnotation.CurAngle + lastAngle); annotationView.Transform = transform; return(annotationView); } return(null); }
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; }
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) { 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; }
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; }
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; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { return(mapView.DequeueReusableAnnotation(MapAnnotationId) ?? new MKPinAnnotationView(annotation, MapAnnotationId) { CanShowCallout = true }); }
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); }
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); }
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); }
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; }
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); }
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); }
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; }
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); }
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); }
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); }
//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); }
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); }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { var customPin = GetCustomPin(annotation); if (customPin == null) { return(new CustomMkAnnotationView(annotation, "") { Id = "me", Image = UIImage.FromFile("dot") }); } var annotationView = mapView.DequeueReusableAnnotation(customPin.Id); if (annotationView == null) { annotationView = new CustomMkAnnotationView(annotation, customPin.Id) { Image = UIImage.FromFile("pin") }; ((CustomMkAnnotationView)annotationView).Id = customPin.Id; } annotationView.CanShowCallout = false; return(annotationView); }
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 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); }
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); }
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 (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); }
protected override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { if (AnnotationIsUserLocation(mapView, annotation)) { return(null); } var annotationView = mapView.DequeueReusableAnnotation(_annotationViewIdentifier) as MKPinAnnotationView; if (annotationView == null) { annotationView = new MKPinAnnotationView(annotation, _annotationViewIdentifier); } else { annotationView.Annotation = annotation; } if (annotation is WayPointMkAnnotation wayPointMkAnnotation) { annotationView.PinTintColor = wayPointMkAnnotation.PinColor; annotationView.CanShowCallout = true; } return(annotationView); }
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); }
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); }
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); }
//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); }
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; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation) { Console.WriteLine("attempt to get view for MKAnnotation " + annotation); try { var anv = mapView.DequeueReusableAnnotation("thislocation"); if (anv == null) { Console.WriteLine("creating new MKAnnotationView"); var pinanv = new MKPinAnnotationView(annotation, "thislocation"); pinanv.AnimatesDrop = true; pinanv.PinColor = MKPinAnnotationColor.Green; pinanv.CanShowCallout = true; anv = pinanv; } else { anv.Annotation = annotation; } return(anv); } catch (Exception ex) { Console.WriteLine("GetViewForAnnotation Exception " + ex); return(null); } }
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; }
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 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 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; }
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; }
/// <summary> /// This is very much like the GetCell method on the table delegate /// </summary> 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.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) => { Console.WriteLine ("Clicked"); //Create Alert var detailAlert = UIAlertController.Create ("Annotation Clicked", "You clicked on " + (annotation as MKAnnotation).Coordinate.Latitude.ToString() + ", " + (annotation as MKAnnotation).Coordinate.Longitude.ToString(), UIAlertControllerStyle.Alert); detailAlert.AddAction (UIAlertAction.Create ("OK", UIAlertActionStyle.Default, null)); parent.PresentViewController (detailAlert, true, null); }; annotationView.RightCalloutAccessoryView = detailButton; annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromBundle("29_icon.png")); return annotationView; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation) { try { var ca = (ConferenceAnnotation)annotation; var aview = (MKPinAnnotationView)mapView.DequeueReusableAnnotation("pin"); if (aview == null) { aview = new MKPinAnnotationView(ca, "pin"); } else { aview.Annotation = ca; } aview.AnimatesDrop = true; aview.PinColor = MKPinAnnotationColor.Purple; aview.CanShowCallout = true; // UIButton rightCallout = UIButton.FromType(UIButtonType.DetailDisclosure); // rightCallout.Frame = new RectangleF(250,8f,25f,25f); // rightCallout.TouchDown += delegate // { // NSUrl url = new NSUrl("http://maps.google.com/maps?q=" + ca.Coordinate.ToLL() ); // UIApplication.SharedApplication.OpenUrl(url); // }; // aview.RightCalloutAccessoryView = rightCallout; return aview; } catch (Exception) { return null; } }
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) { // RFP:: create the cutom annotation view setting its properties to match the CustomPin on the map annotationView = new CustomMKPinAnnotationView(annotation, customPin.Id); ((CustomMKPinAnnotationView)annotationView).Id = customPin.Id; ((CustomMKPinAnnotationView)annotationView).FirstLine = customPin.FirstLine; ((CustomMKPinAnnotationView)annotationView).SecondLine = customPin.SecondLine; ((CustomMKPinAnnotationView)annotationView).ThirdLine = customPin.ThirdLine; ((CustomMKPinAnnotationView)annotationView).FourthLine = customPin.FourthLine; // RFP:: create a new view to be used for annotationView.DetailCalloutAccessoryView var newCalloutView = new UIView(); newCalloutView.TranslatesAutoresizingMaskIntoConstraints = false; // we are using autolayout, not struts // RFP:: create and add 3 new UILabels. The normal secondary line on the pin will be replaced by replacing the DetailCalloutAccessoryView, so in total there will be 4 lines var label1 = CreateBasicLabel(); var label2 = CreateBasicLabel(); var label3 = CreateBasicLabel(); newCalloutView.Add(label1); newCalloutView.Add(label2); newCalloutView.Add(label3); // RFP:: measure how big a text field is and calculate the height needed for the callout label1.Text = "TEMP"; // used to measure height var heightOfLabel = label1.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity).Request.Height; var heightOfCallout = (float)(heightOfLabel * 3 + CALLOUT_Y_OFFSET); // the height of the callout is 3 times the height of the label subtracting height used to shift callout view up to be under main text // RFP:: setup the constraints for the new callout view newCalloutView.AddConstraints(new[] { NSLayoutConstraint.Create(newCalloutView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, heightOfCallout), }); // RFP:: setup the constraints for each of the new labels newCalloutView.AddConstraints(new[] { NSLayoutConstraint.Create(label1, NSLayoutAttribute.Top, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Top, 1, CALLOUT_Y_OFFSET), // offsetting up X pixels to be right under primary text line (otherwise there is a gap) NSLayoutConstraint.Create(label1, NSLayoutAttribute.Left, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Left, 1, 0), // setting label to match parents left edge NSLayoutConstraint.Create(label1, NSLayoutAttribute.Right, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Right, 1, 0), // setting label to match parents right edge }); newCalloutView.AddConstraints(new[] { NSLayoutConstraint.Create(label2, NSLayoutAttribute.Top, NSLayoutRelation.Equal, label1, NSLayoutAttribute.Bottom, 1, 0), // setting top of label to be at bottom of previous label NSLayoutConstraint.Create(label2, NSLayoutAttribute.Left, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Left, 1, 0), // setting label to match parents left edge NSLayoutConstraint.Create(label2, NSLayoutAttribute.Right, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Right, 1, 0), // setting label to match parents right edge }); newCalloutView.AddConstraints(new[] { NSLayoutConstraint.Create(label3, NSLayoutAttribute.Top, NSLayoutRelation.Equal, label2, NSLayoutAttribute.Bottom, 1, 0), // setting top of label to be at bottom of previous label NSLayoutConstraint.Create(label3, NSLayoutAttribute.Left, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Left, 1, 0), // setting label to match parents left edge NSLayoutConstraint.Create(label3, NSLayoutAttribute.Right, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Right, 1, 0), // setting label to match parents right edge }); // RFP:: replace the DetailCalloutAccessoryView with our new view annotationView.DetailCalloutAccessoryView = newCalloutView; } // RFP:: Get a handle on the fields in the callout to update their text values (both if newly created or reused per DequeueReusableAnnotation) var textField1 = annotationView.DetailCalloutAccessoryView.Subviews[0] as UILabel; var textField2 = annotationView.DetailCalloutAccessoryView.Subviews[1] as UILabel; var textField3 = annotationView.DetailCalloutAccessoryView.Subviews[2] as UILabel; textField1.Text = customPin.SecondLine; textField2.Text = customPin.ThirdLine; textField3.Text = customPin.FourthLine; // RFP:: make sure the callout is shown annotationView.CanShowCallout = true; return annotationView; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation) { var anv = mapView.DequeueReusableAnnotation("thislocation"); if (anv == null) { var pinanv = new MKPinAnnotationView(annotation, "thislocation"); pinanv.AnimatesDrop = true; pinanv.PinColor = MKPinAnnotationColor.Green; pinanv.CanShowCallout = false; anv = pinanv; } else { anv.Annotation = annotation; } return anv; }
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation) { MKAnnotationView anView; if (annotation is MKUserLocation) return null; //modifications for MyCustomAnnotations if (annotation is MyCustomAnnotation) { anView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation (pinID); if(anView == null) anView = new MKPinAnnotationView (annotation,pinID); anView.CanShowCallout = true; anView.Draggable = true; ((MKPinAnnotationView)anView).PinColor = MKPinAnnotationColor.Red; anView.RightCalloutAccessoryView = UIButton.FromType (UIButtonType.DetailDisclosure); } //modifications for MKPointAnnotation else { anView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation (pinGeneric); if(anView == null) anView = new MKPinAnnotationView (annotation,pinGeneric); anView.CanShowCallout = true; ((MKPinAnnotationView)anView).PinColor = MKPinAnnotationColor.Green; } return anView; }
/// <summary> /// Get the view for the annotation /// </summary> /// <param name="mapView">The map</param> /// <param name="annotation">The annotation</param> /// <returns>The annotation view</returns> private MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { var customAnnotation = annotation as TKCustomMapAnnotation; if (customAnnotation == null) return null; MKAnnotationView annotationView; if(customAnnotation.CustomPin.Image != null) annotationView = mapView.DequeueReusableAnnotation(AnnotationIdentifier); else annotationView = mapView.DequeueReusableAnnotation(AnnotationIdentifierDefaultPin); if (annotationView == null) { if(customAnnotation.CustomPin.Image != null) annotationView = new MKAnnotationView(); else annotationView = new MKPinAnnotationView(customAnnotation, AnnotationIdentifier); } else { annotationView.Annotation = customAnnotation; } annotationView.CanShowCallout = customAnnotation.CustomPin.ShowCallout; annotationView.Draggable = customAnnotation.CustomPin.IsDraggable; annotationView.Selected = this._selectedAnnotation != null && customAnnotation.Equals(this._selectedAnnotation); this.SetAnnotationViewVisibility(annotationView, customAnnotation.CustomPin); this.UpdateImage(annotationView, customAnnotation.CustomPin); if (FormsMap.CalloutClickedCommand != null) { var button = new UIButton(UIButtonType.InfoLight); button.Frame = new CGRect(0, 0, 23, 23); button.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; button.VerticalAlignment = UIControlContentVerticalAlignment.Center; annotationView.RightCalloutAccessoryView = button; } return annotationView; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { MKPinAnnotationView pinView = (MKPinAnnotationView) mapView.DequeueReusableAnnotation( AnnotationID ); if ( pinView == null ) { pinView = new MKPinAnnotationView( annotation, AnnotationID ); pinView.CanShowCallout = true; } // are we rendering the source location? if ( annotation.Coordinate.Latitude == Parent.SourceLocation.Latitude && annotation.Coordinate.Longitude == Parent.SourceLocation.Longitude ) { pinView.PinColor = MKPinAnnotationColor.Green; } else { pinView.PinColor = MKPinAnnotationColor.Red; } return pinView; }
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation) { if (annotation is MKUserLocation) return null; // stock pin annotation view // MKPinAnnotationView annotationView = mapView.DequeueReusableAnnotation (annotationId) as MKPinAnnotationView; // if (annotationView == null) // annotationView = new MKPinAnnotationView (annotation, annotationId); // // annotationView.PinColor = MKPinAnnotationColor.Purple; // annotationView.CanShowCallout = true; // annotationView.Draggable = true; // annotationView.RightCalloutAccessoryView = UIButton.FromType (UIButtonType.DetailDisclosure); // annotation view with custom image set var restaurantAnnotation = annotation as RestaurantAnnotation; MKAnnotationView annotationView = mapView.DequeueReusableAnnotation (annotationId); if (annotationView == null) annotationView = new MKAnnotationView (annotation, annotationId); switch (restaurantAnnotation.Kind) { case RestaurantKind.Pizza: annotationView.Image = UIImage.FromFile ("images/Pizza.png"); break; case RestaurantKind.Seafood: annotationView.Image = UIImage.FromFile ("images/Seafood.png"); break; } annotationView.CanShowCallout = true; annotationView.RightCalloutAccessoryView = UIButton.FromType (UIButtonType.DetailDisclosure); return annotationView; }
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; }
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation) { try { var anv = mapView.DequeueReusableAnnotation("thisLocation"); if (anv == null) { MKPinAnnotationView pinanv = new MKPinAnnotationView(annotation, "thisLocation"); pinanv.CanShowCallout = true; pinanv.Draggable =true; pinanv.AnimatesDrop = true; pinanv.PinColor = MKPinAnnotationColor.Green; anv = pinanv; } else { anv.Annotation = annotation; } return anv; } catch (Exception e) { Console.WriteLine("Failed to get view for annotation " + e); return null; } }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { MKPinAnnotationView anView; if (annotation is MKUserLocation) return null; if (annotation is mapAnotation) { anView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation (Pid); if (anView == null) anView = new MKPinAnnotationView (annotation, Pid); //((MKPinAnnotationView)anView).PinColor = MKPinAnnotationColor.Green; anView.Image = new UIImage ((annotation as mapAnotation).imageUrl); anView.Frame = new RectangleF ((float)anView.Frame.X, (float)anView.Frame.Y, 30, 30); anView.SizeToFit (); anView.CanShowCallout = true; anView.Draggable = true; var btn = UIButton.FromType (UIButtonType.DetailDisclosure); //btn.SetTitle (">", UIControlState.Normal); //btn.Frame = new RectangleF ((float)anView.Frame.Width - 30, ((float)anView.Frame.Height / 2) - 15, 30, 30); //btn.SetTitleColor (UIColor.Red, UIControlState.Normal); //btn.BackgroundColor = UIColor.Yellow; anView.RightCalloutAccessoryView = btn; //anView.acce .AddSubview (btn); //anView.RightCalloutAccessoryView = (annotation as mapAnotation).btnSelect; return anView; } else return null; }
/// <summary> /// Returns our custom MKAnnotationView /// </summary> public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation annotation) { if (annotation is MKUserLocation) { return null; } else { var annotationView = mapView.DequeueReusableAnnotation (Identifier) as MKPinAnnotationView; if (annotationView == null) { annotationView = new MKPinAnnotationView(annotation, Identifier); annotationView.PinColor = MKPinAnnotationColor.Green; annotationView.AnimatesDrop = true; annotationView.CanShowCallout = true; annotationView.RightCalloutAccessoryView = UIButton.FromType (UIButtonType.DetailDisclosure); } else { annotationView.Annotation = annotation; } return annotationView; } }
MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation annotation) { // if it's the user location, just return nil. if (annotation is MKUserLocation) return null; // handle our two custom annotations // if (annotation is BridgeAnnotation) { // for Golden Gate Bridge const string BridgeAnnotationIdentifier = "bridgeAnnotationIdentifier"; MKPinAnnotationView pinView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation (BridgeAnnotationIdentifier); if (pinView == null) { MKPinAnnotationView customPinView = new MKPinAnnotationView (annotation, BridgeAnnotationIdentifier); customPinView.PinColor = MKPinAnnotationColor.Purple; customPinView.AnimatesDrop = true; customPinView.CanShowCallout = true; UIButton rightButton = UIButton.FromType (UIButtonType.DetailDisclosure); rightButton.AddTarget ((object sender, EventArgs ea) => showDetails (), UIControlEvent.TouchUpInside); customPinView.RightCalloutAccessoryView = rightButton; pinViews.Add (customPinView); return customPinView; } else { pinView.Annotation = annotation; } return pinView; } else if (annotation is SFAnnotation) { // for City of San Francisco const string SFAnnotationIdentifier = "SFAnnotationIdentifier"; MKAnnotationView pinView = (MKAnnotationView)mapView.DequeueReusableAnnotation (SFAnnotationIdentifier); if (pinView == null) { MKAnnotationView annotationView = new MKAnnotationView (annotation, SFAnnotationIdentifier); annotationView.CanShowCallout = true; UIImage flagImage = UIImage.FromFile ("flag.png"); CGRect resizeRect = CGRect.Empty; resizeRect.Size = flagImage.Size; CGSize maxSize = View.Bounds.Inset (AnnotationPadding, AnnotationPadding).Size; maxSize.Height -= NavigationController.NavigationBar.Frame.Size.Height - CalloutHeight; if (resizeRect.Size.Width > maxSize.Width) resizeRect.Size = new CGSize (maxSize.Width, resizeRect.Size.Height / resizeRect.Size.Width * maxSize.Width); if (resizeRect.Size.Height > maxSize.Height) resizeRect.Size = new CGSize (resizeRect.Size.Width / resizeRect.Size.Height * maxSize.Height, maxSize.Height); resizeRect.Location = CGPoint.Empty; UIGraphics.BeginImageContext (resizeRect.Size); flagImage.Draw (resizeRect); UIImage resizedImage = UIGraphics.GetImageFromCurrentImageContext (); UIGraphics.EndImageContext (); annotationView.Image = resizedImage; annotationView.Opaque = false; UIImageView sfIconView = new UIImageView (UIImage.FromFile ("SFIcon.png")); annotationView.LeftCalloutAccessoryView = sfIconView; pinViews.Add (annotationView); return annotationView; } else { pinView.Annotation = annotation; } return pinView; } return null; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation) { MKAnnotationView annotationView = null; if (annotation is CCHMapClusterAnnotation) { var mapClusterAnnotation = annotation as CCHMapClusterAnnotation; var pin = mapView.DequeueReusableAnnotation("Pin") as MKPinAnnotationView; if (pin == null) pin = new MKPinAnnotationView(null, "Pin"); pin.Annotation = mapClusterAnnotation; pin.CanShowCallout = true; annotationView = pin; } return annotationView; }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation) { Console.WriteLine("attempt to get view for MKAnnotation " + annotation); try { var anv = mapView.DequeueReusableAnnotation("thislocation"); if (anv == null) { Console.WriteLine("creating new MKAnnotationView"); var pinanv = new MKPinAnnotationView(annotation, "thislocation"); pinanv.AnimatesDrop = true; pinanv.PinColor = MKPinAnnotationColor.Green; pinanv.CanShowCallout = true; anv = pinanv; } else { anv.Annotation = annotation; } return anv; } catch (Exception ex) { Console.WriteLine("GetViewForAnnotation Exception " + ex); return null; } }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { MKAnnotationView annotationView = null; if (annotation is MKUserLocation) return null; if (annotation is CarAnnotation) { annotationView = mapView.DequeueReusableAnnotation(CarAnnotation) ?? new MKAnnotationView(annotation, CarAnnotation); if (((CarAnnotation) annotation).Color == UIColor.Blue) { annotationView.Image = UIImage.FromBundle(Images.CarAnnotationBlue); } else { annotationView.Image = UIImage.FromBundle(Images.CarAnnotationRed); } annotationView.CanShowCallout = false; } if (annotation is PoiAnnotation) { annotationView = mapView.DequeueReusableAnnotation(POI_ANNOTATION) ?? new MKAnnotationView(annotation, POI_ANNOTATION); if (((PoiAnnotation) annotation).Description == "Hard Acceleration") { annotationView.Image = UIImage.FromBundle(Images.TipAnnotation); } else { annotationView.Image = UIImage.FromBundle(Images.TipAnnotation); } annotationView.CanShowCallout = false; } if (annotation is WaypointAnnotation) { annotationView = mapView.DequeueReusableAnnotation(WaypointAnnotation) ?? new MKAnnotationView(annotation, WaypointAnnotation); if (((WaypointAnnotation) annotation).Waypoint == "A") { annotationView.Image = UIImage.FromBundle(Images.WaypointAnnotationA); } else { annotationView.Image = UIImage.FromBundle(Images.WaypointAnnotationB); } annotationView.CanShowCallout = false; } return annotationView; }