event rendering

Topics: General Topics
Oct 1, 2011 at 11:52 AM

How do you perform event rendering (term from MapObjects) in SharpMap? Basically, I want to render a part or segment of a line.

Editor
Oct 2, 2011 at 1:33 PM

I believe that what you do is:

 

1 Create A Geometry, ie a line made up of the points you want to draw.

2. Create A New Layer useing the Geometry provider.

3. Add That New Layer To The Map.

So something like this:

 

 

 

// Create A New List Of Points

 

IList<SharpMap.Geometries.Point> P = new List<SharpMap.Geometries.Point>();

 

 

// Generate A Set Of 1000 Random Points.
 

Random R = new Random();

 

for (int i = 0; i < 1000; i++)

P.Add(

new SharpMap.Geometries.Point(R.Next(1, 10000), R.Next(1, 10000)));
  

 

 

// Make A New Line from Thoso Points
 

SharpMap.Geometries.

LineString L = new SharpMap.Geometries.LineString(P);

 

 

// Use That As The Baiss For A New Geometry Providor
 

SharpMap.Data.Providers.

GeometryProvider GP = new SharpMap.Data.Providers.GeometryProvider(L);

 

 

// Use The Geomtry Provider to turn that into a new map layer.
 

SharpMap.Layers.

VectorLayer VL = new SharpMap.Layers.VectorLayer("TestLayer124", GP);

VL.Style.Line =

new Pen(Color.Red);

VL.Enabled =

true;

mapBox1.Map.ZoomToExtents();

But one of the sharp map gods may pop along and offer a nicer way  of doing it soon