Beispiel #1
0
        void FindXamarinHeadquarters()
        {
            var myCustomAnnotation = new CustomAnnotation(new CLLocationCoordinate2D(XamarinHQ.Latitude, XamarinHQ.Longitude), "Xamarin HQ", "San Francisco");

            //Add custom annotation to screen
            map.AddAnnotation(myCustomAnnotation);

            // Customize view
            map.GetViewForAnnotation = (mapView, annotation) => {
                if (annotation is MKUserLocation)
                {
                    return(null);
                }

                MKAnnotationView view = null;
                if (annotation is MKPointAnnotation)
                {
                    view = mapView.DequeueReusableAnnotation(pinId);
                    if (view == null)
                    {
                        view = new MKPinAnnotationView(annotation, pinId);
                        ((MKPinAnnotationView)view).PinColor       = MKPinAnnotationColor.Green;
                        ((MKPinAnnotationView)view).CanShowCallout = true;
                    }
                }
                else if (annotation is CustomAnnotation)
                {
                    view = mapView.DequeueReusableAnnotation(customPinId);
                    if (view == null)
                    {
                        view = new MKAnnotationView(annotation, customPinId);
                        view.CanShowCallout = true;
                    }
                    view.Image = UIImage.FromFile("xamarin.png");
                }
                return(view);
            };

            Helpers.CenterOnXamarin(map);
        }
        void FindXamarinHeadquarters()
        {
            var myCustomAnnotation = new CustomAnnotation (new CLLocationCoordinate2D (XamarinHQ.Latitude, XamarinHQ.Longitude), "Xamarin HQ", "San Francisco");

            //Add custom annotation to screen
            map.AddAnnotation (myCustomAnnotation);

            // Customize view
            map.GetViewForAnnotation = (mapView, annotation) => {
                if (annotation is MKUserLocation)
                    return null;

                MKAnnotationView view = null;
                if (annotation is MKPointAnnotation) {
                    view = mapView.DequeueReusableAnnotation (pinId);
                    if (view == null) {
                        view = new MKPinAnnotationView (annotation, pinId);
                        ((MKPinAnnotationView)view).PinColor = MKPinAnnotationColor.Green;
                        ((MKPinAnnotationView)view).CanShowCallout = true;

                    }
                } else if (annotation is CustomAnnotation) {
                    view = mapView.DequeueReusableAnnotation (customPinId);
                    if (view == null) {
                        view = new MKAnnotationView (annotation, customPinId);
                        view.CanShowCallout = true;
                    }
                    view.Image = UIImage.FromFile ("xamarin.png");
                }
                return view;
            };

            Helpers.CenterOnXamarin (map);
        }