Using “ClassBreak” styling to create dynamic maps
In this project you will see how to use the ClassBreakStyle to group and render features by values. ClassBreakStyle is a useful technique as it allows you to group various features by the specified values, then applies differently style to the feature groups. One of the first steps in creating an interactive map that highlights different classes of data is creating unique iconography to translate that onto the map.
For a hands-on demo of the code please visit the ThinkGeo Github page and download the sample today. If you’d like to learn more about ThinkGeo’s Desktop development tools head over to our website and start building with your free 60-day evaluation.
About the Code
Use a ClassBreakStyle to colorize each state differently depending on the range into which its population falls. This value is found in the states ShapeFile DBF in the column named “POP1990”.
ClassBreakStyle statesStyle = new ClassBreakStyle("POP1990");
statesStyle.ClassBreaks.Add(
new ClassBreak(value: 0, areaStyle: AreaStyles.CreateSimpleAreaStyle(
fillBrushColor: GeoColors.LightGray,
outlinePenColor: GeoColors.DarkGray,
outlinePenWidth: 1)
)
);
statesStyle.ClassBreaks.Add(
new ClassBreak(value: 1000000, areaStyle: AreaStyles.CreateSimpleAreaStyle(
fillBrushColor: GeoColors.LightBlue,
outlinePenColor: GeoColors.CornflowerBlue,
outlinePenWidth: 1)
)
);
statesStyle.ClassBreaks.Add(
new ClassBreak(value: 3500000, areaStyle: AreaStyles.CreateSimpleAreaStyle(
fillBrushColor: GeoColors.SkyBlue,
outlinePenColor: GeoColors.DeepSkyBlue,
outlinePenWidth: 1)
)
);
// Add stateStyle to the statesLayer and apply the style to all zoom levels.
statesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(statesStyle);
statesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;