centerOnRouteTrafficEvent method

void centerOnRouteTrafficEvent(
  1. RouteTrafficEvent routeTrafficEvent, {
  2. double zoomLevel = -1,
  3. Rectangle<int> rectangle = const Rectangle<int>(0, 0, 0, 0),
  4. double? viewAngle,
  5. GemAnimation? animation,
})

Centers the map on a traffic event along a route.

Positions the map to focus on a specific traffic event (accident, congestion, road closure, etc.) that affects a route. The zoom level can be automatic or manually specified to provide appropriate detail level.

This is useful for reviewing traffic conditions that may impact navigation or for investigating delays along a route.

Parameters

  • routeTrafficEvent: The RouteTrafficEvent to center on and display
  • zoomLevel: Target zoom level. Use -1 for automatic selection based on event context. Defaults to -1
  • rectangle: Target screen rectangle in physical pixels where the event should fit, relative to the map view's top-left corner. Defaults to Rectangle<int>(0, 0, 0, 0) (uses entire viewport). Useful for fitting within UI elements or adding margins
  • 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
  • animation: Animation settings for the centering operation. If null, centering occurs instantly. Defaults to null

See also:

Implementation

void centerOnRouteTrafficEvent(
  RouteTrafficEvent routeTrafficEvent, {
  final double zoomLevel = -1,
  final Rectangle<int> rectangle = const Rectangle<int>(0, 0, 0, 0),
  final double? viewAngle,
  final GemAnimation? animation,
}) {
  objectMethod(
    _pointerId,
    'MapView',
    'centerOnRouteTrafficEvent',
    args: <String, Object>{
      'traffic': routeTrafficEvent.pointerId,
      'zoomLevel': zoomLevel,
      'rc': RectType<int>.fromRectangle(rectangle),
      if (viewAngle != null) 'viewAngle': viewAngle,
      if (animation != null) 'animation': animation,
    },
  );
}