# Vector Tile Cache

**Vector tiles** are a highly efficient format for web mapping. The core concept is to divide a project's vector data into tiles, similarly to raster tile systems (e.g., WMTS).

There are several standards for producing vector tiles. [Mapbox](https://docs.mapbox.com/#maps) introduced a format based on Google’s **Protocol Buffers** encoding ( <https://developers.google.com/protocol-buffers>). Known as **MVT (Mapbox Vector Tiles)**, this format is widely supported by mapping tools including **JMap Cloud**, **JMap Server**, and **JMap NG**.

A **tiling grid** is applied to vector data, dividing it into tiles. Each tile can include features from multiple layers. A full set of tiles is generated for each **zoom level**. In web mapping, there are typically 23 levels:

* **Level 0** represents the entire Earth
* **Level 23** corresponds to street-level detail

Lower zoom levels use **simplified geometry** to reduce file size and improve performance.

Vector features (lines, polygons) are **clipped at tile boundaries**. When a geometry spans multiple tiles, it is split, and each tile stores only its part. The mapping application is responsible for reconstructing the complete geometry.

**Feature attributes** are embedded in the tiles, allowing **dynamic and interactive** data usage—for example:

* generating thematic maps on-the-fly
* applying attribute-based filters

**Styles** are not included within the tiles. Instead, they are defined in a separate **JSON** file. This allows applications to **dynamically style data**, eliminating the need to regenerate tiles when styles change.

Vector tiles can be generated **on-the-fly** or **pre-generated and cached**, significantly improving server response times and ensuring smooth user experiences.

## Vector Tile Generation in JMap Cloud

A JMap Cloud project produces three types of data consumed by client applications:

1. **Style JSON File**\
   This file accompanies the vector tiles and contains layer definitions, styles, thematics, etc.
2. **Vector Tile Set (MVT)**\
   These tiles contain the geometry and attributes of **non-editable layers**.\
   They can be generated:
   * **on demand**, as users navigate in JMap NG
   * **ahead of time**, then **cached**
3. **GeoJSON Vector Data**\
   These represent the **editable layers** and are delivered **on demand**, by region.

## Performance Factors for Vector Tiles

While vector tiles are generally lighter than raster tiles, several factors can affect tile size and impact JMap NG application performance:

* **Number of attributes per layer**\
  More attributes increase tile size and load times.
* **Layer visibility scales**\
  For dense layers, it is recommended to limit their visibility to higher zoom levels. This reduces data volume in low zoom tiles and accelerates tile generation.
* **Caching**\
  Pre-generating and caching tiles greatly enhances performance.

## Managing a Project’s MVT Cache

{% hint style="warning" %}
Cache generation can take considerable time and storage space. **It is not recommended to cache tiles beyond level 19**.
{% endhint %}

**To manage a project’s vector tile (MVT) cache:**

1. Click <img src="https://content.gitbook.com/content/9n1KCuTyIKwSpZcPcC6l/blobs/8m4xvrMS418SV0cyQWNm/menu.png" alt="" data-size="line">, then select **MVT Cache** to open the management interface.\
   This interface includes four sections.

   <table data-header-hidden><thead><tr><th width="197"></th><th></th></tr></thead><tbody><tr><td>Cache state</td><td>Indicates the cache status, if available.</td></tr><tr><td>Fill</td><td>This option allows you to indicate whether you want to create tiles for all 23 levels or for a specific range of levels. In this case, specify the minimum and maximum levels of the range. <br>This option does not overwrite tiles that are already cached.</td></tr><tr><td>Delete</td><td>This option allows you to specify whether you want to remove tiles from all 23 levels or from a specific range of levels. In this case, indicate the minimum and maximum levels of the range.</td></tr><tr><td>Running task</td><td>Indicates the progress of the creation or deletion by cache level as well as the overall progress of the creation or deletion.</td></tr></tbody></table>
2. Choose the task you want to perform.
3. Click **Launch task**. The **Running task** section shows progress visually and as a percentage.
4. To cancel a running task, click <img src="https://content.gitbook.com/content/9n1KCuTyIKwSpZcPcC6l/blobs/Nal83WoX1wUejISTuPQA/annuler-cache.png" alt="" data-size="line">. A confirmation message will appear.
