ensure method

Future<void> ensure(
  1. String layerId
)

Download and merge a custom layer into the active style.

Implementation

Future<void> ensure(String layerId) async {
  if (_ensured.contains(layerId)) return;

  final item = _findItem(layerId);
  if (item == null) throw Exception('Layer "$layerId" not found in catalog.');

  _ensured.add(layerId);

  // By default, newly ensured items are hidden to match Web SDK behavior
  if (!_layerState.containsKey(layerId)) {
    _layerState[layerId] = {'visible': false, 'opacity': 1.0};
  }

  await _rebuildAndApplyStyle();
}