checkObjectVisibility method

bool checkObjectVisibility({
  1. MapSceneObject? mapSceneObject,
  2. Rectangle<int>? rect,
})

Checks if a map scene object is visible within a specified viewport rectangle.

Determines whether the given MapSceneObject appears within the bounds of the specified screen rectangle. This performs a geometric bounds check only and does not consider the object's visibility settings or whether it is actually rendered on screen.

If no rectangle is provided, checks visibility against the entire screen. If no scene object is provided, uses the default position tracker.

Parameters

  • mapSceneObject: The map scene object to test for visibility. If null, uses the default position tracker. Defaults to null
  • rect: Viewport rectangle in physical pixels for visibility testing, relative to the map view's top-left corner. If null, uses the entire screen. Defaults to null

Returns

  • true if the scene object's bounds intersect with the specified viewport, false otherwise

See also:

Implementation

bool checkObjectVisibility({
  MapSceneObject? mapSceneObject,
  Rectangle<int>? rect,
}) {
  rect ??= const Rectangle<int>(0, 0, 0, 0);
  mapSceneObject ??= MapSceneObject.getDefPositionTracker();

  final OperationResult resultString = objectMethod(
    _pointerId,
    'MapView',
    'checkObjectVisibility',
    args: <String, dynamic>{
      'obj': mapSceneObject.pointerId,
      'rc': RectType<int>.fromRectangle(rect),
    },
  );

  return resultString['result'];
}