Skip to content

Commit

Permalink
explain styles folder
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKreil committed Jan 14, 2025
1 parent 0d474f1 commit 435454f
Showing 1 changed file with 41 additions and 72 deletions.
113 changes: 41 additions & 72 deletions compendium/specification_frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,39 @@ Based on best practices, the VersaTiles Frontend Specification defines a recomme

## Folder Structure

- πŸ“„ **`index.html`**
The index.html file is the front page of the map server.

- πŸ“‚ **`assets/`**
[Contains all static resources such as libraries, fonts, sprites, styles, images, ...](#folder-assets)

- πŸ“‚ **`glyphs/`**
[Contains font glyphs used for map text rendering](#folder-assetsglyphs)

- πŸ“‚ **`{font_id}/`**
Each font face is stored in its own folder, named by its font ID.

- πŸ“„ **`{start}-{end}.pbf`**
The glyphs for each font are divided into ranges of 256 characters (e.g. `0-255.pbf`), with each file representing a particular Unicode range.

- πŸ“„ **`font_families.json`**
[Defines all available font families and their font faces (e.g. regular, italic, bold, condensed) along with their properties.](#file-assetsglyphsfont_familiesjson)

- πŸ“„ **`index.json`**
[A JSON file that lists all available font IDs, essentially providing an index of all the fonts in the `assets/glyphs/` folder.](#file-assetsglyphsindexjson)

- πŸ“‚ **`lib/`**
Contains all JavaScript/CSS libraries.

- πŸ“‚ **`maplibre-gl/`**
Folder for [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js), which must contain both `maplibre-gl.js` and `maplibre-gl.css` files for map rendering.

- πŸ“‚ **`versatiles-style/`**
Folder for [VersaTiles Style](https://github.com/versatiles-org/versatiles-style), which contains the `versatiles-style.js` file to generate map styles.

- πŸ“‚ **`.../`**
Optionally you can include other libraries such as [MapLibre GL Inspect](https://github.com/maplibre/maplibre-gl-inspect), ...

- πŸ“‚ **`sprites/`**
[Contains all map sprites (image files with multiple small graphical icons or symbols used on the map)](#folder-assetssprites)

- πŸ“‚ **`{sprite_id}/`**
Each sprite is stored in its own directory, named by its sprite ID.

- πŸ“„ **`sprite.json`**
The metadata for the sprite set, defined according to the [Sprite Source Format](https://maplibre.org/maplibre-style-spec/sprite/#sprite-source-format).

- πŸ“„ **`sprite.png`**
The actual sprite image, containing all the sprite icons in a single PNG image file.

- πŸ“„ **`index.json`**
[A JSON file listing all available sprite IDs.](#file-assetsspritesindexjson)

- πŸ“‚ **`styles/`**
Contains prepared map styles.

- πŸ“„ **`{style_id}/style.json`**
Each map style is stored in a separate folder. It must contain a `style.json` file following the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/) to define how the map is rendered. The folder may also contain additional files such as style-specific sprite definitions.

- πŸ“‚ **`.../`**
Optional subfolders such as `css/`, `fonts/`, `images/` and `js/` can be included as needed for additional resources.

- πŸ“‚ **`tiles/`**
[The contents of this folder are generated and returned by the tile server.](#folder-tiles)

- πŸ“‚ **`{tileset_id}/`**
Each tile set is organised in its own folder.

- πŸ“„ **`{z}/{x}/{y}{.ext}`**
[The individual map tiles are stored in subdirectories based on zoom level (`{z}`), column (`{x}`) and row (`{y}`). The tile file extension (`{.ext}`) is optional.](#files-tilestileset_idzxyext)

- πŸ“„ **`tiles.json`**
Metadata for each tile set following the [TileJSON specification](https://github.com/mapbox/tilejson-spec).

- πŸ“„ **`index.json`**
[JSON containing an array of all `tileset_id`s. This file acts as a directory of available tile sets.](#file-tilesindexjson)

<pre>
β”œβ”€β”€ πŸ“‚ <a href="#folder-assets">assets/</a>
β”‚ β”œβ”€β”€ πŸ“‚ <a href="#folder-assetsglyphs">glyphs/</a>
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ <a href="#folder-assetsglyphs">{font_id}/</a>
β”‚ β”‚ β”‚ └── πŸ“„ <a href="#folder-assetsglyphs">{start}-{end}.pbf</a>
β”‚ β”‚ β”œβ”€β”€ πŸ“„ <a href="#file-assetsglyphsfont_familiesjson">font_families.json</a>
β”‚ β”‚ └── πŸ“„ <a href="#file-assetsglyphsindexjson">index.json</a>
β”‚ β”œβ”€β”€ πŸ“‚ lib/
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ maplibre-gl/
β”‚ β”‚ β”‚ β”œβ”€β”€ πŸ“„ maplibre-gl.css
β”‚ β”‚ β”‚ β”œβ”€β”€ πŸ“„ maplibre-gl.js
β”‚ β”‚ β”‚ └── ...
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ versatiles-style/
β”‚ β”‚ β”‚ └── πŸ“„ versatiles-style.js
β”‚ β”‚ └── πŸ“‚ .../
β”‚ β”œβ”€β”€ πŸ“‚ <a href="#folder-assetssprites">sprites/</a>
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ <a href="#folder-assetssprites">{sprite_id}/</a>
β”‚ β”‚ β”‚ β”œβ”€β”€ πŸ“„ <a href="#folder-assetssprites">sprite.json</a>
β”‚ β”‚ β”‚ └── πŸ“„ <a href="#folder-assetssprites">sprite.png</a>
β”‚ β”‚ └── πŸ“„ <a href="#file-assetsspritesindexjson">index.json</a>
β”‚ β”œβ”€β”€ πŸ“‚ <a href="#folder-assetsstyles">styles/</a>
β”‚ β”‚ └── πŸ“‚ <a href="#folder-assetsstyles">{style_id}/</a>
β”‚ β”‚ └── πŸ“„ <a href="#folder-assetsstyles">style.json</a>
β”‚ └── πŸ“‚ .../
β”œβ”€β”€ πŸ“‚ <a href="#folder-tiles">tiles/</a>
β”‚ β”œβ”€β”€ πŸ“‚ <a href="#files-tilestileset_idzxyext">{tileset_id}/</a>
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ <a href="#files-tilestileset_idzxyext">{z}/</a>
β”‚ β”‚ β”‚ └── πŸ“‚ <a href="#files-tilestileset_idzxyext">{x}/</a>
β”‚ β”‚ β”‚ └── πŸ“„ <a href="#files-tilestileset_idzxyext">{y}{.ext}</a>
β”‚ β”‚ └── πŸ“„ tiles.json
β”‚ └── πŸ“„ <a href="#file-tilesindexjson">index.json</a>
└── πŸ“„ index.html
</pre>

## Folder: `/assets/`

Expand Down Expand Up @@ -192,6 +153,14 @@ Based on this example, the following glyphs must be present:
- See the [MapLibre Style Spec](https://maplibre.org/maplibre-style-spec/sprite/) for more detailed information on sprites.


### Folder: `/assets/styles/`

- All prepared map styles should be stored in the `/assets/styles/` directory.
- Each style should be in its own subdirectory: `/assets/styles/{style_id}/`.
- The styles are defined in JSON format according to the [MapLibre style specification](https://maplibre.org/maplibre-style-spec/) and should be served as `/assets/styles/{style_id}/style.json`.
- Additional variants of the style can also be saved in the folder, e.g. localised versions such as `de.json`, `en.json`, `nolabel.json` etc.
- Style IDs (`{style_id}`) should be OS/UNIX/URL safe, using only lower case letters, numbers and underscores.

### File: `/assets/sprites/index.json`

This file should contain a JSON array listing all available `{sprite_id}`s. These `{sprite_id}`s correspond to the folder names within `/assets/sprites/`. This index file can be used by map design tools to get a list of all sprites.
Expand Down

0 comments on commit 435454f

Please sign in to comment.