viewport property
Retrieves the current viewport dimensions in physical pixels.
Returns a Rectangle<int> representing the visible area of the map view, measured in physical device pixels. The Rectangle.left and Rectangle.top fields are always 0, as coordinates are relative to the map view's top-left corner. The Rectangle.width and Rectangle.height represent the map view's dimensions in physical pixels.
Physical pixels differ from Flutter's logical pixels. To convert to logical pixels, divide by the device pixel ratio obtained from GemMapController.devicePixelSize.
Use transformScreenToWgsRect to convert the viewport to geographic coordinates (RectangleGeographicArea). Use viewportF to get viewport dimensions as ratios relative to the parent screen.
See also:
- viewportCenter - Center point of the viewport
- viewportF - Viewport in parent screen ratio
- transformScreenToWgsRect - Convert viewport to geographic area
Implementation
Rectangle<int> get viewport {
final OperationResult resultString = objectMethod(
_pointerId,
'MapView',
'getViewport',
);
final Rectangle<int> rect = Rectangle<int>(
resultString['result']['x'] ?? 0,
resultString['result']['y'] ?? 0,
resultString['result']['width'] ?? 0,
resultString['result']['height'] ?? 0,
);
return rect;
}