Show a layer alias to a table by muti color in Posgis

Developer
Aug 10, 2007 at 3:18 AM
Hi all!
I want show a layer on my map with muti color
Exp: a district is muti wards and each ward is a color. I want map show only one layer
I coded muti color like following code: (but it is muti layer)
String sql = "select astext(thegeom)as thegeom, name from Wards";
DataTable tbl = ExecuteQuery(strcon, sql);
Collection<string> listColor = new Collection<string>();
listColor.Add("8deeee");
listColor.Add("f0fff0");
listColor.Add("339999");
listColor.Add("ccff66");
listColor.Add("99cc66");
listColor.Add("dda0dd");
listColor.Add("ffebd7");
listColor.Add("ffffe0");
listColor.Add("ffdead");
int j = 0;
if (tbl != null)
{
for (int i=0;i<tbl.Rows.Count ;i++)
{

SharpMap.Geometries.Geometry temp=SharpMap.Converters.WellKnownText.GeometryFromWKT.Parse(tbl.Rowsi"the_geom".ToString());
SharpMap.Layers.VectorLayer layer = new SharpMap.Layers.VectorLayer("layerWard" + " "+ tbl.Rowsi"name".ToString());
layer.DataSource = new SharpMap.Data.Providers.GeometryProvider(temp);
layer.Style = new SharpMap.Styles.VectorStyle();
string color = listColorj.ToString();
layer.Style.Fill = new SolidBrush(ColorTranslator.FromHtml("#"+color));
mapcontrol.Map.Layers.Add(layer);
if (j == listColor.Count - 1)
j = 0;
else
j++;
}
}
I added muti layer with muti color in a district with muti ward, but i want to show them with only a muti-color layer
Pls help me. Thanks!
Developer
Aug 13, 2007 at 9:42 AM
Edited Aug 13, 2007 at 10:03 AM
You can create a custom theme for the layer. In the GetStyleMethod callback you can set the style based on a FeatureDataRow field.

Look here:
http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=CustomTheme
Developer
Aug 14, 2007 at 2:41 AM
thanks for your reply!
I used custom theme. Your reply is so late, but i read in book for sharpmap v09.
Thanks!