我正在尝试创建一个基于我收到的数据动态更新的图例,唯一的问题是我在Controller中获取变量。下面的代码循环遍历一个shape文件,并从中获取一个非重复项。
List<string> values = new List<string>();
foreach (Feature f in allFeatures)
{
if (f.ColumnValues.ContainsKey(layercode))
{
if (!values.Contains(f.ColumnValues[layercode].ToString()))
{
values.Add(f.ColumnValues[layercode].ToString());
}
}
}
if (count == 0)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Green, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 1)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Pink, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 2)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Blue, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 3)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Yellow, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 4)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Violet, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 5)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Red, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 6)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Aqua, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 7)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Black, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 8)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Brown, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 9)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Coral, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 10)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.DarkKhaki, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
count++;
}
}
所以当代码完成时,我有一串数字,如4390,4393,4394等等。我如何存储这些变量以便以后在HTML中使用它们。我正在尝试创建一个基于我正在使用的图层动态更新的颜色图例。下面的代码显示了将路由到控制器的复选框。因为我总是知道我需要更新html中的字符串
<input type="checkbox" name ="colorLegend" value="ESN" onclick="createEsnLegend();" />ESN
无论如何存储这些项目以在视图中使用?
随时欢迎任何建议