StreetZIM: Offline Maps 200x Smaller
The Problem
Kiwix packages Wikipedia, Stack Overflow, and other sites into ZIM files for offline reading. Their map ZIMs use raster tiles — pre-rendered PNGs at fixed zoom levels. A raster map of the US at useful zoom levels runs 50-200 GB. The whole planet at full zoom: ~54 terabytes. That’s not practical for the USB sticks and SD cards that offline content typically lives on.
I built StreetZIM to solve this: interactive OpenStreetMap data in ZIM format, using vector tiles instead of raster images, at file sizes 50-200x smaller than existing approaches.
How It Works
The key insight is that vector tiles store the raw geometry and metadata of map features (roads, buildings, labels) rather than pre-rendered images. The rendering happens on the device using MapLibre GL JS, a GPU-accelerated mapping library that runs in any modern web browser. This means:
- Infinite zoom resolution — no blurry tiles when you zoom in
- Dynamic styling — switch between map views, toggle satellite imagery, enable 3D terrain
- Dramatically smaller files — you’re storing data, not millions of images
The Pipeline
- Download OSM data in PBF format from Geofabrik
- Generate vector tiles using tilemaker (OpenMapTiles schema) into MBTiles (SQLite)
- Extract and package tiles + MapLibre GL JS + styles + fonts into a ZIM file
- Distribute via Archive.org with auto-generated torrents
The ZIM file is a self-contained web app. Kiwix serves it like a local web server, MapLibre GL JS runs in the browser, and tile requests are intercepted and served from the archive. No internet needed.
Size Comparison
| Area | StreetZIM (Vector) | Raster Equivalent (est.) | Reduction |
|---|---|---|---|
| Monaco | 778 KB | ~50 MB | ~64x |
| Washington, D.C. | 7.8 MB | ~2-5 GB | ~250-640x |
| US State (typical) | 60-250 MB | ~50-200 GB | ~800x |
| Entire Planet | ~100-150 GB | ~54 TB | ~360x |
A complete, interactive, zoomable map of Washington, D.C. fits in 7.8 megabytes. That’s smaller than most photos on your phone.
Fixing Bugs in libzim
Scaling beyond city-sized maps uncovered two bugs in libzim, the C++ library that creates ZIM files. Both are showstoppers for large builds:
Bug 1: Spin-Lock CPU Stall
libzim’s thread synchronization uses microsleep() polling — every thread continuously checks “is my data ready yet?” in a tight loop. When compression workers are slow (as they are for large tile sets), every CPU core burns at 100% utilization doing zero useful work. I replaced four spin-loop sites with std::condition_variable waits across seven source files, letting threads sleep until they’re actually needed.
Bug 2: Compressor Infinite Loop
When ZSTD compressed output exactly fills the output buffer (both avail_in == 0 and avail_out == 0 simultaneously), the compression function enters an infinite loop. This triggers deterministically at tile ~431,760 on US-scale builds — the compressed output of one specific cluster happens to be exactly 1,048,576 bytes (1 MiB), filling the buffer with zero bytes remaining. A classic edge case.
Both patches are included in the StreetZIM repo and are essential for any build above city scale.
Incremental Updates with ZIMDiff
Creating 100+ GB map files raised an immediate follow-up question: how do you update them? Asking users to re-download the entire file every month isn’t practical.
ZIMDiff creates compact overlay files containing only the changes between ZIM versions. The overlay is itself a valid ZIM file — it can be read transparently on top of the base file without merging. I haven’t gotten around to testing map differences with this yet.
Features Beyond Basic Maps
StreetZIM isn’t just a static map viewer:
- Wiki Explorer sidebar — browse Wikipedia entries for places visible in the current viewport
- Satellite imagery — toggle Sentinel-2 satellite views with hillshade
- 3D terrain — Copernicus GLO-30 elevation data for terrain visualization
- Full-text search — find cities, streets, and points of interest with city-level context
- Wikidata enrichment — population, elevation, and Wikipedia extracts for 3.15M places
- Non-Latin font support — full Basic Multilingual Plane glyph ranges for worldwide coverage
ZIM files are uploaded to Archive.org with auto-generated torrents, currently covering 10 regions including the full United States, Europe, West Asia, and individual US states.
Update, November 2026: From a Map to a Travel Companion
Since this post went up in April, StreetZIM has had more than 1,700 changes, and it has grown from “a small map in a ZIM file” into something much closer to a full offline travel app. Everything below runs with no network at all, inside Kiwix or a browser.
Find anything
Search now covers places, streets, house addresses, points of interest, parks, peaks, water, and administrative areas from countries down to city wards. A Find page lists what’s nearby by category (food and drink, bars, hotels, museums, parks, health, shops, gas), sorted by distance. Each place, park, peak and airport also gets its own page, so Kiwix’s own title and full-text search finds them too. Maps can carry Overture addresses and place details like websites and phone numbers.
Get there
Offline routing for driving, walking and biking runs in a Web Worker, with a GPS turn-by-turn display. For big countries the routing graph is split into small cells that load only as you need them, so a whole country can route on a phone.
Search with a photo
Tap the camera in the search box, point it at a street sign, a shop front or a plaque, and an OCR model running on the device reads it and finds the place. It reads Latin, Chinese, Japanese, Korean, Thai, Arabic, Cyrillic, Greek, Devanagari, Tamil and Telugu. It understands the details that make real signs hard: US street-name blades with their cross street, a typed corner like “Addison & Emerson”, Chinese boards that read right to left or top to bottom, and Korean building numbers written in two parts. Photo search can even be added to a map that was built without it, with no rebuild.
See the land
Terrain comes from the Copernicus elevation model, with hillshade and 3D views. Maps can include Sentinel-2 satellite imagery, Wikidata facts, and full Wikipedia articles for the places on the map, shown in the map’s own language when that Wikipedia has them.
In your language
The viewer and the StreetZIM site now come in 22 languages, and streets are labeled in the languages of the region. India comes as six regional maps, each with a lighter version, with proper fonts for Indian scripts. Maps that cross the 180th meridian, like Fiji, work too.
Open it anywhere
Maps open in Kiwix on iPhone, Android and desktop, or in a browser app on the StreetZIM site that opens a map you’ve downloaded or streams one from archive.org. Published regions run from Silicon Valley to Switzerland, Taiwan, Egypt, Greece and Ukraine, each with its own torrent on archive.org.
Built to fit the ecosystem
StreetZIM now also ships a streetzim command that follows openZIM’s own conventions, so it fits the tools the Kiwix community already uses. If you want an offline archive of something other than a map, that’s what Zimsmith is for.
What I Learned
Vector tiles are transformatively better for offline maps. The size difference isn’t incremental — it’s orders of magnitude. A 7.8 MB interactive map of D.C. vs. hundreds of MBs of raster tiles changes what’s practically distributable. This approach should replace raster tiles in every offline map project.
Upstream libraries have edge cases at scale. Both libzim bugs are invisible at small scale and deterministic at large scale. The spin-lock issue doesn’t matter for a 10 MB ZIM; it’s crippling for a 100 GB one. The compressor bug triggers at exactly tile 431,760. Testing at production scale matters.
Content-level diffing beats byte-level diffing for compressed archives. xdelta3 (byte-level) produces diffs 10x larger than ZIMDiff (content-level) because ZSTD compression defeats byte-level delta encoding. Understanding the file format lets you build dramatically better tools.