Geometry layer with multiple colors

Topics: General Topics, SharpMap v0.9 / v1.x
May 23, 2011 at 9:36 PM

I have an application built using SharpMap v0.9 that maps the position of a sensor array towed behind a robot on a map.  I would like to display the output of the sensor on the map as it is moved around a field.  What I would like to do is paint the map with colored rectangles where the color indicates the sensor value.  What would be the easiest way to go about this?  As far as I can tell you cannot associate a color with an individual geometry inside a layer, but only with the entire geometry layer.  Is there a way to create a layer with multiple colors without having to generate a new layer for each color value?  

 

Thanks,

 

David

Coordinator
May 24, 2011 at 5:52 AM

Hi, you can attach a delegate that returns the symbol to be used when drawing a specific feature.

 

layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(drawingdelegate)

...
ISymbol drawingdelegate(FeatureDataRow row) { if (row["attribute"] == "somwthing") { SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle(); style.Fill = Brushes.Yellow; return style; } }