专题图代码主体部分
SharpMap.Layers.VectorLayer layerValve;
layerValve = new SharpMap.Layers.VectorLayer("valve", new SharpMap.Data.Providers.ShapeFile("../data/valve.shp"));
layerValve.Style.SymbolOffset = new PointF(20, -35);
map.Layers.Add(layerValve);
SharpMap.Rendering.Thematics.CustomTheme myThemeValve = new SharpMap.Rendering.Thematics.CustomTheme(GetThemeStyleValve);
layerValve.Theme = myThemeValve;
////////////////////////////////////////////////////////
专题图函数为
private static SharpMap.Styles.VectorStyle GetThemeStyleValve(SharpMap.Data.FeatureDataRow row)
{
string strThemeField = row["onoroff"].ToString();
SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();
if (strThemeField != null)
{
if (strThemeField != "" && int.Parse(strThemeField) == 1)
{
style.SymbolScale = 0.4f;
style.Symbol = new Bitmap("../resourcefiles/pipeOn.PNG");
}
else
{
style.SymbolScale = 0.42f;
style.Symbol = new Bitmap("../resourcefiles/pipeOff.PNG");
}
style.SymbolOffset = new PointF(0, -15);
}
style.EnableOutline = true;
return style;
}
SharpMap.Layers.VectorLayer layerValve;
layerValve = new SharpMap.Layers.VectorLayer("valve", new SharpMap.Data.Providers.ShapeFile("../data/valve.shp"));
layerValve.Style.SymbolOffset = new PointF(20, -35);
map.Layers.Add(layerValve);
SharpMap.Rendering.Thematics.CustomTheme myThemeValve = new SharpMap.Rendering.Thematics.CustomTheme(GetThemeStyleValve);
layerValve.Theme = myThemeValve;
////////////////////////////////////////////////////////
专题图函数为
private static SharpMap.Styles.VectorStyle GetThemeStyleValve(SharpMap.Data.FeatureDataRow row)
{
string strThemeField = row["onoroff"].ToString();
SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();
if (strThemeField != null)
{
if (strThemeField != "" && int.Parse(strThemeField) == 1)
{
style.SymbolScale = 0.4f;
style.Symbol = new Bitmap("../resourcefiles/pipeOn.PNG");
}
else
{
style.SymbolScale = 0.42f;
style.Symbol = new Bitmap("../resourcefiles/pipeOff.PNG");
}
style.SymbolOffset = new PointF(0, -15);
}
style.EnableOutline = true;
return style;
}