Draw a circle on the map

Nov 24, 2009 at 8:50 AM
hi, how can i draw a circle on the map ? thanks.
Nov 26, 2009 at 1:55 PM

Make a regular polygon that inscribes the circle you want.  20, 30 or 36 edges would suffice...

Jan 8, 2010 at 12:59 PM

1. Modify the geometryLayer.cs file to include logic to draw the arc instead of line as below.

pf.StartPoint = pixel;
                    }
                    else
                    {
                        if (pathGeometry.IsArc == true)
                        {
                            var ls = new ArcSegment();
                            ls.Point = pixel;
                            ls.Size = new Size(pathGeometry.Width, pathGeometry.Height);
                            ls.IsLargeArc = pathGeometry.IsLargeArc;
                            ls.SweepDirection = pathGeometry.SweepDirection;
                            pf.Segments.Add(ls);
                        }
                        else
                        {
                            var ls = new LineSegment { Point = pixel };
                            pf.Segments.Add(ls);
                        }
                    }

2. Modify PathBase.cs file to include properties for setting the arc values

public abstract class PathBase : GeometryBase
    {
        protected Rect _Extent;
        protected Path _Path;
        protected Color _LineColor;
        protected double _LineThickness;
        protected ObservableCollection<Point> _Points;
        protected List<Point> _LogicalCoordinates;

        public bool IsArc { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }
        public bool IsLargeArc { get; set; }
        public SweepDirection SweepDirection { get; set; }

3. Example code to create the circle - create 2 arcs (semi-circles). If you come across a better way of doing, let me know.

DeepEarth.Geometry.Polygon _el = new DeepEarth.Geometry.Polygon();
            _el.Points.Add(new Point(20, 0));
            _el.Points.Add(new Point(-20, 0));
            _el.LineThickness = 4;
            _el.Width = 20;
            _el.Height = 20;
            _el.IsLargeArc = true;
            _el.IsArc = true;
            _el.LineColor = Colors.Transparent;
            _el.FillColor = Colors.Orange;
            elementUpdateLayer.Add(_el);