Ejemplo n.º 1
0
        private void OnPinPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            Pin               pin        = sender as Pin;
            SKPin             skiaPin    = pin as SKPin;
            MKPointAnnotation annotation = FindAnnotationForPin(pin) as MKPointAnnotation;

            if (skiaPin != null)
            {
                if (args.PropertyName == SKPin.WidthProperty.PropertyName ||
                    args.PropertyName == SKPin.HeightProperty.PropertyName)
                {
                    UpdateAnnotationIcon(skiaPin);
                }
                else if (args.PropertyName == SKPin.AnchorXProperty.PropertyName ||
                         args.PropertyName == SKPin.AnchorYProperty.PropertyName)
                {
                    MKAnnotationView    view      = _NativeControl.ViewForAnnotation(annotation);
                    SKPinAnnotationView skPinView = view as SKPinAnnotationView;

                    skPinView?.UpdateAnchor();
                }
                else if (args.PropertyName == SKPin.IsVisibleProperty.PropertyName)
                {
                    MKAnnotationView view = _NativeControl.ViewForAnnotation(annotation);

                    if (view != null)
                    {
                        view.Hidden = !skiaPin.IsVisible;
                    }
                }
                else if (args.PropertyName == SKPin.ClickableProperty.PropertyName)
                {
                    MKAnnotationView view = _NativeControl.ViewForAnnotation(annotation);

                    if (view != null)
                    {
                        view.Enabled = !skiaPin.Clickable;
                    }
                }
            }

            if (pin != null && annotation != null)
            {
                if (args.PropertyName == Pin.LabelProperty.PropertyName)
                {
                    annotation.Title = pin.Label;
                }
                else if (args.PropertyName == Pin.AddressProperty.PropertyName)
                {
                    annotation.Subtitle = pin.Address;
                }
                else if (args.PropertyName == Pin.PositionProperty.PropertyName)
                {
                    annotation.Coordinate = pin.Position.ToLocationCoordinate();
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateAnnotationIcon(SKPin pin)
        {
            IMKAnnotation       annotation = FindAnnotationForPin(pin);
            MKAnnotationView    view       = _NativeControl.ViewForAnnotation(annotation);
            SKPinAnnotationView skPinView  = view as SKPinAnnotationView;

            skPinView?.UpdateImage();
            skPinView?.UpdateAnchor();
        }
Ejemplo n.º 3
0
        private MKAnnotationView GetViewForPin(MKMapView mapView, IMKAnnotation annotation)
        {
            SKPinAnnotation skiaAnnotation = annotation as SKPinAnnotation;

            if (skiaAnnotation != null)
            {
                SKPin pin = skiaAnnotation.SharedPin;
                SKPinAnnotationView pinView = mapView.DequeueReusableAnnotation(SKPinAnnotationView.ViewIdentifier) as SKPinAnnotationView
                                              ?? CreateAnnotationView(skiaAnnotation);

                pinView.Annotation = skiaAnnotation;
                pinView.UpdateImage();
                pinView.UpdateAnchor();
                pinView.Hidden  = !pin.IsVisible;
                pinView.Enabled = !pin.Clickable;

                return(pinView);
            }

            return(null);
        }