centerOnMapRoutes method

void centerOnMapRoutes({
  1. RouteDisplayMode? displayMode,
  2. Rectangle<int>? screenRect,
  3. GemAnimation? animation,
})

Centers the map on all routes currently visible in the MapViewRoutesCollection.

Positions the map to display all routes that are currently marked as visible, automatically selecting the optimal zoom level to fit all visible route paths within the target screen rectangle. This is useful for showing all active routes without needing to specify each route explicitly.

Parameters

  • displayMode: Controls how routes are displayed (full paths, partial segments, etc.). If null, uses default display mode. Defaults to null
  • screenRect: Target screen rectangle in physical pixels where routes 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 centerOnMapRoutes({
  final RouteDisplayMode? displayMode,
  final Rectangle<int>? screenRect,
  final GemAnimation? animation,
}) {
  objectMethod(
    _pointerId,
    'MapView',
    'centerOnRoutes',
    args: <String, Object>{
      'routesList': -1,
      if (displayMode != null) 'displayMode': displayMode.id,
      if (screenRect != null)
        'viewRc': RectType<int>.fromRectangle(screenRect),
      if (animation != null) 'animation': animation,
    },
  );
}