centerOnRoutePart method

void centerOnRoutePart(
  1. Route route,
  2. int startDist,
  3. int endDist, {
  4. Rectangle<int>? screenRect,
  5. GemAnimation? animation,
})

Centers the map view on a specific segment of a route with automatic zoom.

Positions the map to display a portion of a route defined by start and end distances along the route path. The zoom level automatically adjusts to fit the specified segment within the target screen rectangle.

This is useful for focusing on specific parts of a route, such as upcoming segments during navigation or highlighting problematic sections.

Parameters

  • route: The Route object containing the segment to display
  • startDist: Start distance in meters from the beginning of the route
  • endDist: End distance in meters from the beginning of the route
  • screenRect: Target screen rectangle in physical pixels where the route segment should fit, relative to the map view's top-left corner. If null, uses the entire viewport. Defaults to null. Useful for fitting within UI elements or adding margins
  • animation: Animation settings for the centering operation. If null, centering occurs instantly. Defaults to null

See also:

Implementation

void centerOnRoutePart(
  final Route route,
  final int startDist,
  final int endDist, {
  final Rectangle<int>? screenRect,
  final GemAnimation? animation,
}) {
  objectMethod(
    _pointerId,
    'MapView',
    'centerOnRoutePart',
    args: <String, dynamic>{
      'route': route.pointerId,
      'startDist': startDist,
      'endDist': endDist,
      if (screenRect != null)
        'viewRc': RectType<int>.fromRectangle(screenRect),
      if (animation != null) 'animation': animation,
    },
  );
}