Hi Ethan,
thank you for your reply.
I narrowed down my investigation and this is what I found.
I need to generate custom grid evenly spaced 1 km. This is done by creating lines in InMemoryFeatureLayer.
My goal is to show different grid lines spacing for different zoomlevels so my featureLayer contains FeatureSourceColumn(“gline”) and then I have one ValueStyle
public static ValueStyle ValueStyleKilometerGrid(int level, LineStyle lineStyle)
{
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "gline";
valueStyle.ValueItems.Add(new ValueItem("0", lineStyle));
valueStyle.ValueItems.Add(new ValueItem("100", lineStyle));
if (level == 0)
{
valueStyle.ValueItems.Add(new ValueItem("50", lineStyle));
}
else if (level == 1)
{
for (int i = 25; i < 100; i += 25)
{
valueStyle.ValueItems.Add(new ValueItem(i.ToString(), lineStyle));
}
}
else if (level == 2)
{
for (int i = 20; i < 100; i += 20)
{
valueStyle.ValueItems.Add(new ValueItem(i.ToString(), lineStyle));
}
}
else if (level == 3)
{
for (int i = 10; i < 100; i += 10)
{
valueStyle.ValueItems.Add(new ValueItem(i.ToString(), lineStyle));
}
}
else if (level == 4)
{
for (int i = 5; i < 100; i += 5)
{
valueStyle.ValueItems.Add(new ValueItem(i.ToString(), lineStyle));
}
}
else if (level == 5)
{
for (int i = 2; i < 100; i += 2)
{
valueStyle.ValueItems.Add(new ValueItem(i.ToString(), lineStyle));
}
}
return valueStyle;
}
and custom ZoomLevelSet
public static ZoomLevelSet KilometerGridZoomLevelSet()
{
ZoomLevelSet zoomLevelSet = new ZoomLevelSet();
zoomLevelSet = MainWindow.SetZoomLeves();
zoomLevelSet.ZoomLevel02.CustomStyles.Add(ValueStyleKilometerGrid(0, kmGridLineStyle16));
zoomLevelSet.ZoomLevel03.CustomStyles.Add(ValueStyleKilometerGrid(0, kmGridLineStyle32));
zoomLevelSet.ZoomLevel04.CustomStyles.Add(ValueStyleKilometerGrid(0, kmGridLineStyle64));
zoomLevelSet.ZoomLevel05.CustomStyles.Add(ValueStyleKilometerGrid(1, kmGridLineStyle64));
zoomLevelSet.ZoomLevel06.CustomStyles.Add(ValueStyleKilometerGrid(2, kmGridLineStyle64));
zoomLevelSet.ZoomLevel07.CustomStyles.Add(ValueStyleKilometerGrid(3, kmGridLineStyle64));
zoomLevelSet.ZoomLevel07.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level08;
zoomLevelSet.ZoomLevel09.CustomStyles.Add(ValueStyleKilometerGrid(4, kmGridLineStyle64));
zoomLevelSet.ZoomLevel09.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level10;
zoomLevelSet.ZoomLevel11.CustomStyles.Add(ValueStyleKilometerGrid(5, kmGridLineStyle64));
zoomLevelSet.ZoomLevel12.DefaultLineStyle = kmGridLineStyle64;
zoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
return zoomLevelSet;
}
I think that somewhere here is problem that can cause above exception.
For now I have workaround that will generate grid lines for each grid step to different InMemoryFeatureLayer but this is not very elegant solution I think.
Thanks
Martin