Class Viewport
Viewport holds all informations about the visible part of the map.
Inheritance
Inherited Members
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 SourceViewport()
Create a new viewport
Declaration
public Viewport()
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 SourceCenter
Coordinate of center of viewport in map coordinates
Declaration
public ReadOnlyPoint Center { get; set; }
Property Value
Type | Description |
---|---|
ReadOnlyPoint |
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.
HasSize
Declaration
public bool HasSize { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Height
Height of viewport in screen pixels
Declaration
public double Height { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
IsRotated
IsRotated is true, when viewport displays map rotated
Declaration
public bool IsRotated { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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);
Rotation
Viewport rotation from True North (clockwise degrees)
Declaration
public double Rotation { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Width
Width of viewport in screen pixels
Declaration
public double Width { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
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 SourceScreenToWorld(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 |
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 |
SetCenter(ReadOnlyPoint)
Declaration
public void SetCenter(ReadOnlyPoint center)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyPoint | center |
SetCenter(Double, Double)
Declaration
public void SetCenter(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | |
System.Double | y |
SetResolution(Double)
Declaration
public void SetResolution(double resolution)
Parameters
Type | Name | Description |
---|---|---|
System.Double | resolution |
SetResolution(Double, ReadOnlyPoint)
Declaration
public void SetResolution(double resolution, ReadOnlyPoint centerOfZoom)
Parameters
Type | Name | Description |
---|---|---|
System.Double | resolution | |
ReadOnlyPoint | centerOfZoom |
SetRotation(Double)
Declaration
public void SetRotation(double rotation)
Parameters
Type | Name | Description |
---|---|---|
System.Double | rotation |
SetSize(Double, Double)
Declaration
public void SetSize(double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | width | |
System.Double | height |
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 |
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 |
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 |
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 |
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 SourceViewportChanged
Declaration
public event PropertyChangedEventHandler ViewportChanged
Event Type
Type | Description |
---|---|
System.ComponentModel.PropertyChangedEventHandler |