transformScreenToWgsRect method
Converts a screen rectangle to a geographic area.
Transforms a rectangular region in screen coordinates (physical pixels) to its corresponding RectangleGeographicArea defined by WGS84 coordinates. If no rectangle is specified, transforms the entire viewport to geographic coordinates.
The input rectangle is automatically clipped to the viewport bounds. Useful for determining what geographic region is visible in a specific screen area, such as the visible map extent or a custom UI region.
Parameters
screenRect: Screen rectangle in physical pixels to convert. Ifnull, uses the entire viewport. The rectangle is clipped against viewport bounds. Defaults tonull
Returns
- RectangleGeographicArea with top-left and bottom-right WGS84 coordinates corresponding to the screen rectangle
See also:
- transformScreenToWgs - Convert single screen point to coordinates
- transformWgsToScreen - Convert geographic coordinates to screen position
- viewport - Current viewport rectangle
Implementation
RectangleGeographicArea transformScreenToWgsRect({
Rectangle<int>? screenRect,
}) {
screenRect ??= const Rectangle<int>(0, 0, 0, 0);
final OperationResult resultString = objectMethod(
_pointerId,
'MapView',
'transformScreenToWgsRect',
args: RectType<int>.fromRectangle(screenRect),
);
return RectangleGeographicArea.fromJson(resultString['result']);
}