viewportCenter property
Calculates the center point of the current viewport.
Returns a Point<int> representing the center coordinates of the visible map area in physical pixels. Coordinates are relative to the map view's top-left corner. This is calculated from the current viewport by taking the midpoint of its width and height.
Useful for determining the default screen position when centering map operations or for UI element placement relative to the viewport center.
See also:
- viewport - Current viewport rectangle
- cursorScreenPosition - Current cursor position (defaults to center)
Implementation
Point<int> get viewportCenter {
final Rectangle<int> rc = viewport;
return Point<int>(
rc.left + (rc.width / 2).round(),
rc.top + (rc.height / 2).round(),
);
}