tinySQL

# MBTiles demo — every tile is a SQL row

WASM · runs entirely in this tab

## How this map is served

There is no tile server here. tinySQL, compiled to WebAssembly, holds one `tiles` table (`zoom_level, tile_column, tile_row, tile_data`) and every tile the map draws is the result of one query, run in this tab:

SELECT tile_data FROM tiles WHERE zoom_level = z AND tile_column = x AND tile_row = TILE_FLIP_Y(y, z)

The world itself is generated art (value noise, not real geography) — see cmd/mbtilesdemo. What's real is the pipeline: this tileset was written to a spec-compliant `.mbtiles` file with `ExportMBTiles`, then read back with `ImportMBTiles` — the same functions documented in the README.

Download demo.mbtiles Open full SQL playground

## Live queries

Tiles rendered 0
Repeat SQL text (cache-eligible)0%
Avg. query time–

## Explore a point

Click anywhere on the map. This runs `TILE_ZXY`, `TILE_QUADKEY` and `TILE_BBOX` for that point at the current zoom and outlines the tile they land on. Right-click for more options.

click the map…

## Editor mode

Place your own named markers with a real `INSERT INTO custom_markers`; right-click one to `DELETE` it. A small foundation for building something game-like on top of this map.

Enable editor mode
Off — clicking the map explores a point as usual.

## Terrain editor 0 edits

Sculpt the generated terrain with a real `terrain_edits` table — each brush stroke is one `INSERT`; tiles re-query and re-composite it live as you pan and zoom.

Brush size
No tool selected — pick Mountain, Dig or River, then click (or drag, for River) the map.

## Geospatial queries settlements

A `settlements` table sits alongside `tiles` — one row per marker, geometry stored as the same GeoJSON `GEO_POINT` shape. Clicking the map finds the nearest settlement with `GEO_DISTANCE`; clicking two markers runs this query to measure the great-circle distance, bearing and midpoint between them:

SELECT GEO_DISTANCE(a.geometry, b.geometry), GEO_BEARING(a.geometry, b.geometry), GEO_MIDPOINT(a.geometry, b.geometry) FROM settlements a JOIN settlements b ON a.name = ? AND b.name = ?
click a settlement marker…
Grassland Plains Forest Highland

## Mapshaper-style editing

Run the new geometry functions against the `mapshaper_shapes` layer. The dashed gray outline is the source; teal is the SQL result.

Shape
Upload GeoJSON
simplify tolerance smooth passes shift x shift y scale rotate ° snap grid
Loading geometry…
Choose an operation…

## Tileset metadata

Loading tinySQL WASM…