您好,这是我的代码,测试可行。要保证你的工作空间打开的,因为符号库存在工作空间里的
DatasetVector point = workspace1.Datasources[0].Datasets[0] as DatasetVector;
ThemeUnique theme = new ThemeUnique();
GeoStyle style = new GeoStyle();
theme.UniqueExpression = "SmID";
for (int i = 0; i < 6; i++)
{
ThemeUniqueItem item = new ThemeUniqueItem();
item.Caption = i.ToString();
item.IsVisible = true;
item.Unique = i.ToString();
style.MarkerSymbolID =318;
style.MarkerSize = new Size2D(10, 10);
style.FillForeColor = Color.Blue;
item.Style = style;
theme.Add(item);
}
mapControl1.Map.Layers.Add(point, theme, true);
mapControl1.Map.Refresh();