Show / Hide Table of Contents

    Class ScaleBarWidget

    A ScaleBarWidget displays the ratio of a distance on the map to the corresponding distance on the ground. It uses always the center of a given Viewport to calc this ratio.

    Usage To show a ScaleBarWidget, add a instance of the ScaleBarWidget to Map.Widgets by

    map.Widgets.Add(new ScaleBarWidget(map));

    Customize ScaleBarMode: Determins, how much scalebars are shown. Could be Single or Both. SecondaryUnitConverter: First UnitConverter for upper scalebar. There are UnitConverters for metric, imperial and nautical units. SecondaryUnitConverter = NauticalUnitConverter.Instance }); MaxWidth: Maximal width of the scalebar. Real width could be smaller. HorizontalAlignment: Where the ScaleBarWidget is shown. Could be Left, Right, Center or Position. VerticalAlignment: Where the ScaleBarWidget is shown. Could be Top, Bottom, Center or Position. PositionX: If HorizontalAlignment is Position, this value determins the distance to the left PositionY: If VerticalAlignment is Position, this value determins the distance to the top TextColor: Color for text and lines Halo: Color used around text and lines, so the scalebar is better visible TextAlignment: Alignment of scalebar text to the lines. Could be Left, Right or Center TextMargin: Space between text and lines of scalebar Font: Font which is used to draw text TickLength: Length of the ticks at scalebar

    Inheritance
    System.Object
    Widget
    ScaleBarWidget
    Implements
    IWidget
    System.ComponentModel.INotifyPropertyChanged
    Inherited Members
    Widget.HorizontalAlignment
    Widget.VerticalAlignment
    Widget.MarginX
    Widget.MarginY
    Widget.Envelope
    Widget.Enabled
    Widget.CalculatePositionX(Single, Single, Single)
    Widget.CalculatePositionY(Single, Single, Single)
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Mapsui.Widgets.ScaleBar
    Assembly: Mapsui.dll
    Syntax
    public class ScaleBarWidget : Widget, IWidget, INotifyPropertyChanged

    Constructors

    | Improve this Doc View Source

    ScaleBarWidget(Map)

    Declaration
    public ScaleBarWidget(Map map)
    Parameters
    Type Name Description
    Map map

    Properties

    | Improve this Doc View Source

    Font

    Font to use for drawing text

    Declaration
    public Font Font { get; set; }
    Property Value
    Type Description
    Font
    | Improve this Doc View Source

    Halo

    Halo color of scalebar and text, so that it is better visible

    Declaration
    public Color Halo { get; set; }
    Property Value
    Type Description
    Color
    | Improve this Doc View Source

    Height

    Real height of scalebar. Depends on number of unit converters and text size. Is calculated by renderer.

    Declaration
    public float Height { get; set; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    MaxWidth

    Maximum usable width for scalebar. The real used width could be less, because we want only integers as text.

    Declaration
    public float MaxWidth { get; set; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    Scale

    Declaration
    public float Scale { get; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    ScaleBarMode

    ScaleBarMode of scalebar. Could be Single to show only one or Both for showing two units.

    Declaration
    public ScaleBarMode ScaleBarMode { get; set; }
    Property Value
    Type Description
    ScaleBarMode
    | Improve this Doc View Source

    SecondaryUnitConverter

    Secondary unit converter for lower text if ScaleBarMode is Both. Default is ImperialUnitConverter.

    Declaration
    public IUnitConverter SecondaryUnitConverter { get; set; }
    Property Value
    Type Description
    IUnitConverter
    | Improve this Doc View Source

    ShowEnvelop

    Draw a rectangle around the scale bar for testing

    Declaration
    public bool ShowEnvelop { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    StrokeWidth

    Stroke width for lines

    Declaration
    public float StrokeWidth { get; set; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    StrokeWidthHalo

    Stroke width for halo of lines

    Declaration
    public float StrokeWidthHalo { get; set; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    TextAlignment

    Alignment of text of scalebar

    Declaration
    public Alignment TextAlignment { get; set; }
    Property Value
    Type Description
    Alignment
    | Improve this Doc View Source

    TextColor

    Foreground color of scalebar and text

    Declaration
    public Color TextColor { get; set; }
    Property Value
    Type Description
    Color
    | Improve this Doc View Source

    TextMargin

    Margin between end of tick and text

    Declaration
    public float TextMargin { get; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    TickLength

    Length of the ticks

    Declaration
    public float TickLength { get; set; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    UnitConverter

    Normal unit converter for upper text. Default is MetricUnitConverter.

    Declaration
    public IUnitConverter UnitConverter { get; set; }
    Property Value
    Type Description
    IUnitConverter

    Methods

    | Improve this Doc View Source

    CanTransform()

    Declaration
    public bool CanTransform()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetScaleBarLengthAndText(IReadOnlyViewport)

    Calculates the length and text for both scalebars

    Declaration
    public (float scaleBarLength1, string scaleBarText1, float scaleBarLength2, string scaleBarText2) GetScaleBarLengthAndText(IReadOnlyViewport viewport)
    Parameters
    Type Name Description
    IReadOnlyViewport viewport
    Returns
    Type Description
    System.ValueTuple<System.Single, System.String, System.Single, System.String>

    Length of upper scalebar Text of upper scalebar Length of lower scalebar Text of lower scalebar

    | Improve this Doc View Source

    GetScaleBarLinePositions(IReadOnlyViewport, Single, Single, Single)

    Get pairs of points, which determin start and stop of the lines used to draw the scalebar

    Declaration
    public Point[] GetScaleBarLinePositions(IReadOnlyViewport viewport, float scaleBarLength1, float scaleBarLength2, float stroke)
    Parameters
    Type Name Description
    IReadOnlyViewport viewport

    The viewport of the map

    System.Single scaleBarLength1

    Length of upper scalebar

    System.Single scaleBarLength2

    Length of lower scalebar

    System.Single stroke

    Width of line

    Returns
    Type Description
    Point[]

    Array with pairs of Points. First is always the start point, the second is the end point.

    | Improve this Doc View Source

    GetScaleBarTextPositions(IReadOnlyViewport, BoundingBox, BoundingBox, BoundingBox, Single)

    Calculates the top-left-position of upper and lower text

    Declaration
    public (float posX1, float posY1, float posX2, float posY2) GetScaleBarTextPositions(IReadOnlyViewport viewport, BoundingBox textSize, BoundingBox textSize1, BoundingBox textSize2, float stroke)
    Parameters
    Type Name Description
    IReadOnlyViewport viewport

    The viewport

    BoundingBox textSize

    Default textsize for the string "9999 m"

    BoundingBox textSize1

    Size of upper text of scalebar

    BoundingBox textSize2

    Size of lower text of scalebar

    System.Single stroke

    Width of line

    Returns
    Type Description
    System.ValueTuple<System.Single, System.Single, System.Single, System.Single>

    posX1 as left position of upper scalebar text posY1 as top position of upper scalebar text posX2 as left position of lower scalebar text posY2 as top position of lower scalebar text

    | Improve this Doc View Source

    HandleWidgetTouched(INavigator, Point)

    Declaration
    public override bool HandleWidgetTouched(INavigator navigator, Point position)
    Parameters
    Type Name Description
    INavigator navigator
    Point position
    Returns
    Type Description
    System.Boolean
    Overrides
    Widget.HandleWidgetTouched(INavigator, Point)

    Events

    | Improve this Doc View Source

    PropertyChanged

    Declaration
    public event PropertyChangedEventHandler PropertyChanged
    Event Type
    Type Description
    System.ComponentModel.PropertyChangedEventHandler

    Implements

    IWidget
    System.ComponentModel.INotifyPropertyChanged
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX