Problem with CustomTheme

Topics: General Topics
Oct 27, 2006 at 7:14 AM

I have a small app utilising SharpMap to draw Satellite Spotbeam coverage maps onto the earth surface. I'd like to utilize the Custom Theme functionality to colour individual spots after certain attributes, but I've run into a problem i can't work out.

I use a standard PictureBox Control to display the image but when calling map.GetMap() i get a System.NullReferenceException.

If i remove the Theme from the layer everything works fine.

Any help is greatly appreciated

The essential parts of the code looks like this:

SharpMap.Map map = new SharpMap.Map(outputsize);
SharpMap.Layers.VectorLayer layNarrow64E;
SharpMap.Rendering.Thematics.CustomTheme spotTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetSpotStyle);
layNarrow64E = new SharpMap.Layers.VectorLayer("Narrow64E");
layNarrow64E.DataSource = new SharpMap.Data.Providers.ShapeFile("../narrow64E.shp");
layNarrow64E.Theme = spotTheme;
SharpMap.Styles.VectorStyle GetSpotStyle(SharpMap.Data.FeatureDataRow row)
// Modfied for simplicity */
SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();

style.Fill = Brushes.Yellow;
style.Outline = Pens.Blue;
return style;
Nov 3, 2006 at 6:48 AM
I managed to figure it out myself. Although you can render a map with layers using only a Shapefile, the use of custom themes require a feature file (.dbf) to be present as well, otherwise you get a NullReferenceException when calling map.GetMap().