@versatiles/style
    Preparing search index...

    Function guessSchema

    Everything both entry points expose. index.ts (npm) adds the authoring helpers on top; browser.ts (the CDN bundle) does not — see the note in each.

    • Recognise the vector tile schema of a tileset from its TileJSON.

      Reads only vector_layers: the source-layer ids, and the fields of the few ids two schemas share. name, attribution and the like are not used — they describe who built a tileset, not what is in it. Synchronous and free of I/O; for a URL, download the document with fetchTileJSON() first.

      Knows Shortbread, OpenMapTiles and Protomaps without importing any of their styles, so it costs the root bundle a small table rather than two schemas. Build the style from the matching subpath:

      import { guessSchema, osm } from '@versatiles/style';
      import { omt } from '@versatiles/style/omt';
      const guess = guessSchema(tileJSON);
      if (guess.type === 'vector' && guess.schema === 'openmaptiles') style = omt({ urls: { omt: tileJSON } });

      A schema is recognised when it qualifies (at least half the tileset's source-layers are its, or at least eight are) and scores strictly higher than every other schema. Never throws.

      Parameters

      Returns SchemaGuess