Пример #1
0
            public override BMKOverlayView ViewForOverlay(BMKMapView mapView, BMKOverlay overlay)
            {
                if (typeof(BMKPolyline) == overlay.GetType())
                {
                    Polyline poly = map.Map.Polylines.Find(overlay);
                    if (null != poly)
                    {
                        BMKPolylineView view = new BMKPolylineView(overlay);
                        view.StrokeColor = poly.Color.ToUIColor();
                        view.LineWidth   = poly.Width;

                        return(view);
                    }
                }
                else if (typeof(BMKPolygon) == overlay.GetType())
                {
                    Polygon poly = map.Map.Polygons.Find(overlay);
                    if (null != poly)
                    {
                        BMKPolygonView view = new BMKPolygonView(overlay);
                        view.StrokeColor = poly.Color.ToUIColor();
                        view.FillColor   = poly.FillColor.ToUIColor();
                        view.LineWidth   = poly.Width;

                        return(view);
                    }
                }
                else if (typeof(BMKCircle) == overlay.GetType())
                {
                    Circle circle = map.Map.Circles.Find(overlay);
                    if (null != circle)
                    {
                        BMKCircleView view = new BMKCircleView(overlay);
                        view.StrokeColor = circle.Color.ToUIColor();
                        view.FillColor   = circle.FillColor.ToUIColor();
                        view.LineWidth   = circle.Width;

                        return(view);
                    }
                }

                Debug.WriteLine("MapViewViewForOverlay: " + overlay.GetType());
                return(null);
            }
Пример #2
0
        protected override void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            Polygon    item   = (Polygon)sender;
            BMKPolygon native = (BMKPolygon)item?.NativeObject;

            if (null == native)
            {
                return;
            }

            if (Annotation.TitleProperty.PropertyName == e.PropertyName)
            {
                native.Title = item.Title;
                return;
            }

            if (Polyline.PointsProperty.PropertyName == e.PropertyName)
            {
                CLLocationCoordinate2D[] points = new CLLocationCoordinate2D[item.Points.Count];
                for (int i = 0; i < points.Length; i++)
                {
                    points[i] = item.Points[i].ToNative();
                }

                native.SetPolygonWithCoordinates(ref points[0], points.Length);
                return;
            }

            if (Polyline.WidthProperty.PropertyName == e.PropertyName)
            {
                BMKPolygonView view = NativeMap.ViewForAnnotation(native);
                if (view != null)
                {
                    view.LineWidth = item.Width;
                }

                return;
            }

            if (Polyline.ColorProperty.PropertyName == e.PropertyName)
            {
                BMKPolygonView view = NativeMap.ViewForAnnotation(native);
                if (view != null)
                {
                    view.StrokeColor = item.Color.ToUIColor();
                }

                return;
            }

            if (Polygon.FillColorProperty.PropertyName == e.PropertyName)
            {
                BMKPolygonView view = NativeMap.ViewForAnnotation(native);
                if (view != null)
                {
                    view.FillColor = item.Color.ToUIColor();
                }

                return;
            }
        }