showRoute method

Future<void> showRoute()

Shows the remaining route on the map. Calculates and moves the camera to fit the remaining route geometry.

Implementation

Future<void> showRoute() async {
  final fullRouteGeometry = navigationManager.uiModel.route.route.geometry;
  final currentRoutePoint = navigationManager.uiModel.routePosition;

  final remainingGeometry = currentRoutePoint != null
      ? sdk.ComplexGeometry(
          sdk
              .remainingRouteGeometry(
                fullRouteGeometry,
                currentRoutePoint,
              )
              .entries
              .map<sdk.PointGeometry>(
                (entry) => sdk.PointGeometry(entry.value),
              )
              .toList(),
        )
      : sdk.ComplexGeometry(
          fullRouteGeometry.entries
              .map((entry) => sdk.PointGeometry(entry.value))
              .toList(),
        );

  final cameraPosition = sdk.calcPositionForGeometry(
    map.camera,
    remainingGeometry,
    null,
    const sdk.Padding(
      top: 32,
      bottom: 92,
      left: 32,
      right: 32,
    ),
    null,
    null,
    null,
  );

  await map.camera.moveToCameraPosition(cameraPosition).value;
}