GeoLeaf Core API - v3.19.0
    Preparing search index...
    • Builds a transformStyle callback that carries the GeoLeaf-owned sources and layers from the previous style into the next one, appending the layers after the incoming basemap layers so they render on top (correct z-order). The raster basemap injection path re-inserts its layer at the bottom independently, so a vector→raster swap keeps GeoLeaf layers on top as well.

      Ownership is read through readOwned (the adapter's layer registry, and what code outside the adapter declared to it) rather than inferred from id conventions, so the merge is authoritative. It is read when the callback RUNS, never when it is built: a layer created while a style URL downloads is GeoLeaf's too, and "nothing to preserve" is decided against the real previous. Preserved layers keep their serialized paint/layout (e.g. taxonomy match expressions and visibility), and GeoJSON sources keep their serialized data — hence the rebuild is unnecessary.

      A declared basemap credit is set on the incoming style's own sources FIRST, before the merge, so it never lands on a GeoLeaf data source. It applies on the first style load too.

      Parameters

      • readOwned: () => OwnedStyleIds

        Returns the source/layer ids GeoLeaf owns at the moment it is called — which is when MapLibre runs the transform.

      • options: StyleTransformOptions = {}

        The incoming basemap's declared credit, if any.

      Returns StyleTransform

      A transformStyle callback for map.setStyle(next, { transformStyle }).

      // `layerIds` / `sourceIds`: live sets, kept up to date as layers come and go.
      const transform = buildGeoLeafStyleTransform(() => ({ layerIds, sourceIds }), {
      attribution: "© Provider",
      });
      map.setStyle(styleUrl, { diff: true, transformStyle: transform });