MVT module · source API
MVTLoader
Resolve TileJSON or tile templates, then fetch individual Mapbox Vector Tiles as an application requests them.
What it does
Keep the service metadata separate from tile requests.
MVTLoader handles the source boundary: load the service description, resolve tile URLs, apply credentials, and return tiles as they are requested.
Source
TileJSON or a tiled service URL
Requests
Individual z / x / y vector tiles
Auth
Shared core credentials and Mapbox tokens
Errors
Empty tiles and text responses handled explicitly
Detailed guide
MVTLoader reference
The sections below document source creation, authentication, options, empty tiles, and service error behavior.
The MVTLoader dynamically loads tiles, typically from big pre-tiled hierarchies on cloud storage.
| Source | Characteristic |
|---|---|
| File Extension | .mvt .tilejson |
| File Type | Binary Archive |
| File Format | Mapbox Vector Tiles |
| Data Format | GeoArrow-compatible Arrow table |
Usage
import {createDataSource} from '@loaders.gl/core';
import {MVTLoader} from '@loaders.gl/tiles/mvt';
const source = await createDataSource(url, [MVTLoader]);
const tile = await source.getTile(...);
Vector tiles returned by MVTLoader are Arrow tables by default, matching MVTLoader's
columnar path. Set mvt.shape: 'geojson-table' explicitly when object-row GeoJSON output is needed.
Authentication
core.credentials applies to both the TileJSON request and every resolved tile URL. For Mapbox,
use createMapboxCredential from @loaders.gl/services; explicit access_token values in a
TileJSON URL or template take precedence. See the
authentication guide.
Options
For shared loading controls and parser configuration, see Source options. The settings below are specific to this source.
| Option | Type | Default | Description |
|---|---|---|---|
mvt.ignoreTextResponses | boolean | false | If enabled, reports successful responses with text, JSON, or XML MIME types through core.onError and returns null for those tiles. |
mvt.shape | string | 'arrow' | Output shape for fetched vector tiles. Set 'geojson-table' for object-row features. |
Empty Tiles and Error Responses
Tile services do not use one universal response for an empty or unavailable tile:
| Service | Typical behavior |
|---|---|
| Mapbox Vector Tiles API | Returns 404 for a missing tile and other non-2xx statuses for authentication, request, and rate-limit errors. |
| ArcGIS Vector Tile Service | Returns 404 when a tile is not found. |
| TileServer GL | By default returns 204 No Content for a missing vector tile; its sparse option changes this to 404. |
| Martin | Returns 204 No Content for a tile without features. |
| pg_tileserv | Returns 200 with the MVT MIME type and writes the encoded result; an empty result can therefore be a zero-byte binary response. |
| Tegola | Returns 200 with MVT bytes for a valid tile and 404 for requests outside the map bounds or without a layer at the requested zoom. |
MVTLoader preserves these normal cases. A 204 or zero-byte successful response is returned as an empty ArrayBuffer, while a non-2xx response is reported through core.onError and returned as null.
Some proxies, authentication gateways, and custom tile services return an HTML, JSON, or XML error document with a successful HTTP status. Enable the defensive MIME-type check for those services:
const source = await createDataSource(url, [MVTLoader], {
mvt: {
ignoreTextResponses: true
},
core: {
onError: error => console.error(error)
}
});
When enabled, the source reports text/*, JSON, and XML responses through core.onError and returns null. It does not reject unrecognized vendor MIME types, because custom services may use them for valid binary tiles. The check is disabled by default to avoid changing behavior for services that use unusual MIME types.
Source grid metadata
TileJSON establishes a canonical Web Mercator XYZ grid. getMetadata().tileGrid preserves
its zoom identifiers and range; bounds describe dataset coverage and do not redefine the world
grid or prove that individual tiles exist. Source requests use top-left XYZ rows, with
scheme: 'tms' converted at the endpoint. The existing {-y} token always inverts the caller's XYZ row, so TMS metadata does not invert it twice.
mvt.tileSize defines a logical pixel frame (default 256 for TileJSON), independently of vector
quantization extent or encoded image dimensions. mvt.minZoom, mvt.maxZoom, and mvt.scheme
override advertised values. With mvt.metadataUrl: null, configure mvt.coordinateReferenceSystem: 'EPSG:3857'
to establish a canonical source contract without a metadata fetch. Tile size alone does not establish a CRS. An arbitrary template or
standalone MVT/MLT payload does not establish a geographic grid.
tileMatrix selects an exact native zoom ID; without it the shared native-ID-first/index-fallback
rule applies. The resolved native zoom is also used for vector coordinate decoding. Out-of-world
indices return null; unknown explicit IDs reject. See Tile matrices.
The geographic and row-convention contract follows TileJSON 3.0.
A tile request's abort signal cancels its metadata wait promptly. Shared metadata discovery continues for other callers; cancelling one tile does not invalidate their requests.
TileJSON zoom ranges that are non-integral, inverted, or outside the supported grid range retain
their native metadata and omit tileGrid. They do not prevent ordinary numeric tile requests.