public class Circle : Polygon { private double radius = double.NaN; private MapPoint center = null; private int pointCount = 360; public double Radius { get { return radius; } set { radius = value; CreateRing(); } } [System.ComponentModel.TypeConverter(typeof(MapPointConverter))] public MapPoint Center { get { return center; } set { center = value; CreateRing(); } } public int PointCount { get { return pointCount; } set { pointCount = value; CreateRing(); } } private void CreateRing() { this.Rings.Clear(); if (!double.IsNaN(Radius) && Radius > 0 && Center != null && PointCount > 2) { PointCollection pnts = new PointCollection(); for (int i = 0; i <= PointCount; i++) { double rad = 2 * Math.PI / PointCount * i; double x = Math.Cos(rad) * radius + Center.X; double y = Math.Sin(rad) * radius + Center.Y; pnts.Add(new MapPoint(x, y)); } this.Rings.Add(pnts); } } }
var buffer = new _2gDataRoomViewer.MyGeoms.Circle(); buffer.Center = new MapPoint(lon, lat); buffer.Radius = bufferSize / (MyMap.Scale * 3.2808);//bufferSize is the width in meter GraphicsLayer bufferPuitsLayer = MyMap.Layers["BufferPuitsLayer"] as GraphicsLayer; var symbol = new SimpleFillSymbol(); symbol.BorderThickness = 3; SolidColorBrush color = new SolidColorBrush(Colors.Violet); symbol.Fill = color; symbol.Fill.Opacity = 0.3; symbol.BorderBrush = color; Graphic graphic = new Graphic() { Geometry = mercator.FromGeographic(buffer), Symbol = symbol }; bufferPuitsLayer.Graphics.Add(graphic);
Solved! Go to Solution.