setMarkersOpacity method

Future<void> setMarkersOpacity(
  1. double opacity
)

Sets the opacity of all currently visible native markers (GL Circles and Symbols) to opacity in a single bulk update.

Designed to work together with addMarker when called with opacity: 0.0. Drive this method from a Flutter AnimationController to achieve a smooth fade-in effect:

_animController.addListener(() {
  _mapController.setMarkersOpacity(_animController.value);
});
_animController.forward(from: 0);

opacity must be between 0.0 (transparent) and 1.0 (fully visible).

Implementation

Future<void> setMarkersOpacity(double opacity) async {
  final clampedOpacity = opacity.clamp(0.0, 1.0);
  // Update all GL Circles
  for (final circle in _controller.circles) {
    await _controller.updateCircle(
      circle,
      CircleOptions(
        circleOpacity: clampedOpacity,
        circleStrokeOpacity: clampedOpacity,
      ),
    );
  }
  // Update all GL Symbols
  for (final symbol in _controller.symbols) {
    await _controller.updateSymbol(
      symbol,
      SymbolOptions(iconOpacity: clampedOpacity),
    );
  }
}