Show / Hide Table of Contents

    Class Viewport

    Viewport holds all informations about the visible part of the map.

    Inheritance
    System.Object
    Viewport
    Implements
    IViewport
    IReadOnlyViewport
    Inherited Members
    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
    Assembly: Mapsui.dll
    Syntax
    public class Viewport : IViewport, IReadOnlyViewport
    Remarks

    Viewport is the connection between Map and MapControl. It tells MapControl, which part of Map should be displayed on screen.

    Constructors

    | Improve this Doc View Source

    Viewport()

    Create a new viewport

    Declaration
    public Viewport()
    | Improve this Doc View Source

    Viewport(IReadOnlyViewport)

    Create a new viewport from another viewport

    Declaration
    public Viewport(IReadOnlyViewport viewport)
    Parameters
    Type Name Description
    IReadOnlyViewport viewport

    Viewport from which to copy all values

    Properties

    | Improve this Doc View Source

    Center

    Coordinate of center of viewport in map coordinates

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

    Extent

    BoundingBox of viewport in map coordinates respection Rotation

    Declaration
    public BoundingBox Extent { get; }
    Property Value
    Type Description
    BoundingBox
    Remarks

    This BoundingBox is horizontally and vertically aligned, even if the viewport is rotated. So this BoundingBox perhaps contain parts, that are not visible.

    | Improve this Doc View Source

    HasSize

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

    Height

    Height of viewport in screen pixels

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

    IsRotated

    IsRotated is true, when viewport displays map rotated

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

    Resolution

    Resolution of the viewport in units per pixel

    Declaration
    public double Resolution { get; set; }
    Property Value
    Type Description
    System.Double
    Remarks

    Resolution is Mapsuis form of zoom level. Because Mapsui is projection independent, there aren't any zoom levels as other map libraries have. If your map has EPSG:3857 as projection and you want to calculate the zoom, you should use the following equation

    var zoom = (float)Math.Log(78271.51696401953125 / resolution, 2);

    | Improve this Doc View Source

    Rotation

    Viewport rotation from True North (clockwise degrees)

    Declaration
    public double Rotation { get; set; }
    Property Value
    Type Description
    System.Double
    | Improve this Doc View Source

    Width

    Width of viewport in screen pixels

    Declaration
    public double Width { get; set; }
    Property Value
    Type Description
    System.Double
    | Improve this Doc View Source

    WindowExtent

    WindowExtend gives the four corner points of viewport in map coordinates

    Declaration
    public Quad WindowExtent { get; }
    Property Value
    Type Description
    Quad
    Remarks

    If viewport is rotated, this corner points are not horizontally or vertically aligned.

    Methods

    | Improve this Doc View Source

    ScreenToWorld(Point)

    Converts a point in screen pixels to one in map units, respecting rotation

    Declaration
    public Point ScreenToWorld(Point position)
    Parameters
    Type Name Description
    Point position

    Coordinate in map units

    Returns
    Type Description
    Point

    Point in map units

    | Improve this Doc View Source

    ScreenToWorld(Double, Double)

    Converts X/Y in screen pixels to a point in map units, respecting rotation

    Declaration
    public Point ScreenToWorld(double screenX, double screenY)
    Parameters
    Type Name Description
    System.Double screenX
    System.Double screenY
    Returns
    Type Description
    Point

    Point in map units

    | Improve this Doc View Source

    SetCenter(ReadOnlyPoint)

    Declaration
    public void SetCenter(ReadOnlyPoint center)
    Parameters
    Type Name Description
    ReadOnlyPoint center
    | Improve this Doc View Source

    SetCenter(Double, Double)

    Declaration
    public void SetCenter(double x, double y)
    Parameters
    Type Name Description
    System.Double x
    System.Double y
    | Improve this Doc View Source

    SetResolution(Double)

    Declaration
    public void SetResolution(double resolution)
    Parameters
    Type Name Description
    System.Double resolution
    | Improve this Doc View Source

    SetResolution(Double, ReadOnlyPoint)

    Declaration
    public void SetResolution(double resolution, ReadOnlyPoint centerOfZoom)
    Parameters
    Type Name Description
    System.Double resolution
    ReadOnlyPoint centerOfZoom
    | Improve this Doc View Source

    SetRotation(Double)

    Declaration
    public void SetRotation(double rotation)
    Parameters
    Type Name Description
    System.Double rotation
    | Improve this Doc View Source

    SetSize(Double, Double)

    Declaration
    public void SetSize(double width, double height)
    Parameters
    Type Name Description
    System.Double width
    System.Double height
    | Improve this Doc View Source

    Transform(Point, Point, Double, Double)

    Moving the position of viewport to a new one

    Declaration
    public void Transform(Point positionScreen, Point previousPositionScreen, double deltaResolution = 1, double deltaRotation = 0)
    Parameters
    Type Name Description
    Point positionScreen
    Point previousPositionScreen
    System.Double deltaResolution

    Change of resolution for transformation (<1: zoom out, >1: zoom in)

    System.Double deltaRotation

    Change of rotation

    | Improve this Doc View Source

    WorldToScreen(Point)

    Converts X/Y in map units to a point in device independent unit (or DIP or DP), respecting rotation

    Declaration
    public Point WorldToScreen(Point worldPosition)
    Parameters
    Type Name Description
    Point worldPosition

    Coordinate in map units

    Returns
    Type Description
    Point

    Point in screen pixels

    | Improve this Doc View Source

    WorldToScreen(Double, Double)

    Converts X/Y in map units to a point in device independent units (or DIP or DP), respecting rotation

    Declaration
    public Point WorldToScreen(double worldX, double worldY)
    Parameters
    Type Name Description
    System.Double worldX

    X coordinate in map units

    System.Double worldY

    Y coordinate in map units

    Returns
    Type Description
    Point

    Point in screen pixels

    | Improve this Doc View Source

    WorldToScreenUnrotated(Point)

    Converts X/Y in map units to a point in device independent units (or DIP or DP), respecting rotation

    Declaration
    public Point WorldToScreenUnrotated(Point worldPosition)
    Parameters
    Type Name Description
    Point worldPosition

    Coordinate in map units

    Returns
    Type Description
    Point

    Point in screen pixels

    | Improve this Doc View Source

    WorldToScreenUnrotated(Double, Double)

    Converts X/Y in map units to a point in device independent units (or DIP or DP), respecting rotation

    Declaration
    public Point WorldToScreenUnrotated(double worldX, double worldY)
    Parameters
    Type Name Description
    System.Double worldX

    X coordinate in map units

    System.Double worldY

    Y coordinate in map units

    Returns
    Type Description
    Point

    Point in screen pixels

    Events

    | Improve this Doc View Source

    ViewportChanged

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

    Implements

    IViewport
    IReadOnlyViewport

    Extension Methods

    ViewportExtensions.ToSKMatrix(IViewport)
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX