.netCHARTING v6.0 Documentation Send comments on this topic.
Map Styling
Getting Started > General Tutorials > Mapping > Map Styling

Glossary Item Box

Shapes Styling

The Shape object exposes a Background, Line, ElementMarker, and Label object which determines the shape's appearance. These objects can be manipulated individually for each shape or they can be set simultaneously for all objects through defaults.

The Chart.Mapping object as well as the MapLayer object contain a DefaultShape property which works the same as a normal DefaultSeries or DefaultElement in a regular chart.

See sample Mapping/ShapeStyling.aspx

Thematic Mapping

Thematic mapping is a feature by which a color is applied to shapes conditionally. This feature uses the SmartColor object. The following sample demonstrates using a smart colors to shade US states based on population ranges.

[C#]

Chart.SmartPalette = SmartPalette sp = new SmartPalette();
Color[] cols = new Color[]{Color.FromArgb(2,255,0),Color.FromArgb(186,253,0)};
sp.Add("POPULATION",new SmartColor(cols[0], new ScaleRange(100000,1000000)));
sp.Add("POPULATION",new SmartColor(cols[1], new ScaleRange(1000000,10000000)));
[Visual Basic]

Dim sp As New SmartPalette()
Chart.SmartPalette = sp
Dim cols() As Color = {Color.FromArgb(2, 255, 0), Color.FromArgb(186, 253, 0)}
sp.Add("POPULATION", New SmartColor(cols(0), New ScaleRange(100000, 1000000)))
sp.Add("POPULATION", New SmartColor(cols(1), New ScaleRange(1000000, 10000000)))
For more information on smart colors see this tutorial.

Labels

Similar to labels on normal chart elements, shape labels can contain tokens which represent the data attributes they contain. For instance, the shapes from the above example contain an attribute named 'State_Abbr' which represents the state's abbreviation. If the shape label text contains '%State_Abbr' the resulting label on the map will show the value of this attribute, depending on which state the label could be something like "IL", or "CA". This code snippet sets this label text for all the states within myLayer.

[C#]

myLayer.DefaultShape.Label.Text = "%State_Abbr";
[Visual Basic]

myLayer.DefaultShape.Label.Text = "%State_Abbr"

 

Additional data imported from other databases (See: Mapping Data and Layers) can also be represented in these labels.

See sample Mapping/ImportShapefileData.aspx

LabelOnce Option [New in v5.0]

In cases where a single shape has multiple polygon parts representing islands for example, the control tends to place the shape's label on each polygon of the shape. Using this option will ensure only one label is used for the collection of polygons belonging to the shape.

 

[C#]

mapLayer.LabelOnce = true;
[Visual Basic]

mapLayer.LabelOnce = True

 

Sample: MapLabelOnce.aspx

Shape Groups

Shape files often contain a large number of shapes which may be difficult to differentiate between and label. The Group object solves this by conditionally encapsulating a number of shapes. This allows settings to simultaneously be applied to all shapes within that group. A DefaultShape property is provided by this Group object to facilitate this feature.

The conditions that determine whether a shape belongs to a group are based on the data attributes of those shapes. For example a condition may be that only shapes with a 'population' attribute greater than 50,000 are included. The following code snippet demonstrates this example.

[C#]

MapLayer layer = MapDataEngine.LoadLayer( @"mapFiles/canada.shp");
dotnetCHARTING.Mapping.Group gr = new dotnetCHARTING.Mapping.Group("CNTRY_NAME", "Canada");
gr.DefaultShape.Background.Color = Color.Green;
layer.Groups.Add(gr);
Chart.Mapping.MapLayerCollection.Add(layer);
[Visual Basic]

Dim layer As MapLayer = MapDataEngine.LoadLayer("mapFiles/canada.shp")
Dim gr As New dotnetCHARTING.Mapping.Group("CNTRY_NAME", "Canada")
gr.DefaultShape.Background.Color = Color.Green
layer.Groups.Add(gr)
Chart.Mapping.MapLayerCollection.Add(layer)

 

See sample Mapping/ShapeGrouping.aspx

Group Labels

While the styling properties of the default shape are inherited by all the shapes within the group. The  Group.Label property is drawn only once on top of the entire group. Tokens are not allowed in this label's text.

[C#]

MapLayer layer = MapDataEngine.LoadLayer( @"mapFiles/canada.shp");
dotnetCHARTING.Mapping.Group gr = new dotnetCHARTING.Mapping.Group("CNTRY_NAME", "Canada");
gr.Label = new dotnetCHARTING.Label("Canada",new Font("Arial",25,FontStyle.Bold),Color.FromArgb(200,20,20),Color.White);
layer.Groups.Add(gr);
Chart.Mapping.MapLayerCollection.Add(layer);
[Visual Basic]

Dim layer As MapLayer = MapDataEngine.LoadLayer("mapFiles/canada.shp")
Dim gr As New dotnetCHARTING.Mapping.Group("CNTRY_NAME", "Canada")
gr.Label = New dotnetCHARTING.Label("Canada", New Font("Arial", 25, FontStyle.Bold), Color.FromArgb(200, 20, 20), Color.White)
layer.Groups.Add(gr)
Chart.Mapping.MapLayerCollection.Add(layer)

 

See sample Mapping/ShapeGrouping.aspx
©2010. All Rights Reserved.