User Tools

Site Tools


map_suite_style_guide

Map Suite Style Guide

Note: The page was created before Map Suite 10. Map Suite 10.0 organized many classes into new namespaces and assemblies as well as had a few minor breaks in compatibility. The majority of previously built code should work without modification assuming the new namespaces are added. For guidance on upgrading your existing code, please check out MapSuite 10 Upgrade Guide.

This guide is a work in progress. If you have suggestion or comment please use the discussion tab on this page.

Overview

What are Styles?

Styles are classes which determine how each feature is represented on the map. Styles can be as simple as drawing a think black line to represent a street to advanced heat styles that represent multiple data points as smooth color gradients. Different styles can be applied to the same data based on the particular map scale. You can in addition, with many styles, use the tabular data associated with the feature to vary their look or even suppress drawing. At their heart styles are where your data and drawing to the map control meet.

Map Suite provides a comprehensive set of styles which will cover most mapping requirements. If you find the provided styles do not cover your scenarios then it is easy to create your own custom styles. We have dedicated an entire section to creating your own customer styles below which includes a video and samples. Using custom styles allow you to leverage your own creativity and knowledge of your specific scenarios.

Examples of styles include..

  • AreaStyle - Designed to render areas such as polygons, ellipses and rectangles.
  • LineStyle - Renders lines and multilines.
  • PointStyle - Draws points on the map using various symbols.
  • TextStyle - Labels features on the map.
  • ClassBreakStyle - Used to render feature groups differently based on their data values, ie. 0-100 Red, 100-200 Blue.
  • ValueStyle - Renders features differntly based on absolute values in their data, ie. MiddleSchool = Red, HighSchool=Blue.

Sample Area Styles
Sample Area Styles

Sample Line Styles
Sample Line Styles

Sample Point Styles
Sample Point Styles

The above images depicts a number of different styles created by Map Suite.

The Drawing Process

Simplified Process

The image below depicts a simplified view of how a style works. Data, intended to be drawn, is passed from the layer to the style along with a GeoCanvas. Internally the style calls methods on the GeoCanvas, passing in in pens, brushes and fonts along with the features, to draw the data. Styles can also access tabular data in the feature to make decisions on which pen, colors or other symbols to use based on that data.

Sample Area Styles
Sample Area Styles

Actual Process

A more complete picture of the drawing process would be…

  1. Spatial Query - The Layer does a spatial query to retrieve any features inside of the current extent of the map.
  2. ZoomLevel - We determine, through the ZoomLevelSet, which zoom level we will pull styles from based on the maps current scale.
  3. Check Custom Styles - We examine the appropriated ZoomLevel determine if there are sytles in the CustomStyle collection. If so we draw these.
  4. Default Styles - If we do not find custom sytles then we examine the default styles to see if they have been changed by the user. If the user has not modofed them then we do not use them to draw as their default state is to draw transparently.
  5. Invoke The Draw - The layer takes the features it queried along with the GeoCanvas, used to draw on the map, and passes them to each of the styles that were valid.
  6. Style Internals - Inside of the Style we typically loop through each feature passed in and if it is of a type we expect, area type for area style, we call drawing methods such as DrawArea on the GeoCanvas passing in the pens, brushes, images, or fonts that is used by the style.
  7. GeoCanvas - The GeoCanvas then receives the method calls and then draws, using native methods, onto the device the GeoCavnas was designed to draw upon. For example the GdiPlusGeoCanvas will draw on a bitmap which the PdfGeoCanvas call native methods to render to a PDF.

Zoom Levels

ZoomLevels
ZoomLevels

In general styles are applied to a particular ZoomLevel. A ZoomLevel is a particular range, in scale, where you want to style things differently. Zoom levels are part of a ZoomLevelSet which is a collection of non overlapping zoom levels.

An analogy would be to think of yourself in space looking down at the earth. At this level your scale might be 1 million. This height, or view, would be represented as a particular ZoomLevel in a ZoomLevelSet ranging from 1, ground level, to 1 million. As you descend towards the earth your scale changes and you would pass through other ZoomLevels on your way down. One thing to note is that as you descend your view of the earth changes and things that were too small to see now come into focus and things that were visible higher are now lost. In the same way your view you change we allow you to set different styles at different ZoomLevels so that you can adjust how things look depending on your current scale. For some layer, like surface streets, you would not even have a style to represent them at scale 1 million. This would cause them not to draw at all but conversely, at this scale, you may draw the capitols of the world as small dots to represent them. As you zoom into the earth those dots may be replaced by polygons that show the borders of the city etc. At a certain scale you would want to show the surface streets but possibly just as small thin black lines. As you zoom further still the thin lines would change to thicker black lines with a which inner line.

Default Styles

The first, and most common, way is to modify property on what we call 'default styles'. Default styles refer to the styles that are pre

Custom Styles

Applying Styles Across ZoomLevels

It is often the case you need to apply a single set of styles across a number of differnt ZoomLevels. You may want, for example, surface streets to be drawn as a thin black line from ZoomLevel01 through ZoomLevel05. It would be tedious to set the styles for each ZoomLevel between one through five. To simplify this requirement we allow you to apply styles across ZoomLevels using the ApplyUntilZoomLevel API on the ZoomLevel itself. Let's say you want a particular Style to be visible at ZoomLevel01 through ZoomLevel05. To make that work, we can simply code as follows:

The code below applies all the styles in ZoomLevel01 to every ZoomLevel until ZoomLevel05. In this way you can apply the same styles across a large range of ZoomLevels and save coding each ZoomLevel. Remember to apply the ZoomLevels from smallest, 01, to the largest, 20.

roadsLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Road1;
roadsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;

PresetZoomLevels

PresetZoomLevels
PresetZoomLevels

Styles define the way we visually represent the data, while ZoomLevels define the situation in which we want to display them. The reason why we need ZoomLevels is because we may want to display a small town when we are zoomed into a state, but we definitely don't want to display that town when we are zoomed out and looking at the entire country.

We have provided the 20 most common scales, from ZoomLevel01 to ZoomLevel20, at which you may want to change the way your data looks. What is scale? Scale indicates how much the given area has been reduced. If a road is 10,000 inches long in the real world and a map depicts this length as 1 inch on the screen, then we say the scale of this map is 1:10,000. Now let's say ZoomLevel02 uses a scale of 1:500 and ZoomLevel03 uses a scale of 1:1200. This means the map with a current scale of 1:1000 matches ZoomLevel03, the ZoomLevel whose scale is the closest to that.

Default Scales (Truncated)

Scales for ZoomLevels 1-7 Scales for ZoomLevels 8-14 Scales for ZoomLevels 15-20
1. 590,591,790 8. 4,613,998 15. 36,046
2. 295,295,895 9. 2,306,999 16. 18,023
3. 147,647,947 10. 1,153,499 17. 9,011
4. 73,823,973 11. 576,749 18. 4,505
5. 36,911,986 12. 288,374 19. 2,252
6. 18,455,993 13. 144,187 20. 1,126
7. 9,227,996 14. 72,093

Disabling Snapping

In the Winforms Desktop Edition, not available in other editions, you have the option to disable snapping and allow the map to zoom to an unlimited number of scales. It is recommended that you do not use this feature as it impact a number of performance optimization we can provide. For example if disable snapping then your tile caching will not work effectively and may result in a large number of tiles being generated. If you want more granulatiry then we suggest you create a set of custom ZoomLevels, detailed later in this guide, as this allows you to define a more granular set of scales.

The code below disables snapping to ZoomLevels in the Winforms Desktop Edition. This method will not work for any other edition due to their design.

winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.None

Custom ZoomLevels

While we have provided a predefined set of the most common scales there are times where you need to specify your own custom scales. There are two ways to specify your own scales for ZoomLevels depending on your intention.

Modifying Existing ZoomLevels

If you plan to make slight modifications to the existing scales but plan on having less then twenty ZoomLevels total then we suggest you simply modify the ZoomLevelSet. Using this method you change the Scale property on the ZoomLevels you want to adjust. If you want fewer then twenty scales then simply set the unused scales to zero. It is important to note that when you change the scales and set the new ZoomLevelSet to the associated FeatureLayers that you also ensure that map control snaps to the new ZoomLevel set. The process of doing this is described below under Third Party ZoomLevelSets (Google, Bing etc.).

The code below creates a ZoomLevelSet with effectivly three ZoomLevels. By setting the rest of the scales to zero we effectivly turn them off. We have left off the code to turn ZoomLevel 08-20 off to save space

   // Change the scales on an existing ZoomLevelSet
   shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.Scale = 1000000;
   shapefileFeatureLayer.ZoomLevelSet.ZoomLevel02.Scale = 500000;
   shapefileFeatureLayer.ZoomLevelSet.ZoomLevel03.Scale = 250000;
   shapefileFeatureLayer.ZoomLevelSet.ZoomLevel05.Scale = 0;
   shapefileFeatureLayer.ZoomLevelSet.ZoomLevel06.Scale = 0;
   shapefileFeatureLayer.ZoomLevelSet.ZoomLevel07.Scale = 0;
   // Set the rest of the 20 ZoomLevels to zero as well if they are not needed

Creating New ZoomLevels

Creating new ZoomLevels allows you to create a near infinite number of ZoomLevels to have total control. In this method you create the number of ZoomLevels you want and you add these to the ZoomLevelSet.CustomZoomLevels collection. During the drawing process if we detect that you have populated the collection we will ignore the predefined ZoomLevels and use the items in the collection instead. It is important to note that when you use custom zoom levels that you ensure that map control snaps to the new ZoomLevel set. The process of doing this is described below under Third Party ZoomLevelSets (Google, Bing etc.).

The code below create three new ZoomLevels and adds them to the CustomZoomLevelSet. Normally you would use this technique to create more than twenty ZoomLevels for greater granularity. If, in the real world, we just wanted three ZoomLevels we would use the code above and simple modify the default ZoomLevelSet.

   // Create the ZoomLevels
   ZoomLevel zoomLevel1 = new ZoomLevel(100000);
   ZoomLevel zoomLevel2 = new ZoomLevel(50000);
   ZoomLevel zoomLevel3 = new ZoomLevel(25000);
 
   // Create a new ZoomLevelSet
   ZoomLevelSet zoomLevelSet = new ZoomLevelSet();
 
   // Add the ZoomLevels to the ZoomLevelSet
   zoomLevelSet.CustomZoomLevels.Add(zoomLevel1);
   zoomLevelSet.CustomZoomLevels.Add(zoomLevel2);
   zoomLevelSet.CustomZoomLevels.Add(zoomLevel3);
 
   // Apply the new ZoomLevelSet to your FeatureLayer
   shapefileFeatureLayer.ZoomLevelSet = zoomLevelSet;

Third Party ZoomLevelSets (Google, Bing etc.)

If you are using base maps images such as Bing Maps or Google Maps it is important that you choose the correct ZoomLevelSet for rendering and map snapping. Background map providers typically tile their data at set scales. This means that you want the map to snap to those scales to avoid distorting their images and to ensure your styles render relative to those ZoomLevels. We have provided below a number of ZoomLevelSets specific to the most popular data background map providers.

There are usually two steps in setting up your ZoomLevelsSets. The first step is to ensure that every FeatureLayer that you use has the ZoomLevelSet that correspecnds to your background data. This will ensure that all of your styles break at the same scales as the background maps. The code below shows you an example of this. This step is universal across all of the Map Suite products as FeatureLayer is shared in the MapSuiteCore assembly. The snapping of the map control itself varies between Map Suite products so it is important to review the section below appropriate to the product you are using.

Popular ZoomLevelSets

Winforms Desktop Edition

   //Snap the map to the Bing Maps ZoomLevels
   //Place this code where you setup your map control
   winformsMap1.ZoomLevelSet = new BingMapsZoomLevelSet();
 
   //Use the scales for Bing Maps in FeatureLayer
   //Place this code where you setup each layer
   shapefileFeatureLayer.ZoomLevelSet = new BingMapsZoomLevelSet();

WPF Desktop Edition

   //Snap the map to the Bing Maps ZoomLevels
   //Place this code where you setup your map control
   WpfMap.SyncZoomLevels(new BingMapsZoomLevelSet());
 
   //Use the scales for Bing Maps in FeatureLayer
   //Place this code where you setup each layer
   shapefileFeatureLayer.ZoomLevelSet = new BingMapsZoomLevelSet();

Web Edition

   //Use the scales for Bing Maps in FeatureLayer
   //Place this code where you setup each layer
   shapefileFeatureLayer.ZoomLevelSet = new BingMapsZoomLevelSet();

Silverlight Edition

   //Snap the map to the Bing Maps ZoomLevels
   //Place this code where you setup your map control
   Map.SyncClientZoomLevels(new BingMapsZoomLevelSet());
 
   //Use the scales for Bing Maps in FeatureLayer
   //Place this code where you setup each layer
   shapefileFeatureLayer.ZoomLevelSet = new BingMapsZoomLevelSet();

Pens, Brushes & Fonts

Styles use pens, brushes and fonts to draw your data on the canvas. These tools can be used in various combinations to achieve interesting effects such as a LineStyle using two pens to portray a realistic road or a AreaStyle using a pen and a brush to show a blue river with a thing black outline for the bank. Each style may use different combinations of these tools so it is important to review the properties and constructors of each different style you choose to use. Be aware that many times pens or brushes may be optional or may have properties that control the order in which multiple tools draw.

We modeled the many of these classes to be closely follow the API design of the GDI+ in the System.Drawing namespace. We created our own classes, by adding the 'geo' prefix, for three main reasons. The first was so that our API was portable to environment where GDI+ was not available such as Silverlight, WP7, PDF rendering etc. The second was that the GDI+ objects themselves held unmanaged resources so creating many of them was unmanageable and they were not easily serializable. The third is that we felt that many developers would be familiar with concepts of pens, brushes, etc. If you are familiar with the GDI+ classes then you should feel at home with our drawing classes below.

GeoPen

Sample Pens
Sample Pens

The GeoPen class is used to draw lines of various thicknesses, colors, brush types, dash styles, and line caps. A simple pen may consist of simply a black color line with thickness of one. A complex symbol, for a railroad as an example, may use parallel offset lines with

Properties

Brush

This property gets and sets the brush for this GeoPen.

Remarks

None

Return Value

Color

This property gets and sets the GeoColor for this GeoPen.

Remarks

N/A

Return Value

DashCap

This property gets and sets the dash cap for this GeoPen.

Remarks

None

Return Value

DashPattern

This property gets the dash pattern for this GeoPen.

Remarks

Assigning a value other than null (Nothing in Visual Basic) to this property will set the DashStyle property for this GeoPen to Custom. The elements in the dashArray array set the length of each dash and space in the dash pattern. The first element sets the length of a dash, the second element sets the length of a space, the third element sets the length of a dash, and so on. The length of each dash and space in the dash pattern is the product of the element value in the array and the width of the GeoPen.

Return Value
  • Type:Collection<Single>

DashStyle

This property gets and sets the dash style for this GeoPen.

Remarks

None

Return Value

EndCap

This property gets and sets the end cap for this GeoPen.

Remarks

None

Return Value

LineJoin

This property gets and sets the line join for this GeoPen.

Remarks

None

Return Value

MiterLimit

This property gets and sets the miter limit for this GeoPen.

Remarks

None

Return Value
  • Type:Single

StartCap

This property gets and sets the start cap for this GeoPen.

Remarks

None

Return Value

Width

This property gets and sets the width for this GeoPen.

Remarks

None

Return Value
  • Type:Single

Id

The id of the GeoBrush. This is always used as a key when in the cached brushes.

Remarks

N/A

Return Value
  • Type:Int64

GeoBrush

GeoBrushes are typically to fill areas of polygons, ellipses, or rectangle however they can also be used to fill in thick lines on GeoPens. The GeoBrush class itself is abstract and as such cannot be used directly. The GeoBrush is used as a base class to create a family of various brushed that use different ways to fill an area. In most Map Suite APIs we use the abstract class for properties meaning that you can freely use any of the derived brushes.

GeoSolidBrush

Sample Solid Brushes

The GeoSolidBrush is the easiest to use as it only takes a GeoColor for the fill. As simple as it is the GeoSolidBrush is the most widely used brushes since most items drawn to the screen only require a simple color.

Properties

Color

This property gets or sets the color of the GeoSolidBrush.

Remarks

None

Return Value

Id

N/A

Remarks

N/A

Return Value
  • Type:Int64

GeoHatchBrush

Sample Hatch Brushes

The GeoHatchBrush allows you you to specify that area be filled with a pattern. The patterns are use colors from the background and foreground color properties.

Some example patterns are below.

Properties

HatchStyle

This property gets and sets the pattern you want to use for the fill.

Remarks

None

Return Value

ForegroundColor

This property gets and sets the foreground color for the fill pattern.

Remarks

In this case the background color will be transparent.

Return Value

BackgroundColor

This property gets and sets the background color for the fill pattern.

Remarks

In this case the foreground color will be transparent.

Return Value

Id

N/A

Remarks

N/A

Return Value
  • Type:Int64

GeoTextureBrush

Sample Texture Brushes

The GeoTextureBrush allows you to fill an are with an texture image. You can use this to represent natural effect such as water, sand, forest etc. It is also useful for high impact polygons fills such an area that is currently dangerous having a semitransparent warning tile. It is important to note that there are a number of ways the image tiles can be wrapped or flipped and you can find the details in GeoWrapMode property.

Properties

GeoImage

This property gets and sets the GeoImage used for the texture fill.

Remarks

None

Return Value

DrawingRectangleF

This property gets and sets the screen rectangle used to fill the texture.

Remarks

None

Return Value

GeoWrapMode

This property gets and sets the wrap mode that is used to determine how an area is filled if the area is larger than the texture.

Remarks

This property gets and sets the wrap mode that is used to determine how an area is filled if the area is larger than the texture.

Return Value

Id

N/A

Remarks

N/A

Return Value
  • Type:Int64

GeoLinearGradientBrush

Sample Linear Gradient Brushes

The GeoLinearGradientBrush allows you to fill in area going from one color to another color. You specify the angle and wrap mode as well to control precisely how it draws.

Properties

StartColor

Gets or sets the starting GeoColor of the gradient.

Remarks

N/A

Return Value

EndColor

Gets or sets the ending GeoColor of the gradient.

Remarks

N/A

Return Value

DirectionAngle

Gets or sets the Direction angle of the GeoLinearGradientBrush.

Remarks

N/A

Return Value
  • Type:Single

WrapMode

Gets or sets a GeoWrapMode enumeration that indicates the wrap mode for the GeoLinearGradientBrush.

Remarks

N/A

Return Value

Id

N/A

Remarks

N/A

Return Value
  • Type:Int64

GeoFont

Sample GeoFonts

GeoFonts are primary used for labeling int he TextStyle. GeoFonts can also be used with the PointStyle to represent points as font members at various sizes, colors, and styles.

Properties

IsBold

This property gets the bold property of the font.

Remarks

None

Return Value
  • Type:Boolean

IsStrikeout

This property gets the strikeout property of the font.

Remarks

None

Return Value
  • Type:Boolean

IsItalic

This property gets the italic property of the font.

Remarks

None

Return Value
  • Type:Boolean

IsUnderline

This property gets the underline property of the font.

Remarks

None

Return Value
  • Type:Boolean

FontName

This property gets the font name property of the font.

Remarks

None

Return Value
  • Type:String

Size

This property gets the font size property of the font.

Remarks

None

Return Value
  • Type:Single

Style

This property gets the font style property of the font.

Remarks

None

Return Value

Id

N/A

Remarks

N/A

Return Value
  • Type:Int64

Predefined Styles

Simple Styles

AreaStyle

LineStyle

TextStyle

Conditional Styles

ClassBreakStyle

ValueStyle

RegexStyle

Advanced Styles

ClusterPointStyle

DotDensityStyle

GradientStyle

HeatStyle

HueFamilyAreaStyle

QualityFamilyAreaStyle

IconStyle

IconValueStyle

Using Tabular Data

Concatenating Columns

Custom External Data

Creating Custom Styles

Why Create a Custom Style?

Anatomy of a Abstract Style Class

Each style in Map Suite inherits from the Style abstract base class. The base class define a simple set of functionality that is typically required by a style and beyond that it is a requirement of the subclass to provide additional functionality.

Name

The name property is reserved for your use and is not used by the system. You could use it, as an example, to store the style's name if you wanted to build a legend.

IsActive

This property determines if the style will be used. If you set the style IsActive to false then it will not draw any records. We suggest that if you want to control the drawing of a particular layer then you use the Layer.IsActive and not the Style.IsActive as using the Layer.IsActive is more efficient and uses less resource in the scenario you want to stop a layer from drawing.

Draw

This method is the concrete wrapper for the abstract method DrawCore. As the wrapper it will call the DrawCore method and do any other tasks such as raise events etc.

DrawCore

In this method, we take the shapes that are passed in and draw them on the provided canvas. Each style, based on its properties, may draw each shape differently.

RequiredColumnNames

GetRequiredColumnNames

This method is the concrete wrapper for the abstract method GetRequiredColumnNamesCore . As the wrapper it will call the GetRequiredColumnNamesCore method and do any other tasks such as raise events etc.

GetRequiredColumnNamesCore

DrawSample

DrawSampleCore

Sample

Additional Resources

Video

I need to consider how to transclude this item from one of the main pages.

Topic

Attachment Description
Creating Custom Styles Video

Presentation

Q&A

Sample
This informative, in-depth webinar explores the limitless possibilities for creating your own custom styles with Map Suite. Take a look at the video presentation and download the sample project with source code in both C# and VB.NET.
map_suite_style_guide.txt · Last modified: 2017/03/17 02:08 by tgwikiupdate