- Interaction: HTTP endpoints needed for implementing interactivity
- UTFGrid: This specification relies on UTFGrid 1.2 for interactivity.
MBTiles is a specification for storing tiled map data in SQLite databases for immediate usage and for transfer. MBTiles files, known as tilesets, must implement the specification below to ensure compatibility with devices.
Tilesets are expected to be valid SQLite databases of version 3.0.0 or higher. Only core SQLite features are permitted; tilesets cannot require extensions.
MBTiles databases can optionally use the officially assigned magic number to be easily identified as MBTiles.
Note: the schemas outlined are meant to be followed as interfaces. SQLite views that produce compatible results are equally valid. For convenience, this specification refers to tables and virtual tables (views) as tables.
The database is required to contain a table or view named
This table must yield exactly two columns named
value. A typical create statement for the
CREATE TABLE metadata (name text, value text);
The metadata table is used as a key/value store for settings. Five keys are required:
name: The plain-english name of the tileset.
version: The version of the tileset, as a plain number.
description: A description of the layer as plain text.
format: The image file format of the tile data:
One row in
metadata is suggested and, if provided, may enhance performance.
bounds: The maximum extent of the rendered map area. Bounds must define an area covered by all zoom levels. The bounds are represented in
WGS:84- latitude and longitude values, in the OpenLayers Bounds format - left, bottom, right, top. Example of the full earth:
attribution: An attribution string, which explains in English (and HTML) the sources of data and/or style for the map.
Several additional keys are supported for tilesets that implement UTFGrid-based interaction.
The database is required to contain a table named
The table must yield four columns named
tile_data. A typical create statement for the
CREATE TABLE tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob);
The tiles table contains tiles and the values used to locate them.
tile_row columns follow the
Tile Map Service Specification in
their construction, but in a restricted form:
The global-mercator (aka Spherical Mercator) profile is assumed
tile_data blob column contains raw image data in binary.
A subset of image file formats are permitted:
See the UTFGrid specification for implementation details of grids and interaction metadata itself: the MBTiles specification is only concerned with storage.
The database can have optional tables named
grids table must yield four columns named
grid. A typical create statement for the
CREATE TABLE grids (zoom_level integer, tile_column integer, tile_row integer, grid blob);
grid_data table must yield five columns named
key_json. A typical create statement for the
CREATE TABLE grid_data (zoom_level integer, tile_column integer, tile_row integer, key_name text, key_json text);
grids table contains UTFGrid data, gzip compressed.
grid_data table contains grid key to value mappings, with values encoded
as JSON objects.