centerOnRoutes method
- List<
Route> ? routes, - RouteDisplayMode displayMode = RouteDisplayMode.full,
- Rectangle<
int> ? screenRect, - GemAnimation? animation,
Centers the map on multiple routes simultaneously with automatic zoom.
Positions the map to display all specified routes, automatically selecting the optimal zoom level to fit all route paths within the target screen rectangle. If no routes are provided, centers on the visible routes from MapViewRoutesCollection.
The display mode controls whether the full route paths are shown or only specific segments, useful for comparing route alternatives or showing multiple navigation options. If RouteDisplayMode.full (default) is used, the entire paths of all routes are considered for centering. If RouteDisplayMode.branches is used, only the differing segments between routes are considered.
Parameters
routes: List of Route objects to center on and display. Ifnull, uses visible routes from MapViewRoutesCollection. Defaults tonulldisplayMode: Controls how routes are displayed (full paths, partial segments, etc.). Defaults to RouteDisplayMode.fullscreenRect: Target screen rectangle in physical pixels where routes should fit, relative to the map view's top-left corner. Ifnull, uses the entire viewport. Defaults tonull. Useful for fitting within UI elements or adding marginsanimation: Animation settings for the centering operation. Ifnull, centering occurs instantly. Defaults tonull
See also:
- centerOnRoute - Center on a single route
- centerOnRoutePart - Center on a route segment
- getOptimalRoutesCenterViewport - Calculate optimal viewport for routes
Implementation
void centerOnRoutes({
final List<Route>? routes,
final RouteDisplayMode displayMode = RouteDisplayMode.full,
final Rectangle<int>? screenRect,
final GemAnimation? animation,
}) {
objectMethod(
_pointerId,
'MapView',
'centerOnRoutes',
args: <String, dynamic>{
'routesList': (routes != null)
? RouteList.fromList(routes).pointerId
: -1,
'displayMode': displayMode.id,
if (screenRect != null)
'viewRc': RectType<int>.fromRectangle(screenRect),
if (animation != null) 'animation': animation,
},
);
}