This project has moved and is read-only. For the latest updates, please go here.

event rendering

Topics: General Topics
Oct 1, 2011 at 12:52 PM

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

Oct 2, 2011 at 2: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++)


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



// Make A New Line from Thoso Points


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



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


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



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


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

VL.Style.Line =

new Pen(Color.Red);

VL.Enabled =



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