Sanjay,
Try following code snippet to create the layer and I attached the result for it too.
InMemoryFeatureLayer layer = new InMemoryFeatureLayer();
layer.Open();
layer.Columns.Add(new FeatureSourceColumn("GridName","string",20));
layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Highway1;
layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1;
layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1("GridName");
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
int gridSize = 5;
PointShape[,] points = new PointShape[gridSize, gridSize];
PointShape p1 = new PointShape(0, 70);
points[0, 0] = p1;
Feature feature = p1.GetFeature();
//feature.ColumnValues.Add("GridName", "1 Box = 500 Meter");
layer.InternalFeatures.Add(feature);
for (int i = 1; i < gridSize; i++)
{
PointShape p = (PointShape)p1.CloneDeep();
p.TranslateByDegree(100 * i, 360, winformsMap1.MapUnit, DistanceUnit.Kilometer);
layer.InternalFeatures.Add(p.GetFeature());
points[0, i] = p;
}
for (int i = 0; i < gridSize; i++)
{
PointShape point = points[0, i];
for (int j = 1; j < gridSize; j++)
{
PointShape p = (PointShape)point.CloneDeep();
p.TranslateByDegree(100 * j, 270, winformsMap1.MapUnit, DistanceUnit.Kilometer);
Feature feature1 = p.GetFeature();
if((j == gridSize -1) && ( i == gridSize -1))
{
feature1.ColumnValues.Add("GridName", "1 Box = 500 Meter");
}
layer.InternalFeatures.Add(feature1);
points[j, i] = p;
}
}
for (int i = 0; i < gridSize; i++)
{
LineShape line = new LineShape();
LineShape line2 = new LineShape();
for (int j = 0; j < gridSize; j++)
{
PointShape point = points[i, j];
line.Vertices.Add(new Vertex(point.X, point.Y));
PointShape point2 = points[j, i];
line2.Vertices.Add(new Vertex(point2.X, point2.Y));
}
layer.InternalFeatures.Add(line.GetFeature());
layer.InternalFeatures.Add(line2.GetFeature());
}
EllipseShape ellipse = new EllipseShape(points[2, 2], 100, 100, winformsMap1.MapUnit, DistanceUnit.Kilometer);
layer.InternalFeatures.Add(ellipse.GetFeature());
Any more questions please feel free to let me know
Thanks.
Yale