centerOnRouteInstruction method
- RouteInstruction routeInstruction, {
- double zoomLevel = -1,
- Point<
int> screenPosition = const Point<int>(0, 0), - double? viewAngle,
- GemAnimation? animation,
Centers the map on a specific route instruction with visual indicator.
Positions the map to focus on a particular routing instruction (turn, exit, etc.) with a visible turn arrow displayed on the map. The instruction remains highlighted until cleared with clearRouteInstruction.
This is particularly useful during turn-by-turn navigation to show upcoming maneuvers or for reviewing specific instructions in a route.
Parameters
routeInstruction: The RouteInstruction to center on and highlightzoomLevel: Target zoom level. Use-1for automatic selection based on instruction context. Defaults to-1screenPosition: Screen coordinates in physical pixels where the instruction should be centered, relative to the map view's top-left corner. Defaults toPoint<int>(0, 0)viewAngle: Camera pitch angle in degrees (0-90), where 0 is top-down view and 90 is horizon view. Ifnull, maintains current pitch. Defaults tonull. Useful for emphasizing the instruction with a specific perspectiveanimation: Animation settings for the centering operation. Ifnull, centering occurs instantly. Defaults tonull
See also:
- clearRouteInstruction - Remove the instruction highlight
- centerOnRoute - Center on an entire route
- centerOnRoutePart - Center on a route segment
Implementation
void centerOnRouteInstruction(
final RouteInstruction routeInstruction, {
final double zoomLevel = -1,
final Point<int> screenPosition = const Point<int>(0, 0),
final double? viewAngle,
final GemAnimation? animation,
}) {
objectMethod(
_pointerId,
'MapView',
'centerOnRouteInstruction',
args: <String, Object>{
'instruction': routeInstruction.pointerId,
'zoomLevel': zoomLevel,
'xy': XyType<int>.fromPoint(screenPosition),
if (viewAngle != null) 'viewAngle': viewAngle,
if (animation != null) 'animation': animation,
},
);
}