getVisibleRouteInterval method
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 segmentsscreenRect: Clipping rectangle in physical pixels to test for route visibility, relative to the map view's top-left corner. Ifnull, uses the entire screen. Defaults tonull. 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:
- centerOnRoutePart - Center on a specific route segment
- centerOnRoute - Center on an entire route
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']);
}