I am attempting to add a MapLineLayer with lines to my map.
What I am trying to do is:
The OD_matrix and coordinate variables are defined elsewhere in the code.
When I run my program, the categories show up correctly in the legend, however the map control doesn't change.
Any help appreciated!
Sorry if anything is unclear or I have made any stupid mistakes; I am still new to this.
What I am trying to do is:
- Create a new MapLineLayer
- Add line (features) to the layer
- Add a "Volume" attribute to the attribute table with a value corresponding to each line
- Create a new LineScheme containing LineCategories for each unique "Volume" value
- The "Volume" data comes from an OD_matrix (2D array)
- Line coordinates come from two arrays x[], y[]
MapLineLayer LineLyr = new MapLineLayer;
LineLyr.DataSet = new FeatureSet(FeatureType.Line);
LineLyr.DataSet.FillAttributes();
LineLyr.DataSet.DataTable.Columns.Add("Volume");
LineScheme LineSch = new LineScheme();
LineLyr.Symbology = LineSch;
IFeature feature;
LineCategory[] lineCat = new LineCategory[centroid_nodes.Count];
LineString desire_line;
Coordinate from_coord = new Coordinate();
var coord_set = new List<Coordinate>();
for (i = 0; i < centroid_nodes.Count; i++)
{
from_coord = new Coordinate(x_coords[i], y_coords[i]);
coord_set.Add(from_coord);
coord_set.Add(to_zone_coord);
desire_line = new LineString(coord_set);
feature = LineLyr.DataSet.AddFeature(desire_line);
coord_set.Clear();
feature.DataRow.BeginEdit();
feature.DataRow["Volume"] = (OD_matrix[i][to_zone]).ToString();
feature.DataRow.EndEdit();
lineCat[i] = new LineCategory(Color.Blue, (double)(OD_matrix[centroid_nodes[i]][to_zone] * 5));
lineCat[i].FilterExpression = "[Volume] = " + (OD_matrix[centroid_nodes[i]][to_zone]).ToString();
lineCat[i].LegendText = (centroid_nodes[i]).ToString();
LineSch.AddCategory(lineCat[i]);
}
map1.Layers.Add(LineLyr);
LineLyr.DataSet.InitializeVertices();
map1.ResetBuffer();
The OD_matrix and coordinate variables are defined elsewhere in the code.
When I run my program, the categories show up correctly in the legend, however the map control doesn't change.
Any help appreciated!
Sorry if anything is unclear or I have made any stupid mistakes; I am still new to this.