prepare method

Future<void> prepare(
  1. MapLayerHost host,
  2. Iterable<MarkerSpec> specs
)

Rasterises the icons of specs ahead of time (into the map's icon cache) without publishing anything, so a later publish of them is immediate.

Implementation

Future<void> prepare(MapLayerHost host, Iterable<MarkerSpec> specs) {
  final pixelRatio = host.pixelRatio;
  _followIcons(host, pixelRatio);
  final requested = <_IconKey>{};
  final pending = <Future<void>>[];
  for (final spec in specs) {
    final key = (spec.iconKey, spec.size);
    if (!requested.add(key) || _failed.contains(key) || _held.containsKey(key)) continue;
    if (host.icons.lookup(spec.iconKey, spec.size, pixelRatio) != null) continue;
    pending.add(_resolve(host, spec, pixelRatio));
  }
  return Future.wait(pending);
}