Accelerated layers using circles with strokes

499
2
06-03-2013 01:43 AM
Labels (1)
arnoudde_jong
New Contributor
Hi all,

I have a SimpleMarkerSymbol on an accelerated layer displaying a circle. The circle only accepts a fill color and I would like to add a stroke width/color. Any suggestions on how to achieve this?

Arnoud
0 Kudos
2 Replies
AaronHigh
New Contributor III
You might try a SimpleLineSymbol to render the ellipse itself and then use a SimpleFillSymbol to do the interior. This link (http://tilonthuduc.blogspot.com/2012/07/a-hatch-drawing-brush-for-wpf-in-visual.html) provides information on porting GDI+ hatch brushes to WPF, which will work with a SimpleFillSymbol.
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

If you're symbolizing points and using marker symbols you could consider using WPF elements to get the visual effect you would like then render the WPF element as an image and use it as a PictureMarkerSymbol:

// Create a diagonal linear gradient with four stops.   
// http://msdn.microsoft.com/en-us/library/system.windows.media.lineargradientbrush.aspx
LinearGradientBrush myLinearGradientBrush =
    new LinearGradientBrush();
myLinearGradientBrush.StartPoint = new Point(0, 0);
myLinearGradientBrush.EndPoint = new Point(1, 1);
myLinearGradientBrush.GradientStops.Add(
    new GradientStop(Colors.Yellow, 0.0));
myLinearGradientBrush.GradientStops.Add(
    new GradientStop(Colors.Red, 0.25));
myLinearGradientBrush.GradientStops.Add(
    new GradientStop(Colors.Blue, 0.75));
myLinearGradientBrush.GradientStops.Add(
    new GradientStop(Colors.LimeGreen, 1.0));
 
// Add an Ellipse Element
// http://msdn.microsoft.com/en-us/library/system.windows.shapes.ellipse.aspx
Ellipse myEllipse = new Ellipse();
myEllipse.Stroke = System.Windows.Media.Brushes.Black;
myEllipse.Fill = myLinearGradientBrush;
myEllipse.HorizontalAlignment = HorizontalAlignment.Left;
myEllipse.VerticalAlignment = VerticalAlignment.Center;
myEllipse.Width = 50;
myEllipse.Height = 50;
            
 
//Force render
myEllipse.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
myEllipse.Arrange(new Rect(myEllipse.DesiredSize));
 
RenderTargetBitmap render = new RenderTargetBitmap(200, 200, 150, 150, PixelFormats.Pbgra32);
render.Render(myEllipse);
 
PictureMarkerSymbol pms = new PictureMarkerSymbol() 
{
    Source = render,
};

Random random = new Random();
var graphic = new Graphic() { Geometry = new MapPoint(random.Next(-20000000, 20000000), random.Next(-20000000, 20000000)) };
graphic.Symbol = pms;
MarkerGraphicsLayer.Graphics.Add(graphic);


Cheers

Mike
0 Kudos