getVisibleRouteInterval method

(int, int) getVisibleRouteInterval(
  1. Route route, {
  2. Rectangle<int>? screenRect,
})

Determines which segment of a route is visible within a screen rectangle.

Returns the portion of a route that intersects with the specified screen rectangle, expressed as start and end distances along the route path. This is useful for identifying which parts of a route are currently visible to the user or within a specific viewport region.

If no rectangle is provided, uses the entire screen to determine visibility.

Parameters

  • route: The Route to analyze for visible segments
  • screenRect: Clipping rectangle in physical pixels to test for route visibility, relative to the map view's top-left corner. If null, uses the entire screen. Defaults to null. Useful for checking visibility within UI elements or specific areas

Returns

  • Record of (startDistance, endDistance) in meters from the route beginning, representing the visible route segment

See also:

Implementation

(int, int) getVisibleRouteInterval(
  final Route route, {
  final Rectangle<int>? screenRect,
}) {
  final OperationResult resultString = objectMethod(
    _pointerId,
    'MapView',
    'getVisibleRouteInterval',
    args: <String, dynamic>{
      'route': route.pointerId,
      if (screenRect != null)
        'clipRect': RectType<int>.fromRectangle(screenRect),
    },
  );

  return (resultString['result']['first'], resultString['result']['second']);
}