What I write is so plain that I hope to give some help to beginners. As for the in-depth study of SHARPMAP and GIS technology, Daniel, please give us a little more guidance to these rookie.
Today we will talk about the basic use of sharpmap, according to attribute to fill the color of the map objects, so that users can see more clearly the focus of the business object corresponding to the map representation, and how to customize the label layer display content, font size and so on. So today's main topic is customization: custom theme, custom label, and label Font.
First of all, we have to fill the map with different colors, so that they look colorful, easy to distinguish. For example, rivers and lakes to fill the blue, grass to fill the green, the house to fill the white, the road to fill the cyan and so on. How do you do it? Very simple, first look at the code:
SharpMap.Rendering.Thematics.CustomTheme itheme = new
SharpMap.Rendering.Thematics.CustomTheme (Getmystyle);
When you initialize the map, add the preceding line of code. It defines a custom theme object whose constructor needs to pass in a method (delegate) that we write ourselves, which specifically describes how the theme is defined, and the method code is as follows:
private static SharpMap.Styles.VectorStyle Getmystyle (SharpMap.Data.FeatureDataRow
Row)
{
SharpMap.Styles.VectorStyle style = new
SharpMap.Styles.VectorStyle ();
Switch (row["Status"). ToString (). ToLower ())
{case
"available"://if status are interred, fill it with
yellow
Style. Fill = Brushes.yellow;
return style;
Default:
style. Fill = Brushes.green;
return style;
}
}