enterRouteOverviewMode method

Future<void> enterRouteOverviewMode(
  1. RouteDetails route
)

//////////// //////////// Enters route overview mode to display the entire route

Implementation

// I.F - Route Overview Methods
///////////////
/// Enters route overview mode to display the entire route
Future<void> enterRouteOverviewMode(RouteDetails route) async {
  if (route.points.isEmpty) return;

  try {
    // Clear animation state
    _isCameraAnimating = false;

    // Get route bounds
    final bounds = route.bounds;

    // Calculate appropriate zoom level based on route distance
    double baseZoom = _routeZoom;
    if (route.distance > 160000) { // >100 miles
      baseZoom = 8.0;
    } else if (route.distance > 80000) { // >50 miles
      baseZoom = 9.0;
    } else if (route.distance > 40000) { // >25 miles
      baseZoom = 10.0;
    }

    // Create a center point from the route bounds
    final center = mapbox.Point(
      coordinates: mapbox.Position(bounds.center.lng, bounds.center.lat)
    );

    // Create and apply camera options
    final cameraOptions = mapbox.CameraOptions(
      center: center,
      zoom: baseZoom,
      pitch: 0.0, // Flat view for route overview
      bearing: 0.0, // North-up for route overview
      padding: mapbox.MbxEdgeInsets(
        top: 50.0,
        left: 50.0,
        bottom: 50.0,
        right: 50.0,
      ),
    );

    await mapboxMap.flyTo(
      cameraOptions,
      mapbox.MapAnimationOptions(duration: 1500),
    );
  } catch (e) {
    print('Error entering route overview mode: $e');
    rethrow;
  }
}