addSymbol method

Future<Symbol> addSymbol(
  1. SymbolOptions options, [
  2. Map? data
])

Adds a symbol to the map, configured using the specified custom options.

Change listeners are notified once the symbol has been added on the platform side.

The returned Future completes with the added symbol once listeners have been notified.
An Exception is thrown if the SymbolManager is not initialized (style not loaded yet).

Implementation

Future<Symbol> addSymbol(SymbolOptions options, [Map? data]) async {
  _ensureManagerInitialized(symbolManager);

  final effectiveOptions = SymbolOptions.defaultOptions.copyWith(options);
  final symbol = Symbol(getRandomString(), effectiveOptions, data);
  await symbolManager?.add(symbol);
  if (!isDisposed) notifyListeners();
  return symbol;
}