centerOnRoute method
- Route route, {
- Rectangle<
int> ? screenRect, - GemAnimation? animation,
Centers the map view on an entire route with automatic zoom adjustment.
Positions the map to display the complete route path, automatically selecting the optimal zoom level to fit the entire route within the specified screen rectangle or the full viewport if no rectangle is provided.
This is useful for providing an overview of a calculated route before navigation or for displaying route alternatives.
Parameters
route: The Route object to center on and displayscreenRect: Target screen rectangle in physical pixels where the route 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:
- centerOnRoutes - Center on multiple routes simultaneously
- centerOnRoutePart - Center on a specific segment of a route
- centerOnRouteInstruction - Center on a specific route instruction
Implementation
void centerOnRoute(
final Route route, {
final Rectangle<int>? screenRect,
final GemAnimation? animation,
}) {
objectMethod(
_pointerId,
'MapView',
'centerOnRoute',
args: <String, dynamic>{
'route': route.pointerId,
if (screenRect != null) 'rc': RectType<int>.fromRectangle(screenRect),
if (animation != null) 'animation': animation,
},
);
}