add method
void
add(})
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:trueto set the route as the main route;falseto add it as an alternative.label: optional text label shown on the route (for example ETA or distance).labelIcons: optional list of up to twoImgicons displayed inside the label. UseSdkSettings.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: whentruethe SDK automatically generates a label (overrideslabelandlabelIcons).
See also:
- RouteRenderSettings — Customize the visual appearance of routes.
- Route — The objects used for routing, analysis and navigation.
- SdkSettings.getImgById - Obtain images for
labelIcons.
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,
);
}