Class ScaleBarAdornmentLayer
The ScaleBarAdornmentLayer class allows you show a bar graphic on the map that displays the distance scale for the current map extent.
public class ScaleBarAdornmentLayer : AdornmentLayer
- Inheritance
-
ScaleBarAdornmentLayer
- Inherited Members
Examples
ScaleBarAdornmentLayer scaleLineAdornmentLayer = new ScaleBarAdornmentLayer();
mapEngine.AdornmentLayers.Add("ScaleLineAdornmentLayer", scaleLineAdornmentLayer);
Dim scaleLineAdornmentLayer As New ScaleBarAdornmentLayer()
mapEngine.AdornmentLayers.Add("ScaleLineAdornmentLayer", scaleLineAdornmentLayer)
Remarks
Use the ScaleBarAdornmentLayer class as a quick way to implement a ScaleBar. When using the ScaleBarAdornmentLayer, you also need to add a ScaleLineAdornmentLayer to the map control. One thing we should pay attention to is that the ScaleBar will not be drawn when the CurrentExtent is outside of Range(-90,180,90,-180).
Constructors
ScaleBarAdornmentLayer()
Creates a new instance of the ScaleBarAdornmentLayer class.
public ScaleBarAdornmentLayer()
Remarks
When displaying a ScaleBarAdornmentLayer, we need to instance a ScaleLineAdornmentLayer and add it to MapEngine. The ScaleBar will not be drawn when the CurrentExtent is outside of the world Extent(-90,180-,90,-180).
Properties
AlternateBarBrush
The property is the GeoBrush that will be used to draw the alternate ScaleBar.
public GeoBrush AlternateBarBrush { get; set; }
Property Value
Remarks
This AlternateBarBrush property will give you full control over the appearance of the ScaleBarAdornmentLayer.
BarBrush
The property is the GeoBrush that will be used to draw the ScaleBar.
public GeoBrush BarBrush { get; set; }
Property Value
Remarks
This BarBrush property will give you full control over the appearance of the ScaleBarAdornmentLayer.
BarPen
public GeoPen BarPen { get; set; }
Property Value
DisplayUnitString
This propery is a dictionary that exposes what text will be drawn to represent the ScaleLine Unit.
public Dictionary<string, string> DisplayUnitString { get; }
Property Value
Remarks
We will display different letters for different units of measure; for example: "m" for meters, "ft" for feet, etc.
HasMask
Gets or sets whether the ScaleBar will have a mask or not. A boolean value representing whether or not a mask is shown.
public bool HasMask { get; set; }
Property Value
Remarks
Depending upon the look of your map and your requirements, you may or may not want a mask on the ScaleBar. You can control whether or not the ScaleBar has a mask by setting this property. If you set the HasMask property to true, be sure to specify a mask color (or texture) by using the MaskBrush property.
MaskBrush
Gets or sets the color for the ScaleBarAdornmentLayer's mask, if the HasMask property is set to true.
public GeoBrush MaskBrush { get; set; }
Property Value
MaskContour
Gets or sets the pen for the outline of the ScaleBar mask.
public GeoPen MaskContour { get; set; }
Property Value
Remarks
By using this property you can control the border of the mask, if the HasMask property is set to true. If you do not want a contour or border to show, you should set the pen to transparent.
MaxWidth
Gets or Sets the MaxWidth of the ScaleBar.
public int MaxWidth { get; set; }
Property Value
Remarks
You can use this property to set the maximum width that you want the ScaleBar to occupy on the map. The ScaleBarAdornmentLayer will automatically adjust its size based upon the current extent of the map. By setting this property, you can control the maximum width the ScaleBar will occupy on the map.
TextStyle
public TextStyle TextStyle { get; set; }
Property Value
Thickness
Gets or sets the thickness of the ScaleBar. It is an integer value representing the height of the ScaleBar in screen units.
public int Thickness { get; set; }
Property Value
UnitFamily
Gets or sets the UnitSystem (Imperial/Metric) to be used for the ScaleBar.
public UnitSystem UnitFamily { get; set; }
Property Value
Examples
The example below sets the ScaleBar to use the metric system of measurement.
Dim adornment As New ScaleBarAdornmentLayer()
adornment.UnitFamily = UnitSystem.Metric
ScaleBarAdornmentLayer adornment = new ScaleBarAdornmentLayer();
adornment.UnitFamily = UnitSystem.Metric;
Remarks
By setting this property, you can control whether to use a metric or imperial measurement system for the ScaleBar.
Methods
CloseCore()
protected override void CloseCore()
DrawCore(GeoCanvas, Collection<SimpleCandidate>)
This method draws the Layer.
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
Parameters
canvas
GeoCanvasThis parameter is the view object or a NativeImage to draw on.
labelsInAllLayers
Collection<SimpleCandidate>This parameter represents the labels used for collision detection and duplication checking.
Remarks
This abstract method is called from the concrete public method Draw. This
method draws the representation of the layer based on the extent you provided.
When implementing this abstract method, consider each feature and its column data
values. You can use the full power of the GeoCanvas to do the drawing. If you need
column data for a feature, be sure to override the GetRequiredColumnNamesCore and add
the columns you need to the collection. In many of the styles, we add properties to
allow the user to specify which field they need; then, in the GetRequiredColumnNamesCore,
we read that property and add it to the collection.
OpenCore()
protected override void OpenCore()