centerOnRouteInstruction method

void centerOnRouteInstruction(
  1. RouteInstruction routeInstruction, {
  2. double zoomLevel = -1,
  3. Point<int> screenPosition = const Point<int>(0, 0),
  4. double? viewAngle,
  5. 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 highlight
  • zoomLevel: Target zoom level. Use -1 for automatic selection based on instruction context. Defaults to -1
  • screenPosition: Screen coordinates in physical pixels where the instruction should be centered, relative to the map view's top-left corner. Defaults to Point<int>(0, 0)
  • viewAngle: Camera pitch angle in degrees (0-90), where 0 is top-down view and 90 is horizon view. If null, maintains current pitch. Defaults to null. Useful for emphasizing the instruction with a specific perspective
  • animation: Animation settings for the centering operation. If null, centering occurs instantly. Defaults to null

See also:

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,
    },
  );
}