add method

void add(
  1. Route route,
  2. bool bMainRoute, {
  3. String? label,
  4. List<Img>? labelIcons,
  5. RouteRenderSettings? routeRenderSettings,
  6. bool autoGenerateLabel = false,
})

Add or update a route in the collection with optional render settings and label.

Adds the provided route to the collection. If bMainRoute is true the added route becomes the main route (rendered prominently); otherwise it is treated as a secondary/alternative route. When a route is already present in the collection this method updates its display settings.

Parameters

  • route: the Route to add or update in the collection.
  • bMainRoute: true to set the route as the main route; false to add it as an alternative.
  • label: optional text label shown on the route (for example ETA or distance).
  • labelIcons: optional list of up to two Img icons displayed inside the label. Use SdkSettings.getImgById(GemIcon.<name>.id) to obtain images.
  • routeRenderSettings: optional RouteRenderSettings to customize route appearance. When omitted a default RouteRenderSettings is used. All sizes in RouteRenderSettings are measured in millimetres.
  • autoGenerateLabel: when true the SDK automatically generates a label (overrides label and labelIcons).

See also:

Implementation

void add(
  final Route route,
  final bool bMainRoute, {
  final String? label,
  final List<Img>? labelIcons,
  RouteRenderSettings? routeRenderSettings,
  final bool autoGenerateLabel = false,
}) {
  routeRenderSettings ??= RouteRenderSettings();

  if (bMainRoute) {
    routeRenderSettings.options = <RouteRenderOptions>{
      RouteRenderOptions.main,
      ...routeRenderSettings.options,
    };
  }

  objectMethod(
    pointerId,
    'MapViewRouteCollection',
    'add',
    args: <String, dynamic>{
      'route': route.pointerId,
      'bMainRoute': bMainRoute,
      'routeRenderSettings': routeRenderSettings,
      'autoGenerateLabel': autoGenerateLabel,
      if (label != null) 'label': label,
      'labelIcons': labelIcons != null
          ? ImageList.fromList(labelIcons).pointerId
          : ImageList().pointerId,
    },
    dependencyId: mapPointerId,
  );
}