This project is read-only.

How to write code to control the line color of line layers?

Aug 9, 2011 at 12:06 PM
Edited Aug 9, 2011 at 3:53 PM

hello:

I have a question:

 How to write code to control the line color of  line layers?

Any help will be appreciated.

Regards,

S.G.

Aug 10, 2011 at 12:49 PM

LineScheme myScheme = new LineScheme();
myScheme.Categories.Clear();
LineCategory low = new LineCategory(Color.Blue, 2);
low.FilterExpression = "[tile_id] < 36";
low.LegendText = "Low";
LineCategory high = new LineCategory(Color.Red, Color.Black, 6, DashStyle.Solid,
LineCap.Triangle);
high.FilterExpression = "[tile_id] >= 36";
50 of 85
high.LegendText = "High";
myScheme.AppearsInLegend = true;
myScheme.LegendText = "Tile ID";
myScheme.Categories.Add(low);
myScheme.Categories.Add(high);
myLayer.Symbology = myScheme;

Aug 10, 2011 at 5:04 PM
fjm11100 wrote:

LineScheme myScheme = new LineScheme();
myScheme.Categories.Clear();
LineCategory low = new LineCategory(Color.Blue, 2);
low.FilterExpression = "[tile_id] < 36";
low.LegendText = "Low";
LineCategory high = new LineCategory(Color.Red, Color.Black, 6, DashStyle.Solid,
LineCap.Triangle);
high.FilterExpression = "[tile_id] >= 36";
50 of 85
high.LegendText = "High";
myScheme.AppearsInLegend = true;
myScheme.LegendText = "Tile ID";
myScheme.Categories.Add(low);
myScheme.Categories.Add(high);
myLayer.Symbology = myScheme;

This is in accordance with your recommendations to do, but the map does not show

         var test = new DotSpatial.Data.Database.SpatiaLiteVectorProvider();
         this.map1.Layers.Add(test.Open(@"Data Source=D:\yjsj\yj.sqlite;", "yjXZQ", "PK_UID", "Geometry"));
         MapPolygonLayer ss = default(MapPolygonLayer);

         ss = (MapPolygonLayer)map1.Layers[0];
         if (ss == null)
         {
             MessageBox.Show("The layer is not a polygon layer.");

         }

         PolygonScheme scheme = new PolygonScheme();
         scheme.Categories.Clear();
         PolygonCategory category = new PolygonCategory(Color.Yellow, Color.Red, 2);

         scheme.Categories.Add(category);
         ss.Symbology = scheme;

 

 

This is in accordance with your recommendations to do, but the map does not show

Aug 11, 2011 at 8:35 AM

which one, one line of a layer or all lines of a layer?

all line:

ss.Symbolizer.SetFillColor = Color.Blue;

one line:

1- you must define an attribute("tile_id" in my sample ) for your Featureset

2- set FilterExpression property, for example category.FilterExpression = "[tile_id] < 36"

Excuse my bad English!