GeoLeaf Core API - v3.19.0
    Preparing search index...

    Function whenStyleReady

    • Resolves once the map reports its style — and the style's sources — loaded.

      Resolves at once when it already is. Otherwise it listens on STYLE_READY_EVENTS, re-tests isStyleLoaded() on each emission, and detaches from all three when it holds. It never rejects and has no deadline: a map whose style never loads can build nothing anyway, and a timeout would only turn that into a second, later failure.

      Parameters

      • map: StyleReadyMap

        The native map (or any object with its isStyleLoaded / on / off).

      Returns Promise<void>

      A promise settled when addSource / addLayer may be called.

      await whenStyleReady(map);
      map.addSource("gl-src-roads", spec);