# TarkovMap Self-hosted, mobile-friendly Escape from Tarkov map viewer. Layered PSDs go in, a Leaflet tile pyramid comes out, and every map is placed onto one shared world canvas — the overall satellite map, rotated so north is up. Zoom out for the whole of Tarkov; zoom into a location and the full-resolution re3mr map for it fades in over the terrain. Only the **base map art** is extracted. Markers, spawns, legends, captions and titles are dropped during the render. ## Quickstart ```bash git lfs install git lfs pull ``` ```bash python -m pip install -r tools/requirements.txt ``` ```bash python tools/build.py ``` The rendered base maps (`build//base.png`, Git LFS) and `web/data/` are committed, so on a fresh clone `build.py` only has to cut the tile pyramids from those PNGs -- a couple of minutes, no PSD work. It skips every map whose PSD is unchanged since its `base.png` was rendered (tracked in `build//base.stamp.json`, not by file mtimes, so a fresh clone does not re-render anything) and never rewrites an existing tile pyramid; delete `web/tiles/` or pass `--force-export` to redo one. ```bash pwsh server/get-caddy.ps1 ``` ```bash pwsh server/run.ps1 ``` Open the printed URL. The LAN address works from a phone on the same network. The default launcher is the editable authoring server. Pass `-ReadOnly` for a deployment-style preview. In read-only mode `run.ps1` uses Caddy when `server/caddy.exe` is present and falls back to `serve.py`, so the Caddy download is optional — see [Serving](#serving). Source PSDs and archives and the rendered `build/` PNGs are stored through Git LFS. Run `git lfs install` before cloning and `git lfs pull` if a checkout contains pointer files. ## Documentation | | | | --- | --- | | **[DOCUMENTATION.md](DOCUMENTATION.md)** | Full technical reference — architecture, coordinate systems, config, traps, troubleshooting | | **[docs/adding-a-map.md](docs/adding-a-map.md)** | Step-by-step runbook for adding a map | | **[PLAN.md](PLAN.md)** | Project status and remaining work | ## Adding a map See **[docs/adding-a-map.md](docs/adding-a-map.md)**. Short version: run `tools/psd_tree.py` to find the group holding the art, add an entry to `maps.json`, run `tools/build.py`. No application code changes. ## Layout ``` maps.json the only thing you edit to add or change a map tools/ psd_tree.py inspect a PSD's layer tree export_base.py PSD -> build//base.png (base group only) release.py static-site ZIP + git tag + Gitea release with the ZIP attached align_square.py register a regenerated square base to the rotated source; keep real pixels sea_corner.py flat sea fill for the outpainted corners of the square base tile.py base.png -> original and optional permanently trimmed tiles build.py orchestrator; also writes web/data/world.json preview.py stitch built tiles into one overview image place_preview.py gridded base map for positioning maps retilt.py change world.rotate, keeping placements common.py config loading + world placement maths server/serve.py dependency-free static server with sane cache headers web/ the site: index.html, app.js, style.css, vendored Leaflet sources/ Git LFS — layered source artwork build/ Git LFS — rendered base PNGs + base.stamp.json (PSD fingerprint) web/tiles/ gitignored — generated original tiles (build.py) web/tiles-trimmed/ gitignored — generated permanently trimmed tiles ``` ## How the shared canvas works The base is `sources/overall/overall.jpeg`, rotated **45°** so north is up. (An aspect-ratio fit of the Customs zone outline suggested 31°, but the zone polygon encloses more than the playable strip so that estimate ran low; 45° is the current visual starting point. Adjust with `tools/retilt.py`, which converts every placement through the old and new angles so geography is preserved.) World pixels are overall-map pixels × `overallScale` (64), which puts Customs at almost exactly its native 7832 px. Each map's `place` entry gives its centre and width in rotated overall-map pixels, and the tiler scales it to match. Tile grids must stay integral — a map's tile-index offset has to be a whole number of tiles at every zoom, which only holds when its origin is a multiple of `tileSize · 2^maxZoom` (131 072 px). Far too coarse to position anything. So rather than *moving* a map onto the grid, the tiler **pads** it up-and-left to the nearest cell boundary and only visits tiles containing real content. Exact placement, integral grid, and the padding costs nothing. Each map is tiled only down to its **native level** — the deepest zoom still downscaling its source. Main maps default to `minZoom: 0`, so they remain visible in the overview. Nested detail maps can set a later `minZoom` and only appear as you zoom in. ### Interactive placement Select a detail map, choose **Edit placement**, then drag its yellow center anchor or enter exact X/Y values. Width and Height can be changed independently to stretch the map horizontally or vertically around that anchor. All changes preview live without rebuilding. **Save & rebuild** writes the new geometry to `maps.json`, rebuilds only that map, and reloads its versioned tiles. The normal project launcher starts the writable local server: ```bash pwsh server/run.ps1 -Port 8081 ``` Use `-ReadOnly` for a deployment-style preview. In that mode the authoring controls are hidden and every write API returns `403`. The editable server is intended only for a trusted local machine or private admin access; exported static viewers remain read-only and use the separate local-marker mode below. ### Static-site export On the editable server, choose **Export site ZIP** to create and download `exports/tarkov-map-static.zip`. The archive contains only the finished `web/` document root plus a small export manifest; it does not include Python, PSDs, build tooling, editable APIs or marker backup snapshots. Extract the ZIP into a static host's document root and put that host behind Cloudflare. The bundled capability file keeps map geometry and all published files read-only. ### Releases `tools/release.py` turns the same export into a stable, versioned artefact on Gitea: it writes `exports/tarkov-maps-.zip`, creates and pushes an annotated git tag, creates the Gitea release for that tag (or reuses it) and attaches the ZIP through the REST API of the `origin` remote. ```bash GITEA_TOKEN=... python tools/release.py v2026.08.22 --build ``` The token is a Gitea personal access token with repository write access; it can also live in the gitignored `.env` as `GITEA_TOKEN=...`. `--build` runs `tools/build.py` first, `--zip-only` just writes the archive, `--replace` re-uploads over an existing asset, `--notes FILE` supplies release notes (otherwise they are generated), `--draft`/`--prerelease` mark the release. The tree must be committed (or pass `--allow-dirty`). Gitea caps attachments at its `[attachment] MAX_SIZE` (2048 MB by default; the ZIP is ~65 MB). To deploy a release, download the asset from the release page (for a private repository use the same token: `curl -H "Authorization: token $GITEA_TOKEN" -LO `) and unzip it into the static host's document root -- the directory `server/Caddyfile` serves. The exported viewer still allows visitors to edit markers. Published marker files (including the canonical marker edits made through the editable Python server) are cached per map in the browser. Visitor additions, moves, renames, category changes and deletions are stored only in that site's `localStorage`; the static host receives no write request. **Reset this map** discards the selected map's browser-local changes and refetches the latest published marker files. Local marker changes survive refreshes and browser relaunches, but remain specific to that browser, device and site origin. Placement mode renders the selected map at 50% opacity so landmarks on the overall map remain visible underneath it. ### Playable-area trimming Select a detail map and choose **Trim area**. Click around the playable boundary to add polygon points; drag any yellow point to refine it. The Outside transparency slider controls how strongly the unplayable portion fades while the polygon interior remains fully opaque. **Save trim** stores normalized polygon points in `maps.json`, leaves `build//base.png` and the original tile pyramid untouched, and writes a separate permanent `build//trimmed.png` plus `web/tiles-trimmed//` pyramid. The normal viewer loads that rasterized copy; only the editor uses a temporary live mask for previewing unsaved edits. Trim saves use a trim-only build, so they do not regenerate the original tiles. Map navigation and active-map detection are recalculated from the saved trim polygon, rather than continuing to use the untrimmed rectangular canvas. ### Semantic marker layer **Markers** toggles a real Leaflet data layer; no PSD marker artwork is placed over the tiles. `tools/extract_markers.py` reads visible on-map PSD layer metadata, ignores legends and title furniture, classifies and deduplicates markers, and writes normalized records to `web/data/markers/.json`: ```bash python tools/extract_markers.py python tools/extract_markers.py --source-root C:/path/to/source-checkout python tools/backup_markers.py python tools/render_marker_audit.py --source-root C:/path/to/source-checkout ``` The audit command flattens every visible PSD layer and writes a side-by-side reference/semantic comparison for each map. Use it after extraction to catch legend copies, off-map records, missing extract names and role mismatches. Every map uses the same configurable symbols, colors and labels. Open **Marker categories** to show or hide individual categories; those choices and the main toggle are persisted in local browser storage. Hovering a marker shows its name, category and source map. Edit `web/data/marker-config.json` to change category grouping, color, size, symbol (including emoji), visible text, default visibility, or the zoom at which text labels appear. The viewer builds a world-space grid index and only fetches only the focused parent/sub-map family, unloads the previous family, and creates markers only in the padded viewport. Selecting Customs therefore loads `customs.json` and `customs-dorms.json`; selecting Shoreline loads `shoreline.json` and `shoreline-resort.json`. `gridSize` and `viewportPadding` in the config tune the viewport index. Extracts and transits are enabled by default, use larger high-stacking symbols, and reveal labels earlier than ordinary markers. Bulk spawn, loot, key, cache and location categories begin hidden to keep the main map readable. The **Markers** slider (top right; bottom left on phones) scales marker icons and labels from 0.5× to 2× — it is one CSS transform per marker, persisted in `localStorage`; click the value to reset to 1×. The bottom-right **EN / 中文** control switches every published extract and transit name between English and Simplified Chinese. Chinese strings live in `web/data/extract-translations.zh-CN.json`, keyed by stable marker ID, and the selected language persists in the browser. Other marker categories and editor UI remain English until their localization data is added. Visible labels are laid out against the current viewport, nearby marker icons and the open control panel. Crowded labels move to the nearest free position; when that position is no longer adjacent, a leader line connects the label to its marker. Extract labels receive placement priority. With the editable server running, right-click the map (long-press on touch) and pick a category from the menu: a draft marker appears under the pointer with an edit box beside it. Type the name, then press Enter or click anywhere else to save it; Escape discards it. The same box opens when you click an existing marker in **Marker edit** mode, where you can rename it, change its category, delete it, or drag it to save a new position. **Drop new marker** is the click-to-place alternative for the selected map. Manual changes are written to `web/data/marker-edits/.json` as compact overrides, additions and deleted-marker IDs. The generated file under `data/markers/` remains untouched, so deletion is reversible. `tools/backup_markers.py` snapshots every generated map file into `web/data/marker-defaults/`. Existing snapshots are never overwritten and the backup files are marked read-only. The viewer and editable server do not write to that directory. ## No black gaps The base map is the backdrop. It is 85 tiles / 0.3 MB, always resident, and Leaflet upscales it past its native z3 — so any gap while detail tiles load shows blurry terrain rather than the page background. ## Cache busting Tile paths are stable across rebuilds but their contents are not — move a map's `place` and `tiles//6/17/33.webp` becomes different imagery. Tiles are served `immutable` for a week, so a browser that saw the old build would blend it with the new one and show duplicated, offset terrain. Each map therefore carries a `version` in `world.json` — a hash of its geometry, zoom range and source file stamp — appended to every tile URL as `?v=`. Re-tile a map and it simply gets fresh URLs. Identical rebuilds keep the same version, so nothing is re-downloaded needlessly. ## Stacking Placements are approximate, so map rectangles overlap where the real locations don't. Baseline order puts the finer map on top (by `maxNativeZoom`, then smaller footprint), and on top of that **the map whose centre you are viewing is lifted above all others** — so an overlapping neighbour can never hide the map you came to see. ## Current maps Base: `overall.jpeg` 1308 × 1296 → 1842 × 1842 rotated → world 117 824 × 117 824. | Map | PSD | Base layers | | --- | --- | --- | | Customs | 7832 × 5016 | `LOCATION` | | Customs — Dorms | 4301 × 4904 | `LOCATION` | | Woods | 7680 × 5168 | `re3mr.com/Map&Art/Map&OverlayArt/{RawMapLayer,WaterDetail}` | | Interchange | 9600 × 5400 | `3DRENDER` | | Reserve | 5760 × 3240 | `Day copy` | | Shoreline | 5760 × 3240 | `Baselayer` | | Shoreline — Resort | 10694 × 6016 | `BGCOLOR PATTERN`, `BASEMAP+2DLAYERS` | | Lighthouse | 8259 × 7560 | `Day` | | Streets of Tarkov | 7605 × 4841 | `Map - 3D map portion…` | There is **no shared naming convention** between these PSDs — see [docs/adding-a-map.md](docs/adding-a-map.md). ## Tile resolution and sharpness World `maxZoom` is 9, set so the whole 117 824 px world fits the pyramid. Each map is tiled only to its own **native level** — the deepest zoom still downscaling its source — recorded as `maxNativeZoom` in `world.json`. The base map is native at z3; detail maps land at z7–z9. Those ceilings are real: Customs' embedded terrain smart object is exactly 7832 × 3720 placed 1:1, so there is no hidden detail to recover. Past a map's native level the browser upscales. Sharpness is therefore about **level selection**, not pyramid depth. Leaflet picks its level with `Math.round(mapZoom)`, so at zoom 2.25 it takes level 2 and stretches it 1.19×. On a 150 %-scaled Windows display (`devicePixelRatio` 1.5) that compounds to a **1.78× upscale** — visibly soft. `DENSITY_BOOST` in `app.js` fixes it: halve the CSS size of a tile and request one level deeper, so we downscale a denser level instead of upscaling a coarser one. Measured at `devicePixelRatio` 1.5, in source pixels delivered per device pixel (higher is sharper, 1.0 is pixel-perfect): | View zoom | Before | After | | --- | --- | --- | | below native | 0.56 | **1.33** | | at native | 0.67 | 0.67 | It costs ~4× the tiles in view (99 at the busiest level on a 1315 px viewport, ~17 KB each) — DOM nodes, decodes and bytes — so it is no longer unconditional. In **Auto** it is on for displays above 1:1 (`devicePixelRatio` > 1.05, where the extra pixels are actually shown) and off for 1:1 displays, which accept at most a 1.19× stretch at quarter zooms. **Sharp** forces it on, **Fast** forces it off. See [Performance](#performance). Past a map's native level you are beyond its source resolution and the browser upscales — unavoidable, and `ZOOM_HEADROOM` deliberately allows one level of it. ## Performance The map is meant to be glanced at mid-raid, often on the weaker machine or phone that is *not* running the game, over whatever the Wi-Fi is doing. Two bottlenecks — device and connection — and both are dominated by how many tiles are in play. **Detail modes** (the *Detail* button in the panel; stored in `localStorage`, reloads the page): | Mode | Tiles | Tile fade | Tile loading | When | | --- | --- | --- | --- | --- | | Auto | density boost only above DPR 1 | on | during pans on desktop, after pans on phones | default | | Fast | 256 CSS px, no boost | off | after the pan settles | ≤ 4 GB RAM, ≤ 2 cores, `saveData`, 2G/3G — or by choice | | Sharp | density boost always | on | during pans | you have the GPU and the bandwidth | Measured on one Customs view at zoom 7 (816 × 1051 viewport): Auto/Sharp on a 2× display **89 requests / 1.3 MB / 89 tile nodes**; Fast **45 / 0.5 MB / 42**. **Always on, whatever the mode:** - **Low-res underlay.** Each detail map keeps its z ≤ 4 pyramid resident — a handful of tiles, ~20 KB per map — shown only while that map's full-res tiles are loading. A fresh deep link or a flick into new ground paints *blurry then sharp* instead of *holes then sharp*. - **Cache warming.** After the first view lands, the overview and every map's z ≤ 5 (z ≤ 4 in Fast) are fetched at idle, two at a time, low priority, paused while you pan. Tiles are `immutable` for a year, so the next visit — or the next alt-tab — paints the whole world from cache and only the deep levels of the map you are on touch the network. Skipped on `saveData` and 2G/3G. - **Service worker** (`web/sw.js`, read-only viewer only, HTTPS or `localhost`): tiles and vendor files cache-first, app shell stale-while-revalidate, `data/*.json` network-first with offline fallback. The map keeps working with no connection at all. The authoring server unregisters it so rebuilds show up immediately; plain-HTTP LAN addresses can't run one and rely on the warmed HTTP cache instead. - **Nothing per frame.** Pan/zoom handlers only touch the DOM when an editor is actually moving a map; markers re-cull and re-layout on `zoomend`, not on every zoom frame; the panel no longer `backdrop-filter`s the moving map; tiles decode off the main thread (`decoding="async"`). - **Markers.** Label layout batches writes before reads (one layout instead of one per label), tests icon collisions against a grid index instead of every icon, generates candidate positions lazily ring by ring, resolves label/leader elements once per marker instead of per pass, and derives label visibility from the map's CSS classes instead of `getComputedStyle` per label. Markers just outside the padded viewport are kept through short pans instead of being destroyed and recreated. Every pass is recorded as a `tarkov:marker-labels` performance measure. - **Smaller tiles.** WebP q78 instead of q82: ~15–20 % fewer bytes at no visible cost on map art (Customs 12.7 → 10.4 MB). Encoder method stays fast (5); method 6 is ~60× slower on tiles with alpha for no size gain. ## Experimental: AI-generated skirts The re3mr maps come with their own frame — Woods has black bars, Customs a sky gradient and a vignette — and the trim polygon only fades it. A *skirt* replaces it with terrain in the style of the map's own art, generated with the MiniMax CLI (`mmx`, logged in): ```bash python tools/skirt.py woods # vision → prompt → 1536² texture python tools/build.py --trim-only woods ``` `skirt.py` samples the art just inside the playable polygon, asks `mmx vision` to describe the ground (vegetation, palette, rendering style), asks `mmx image generate` for a strictly orthographic, uniformly distributed, seamless texture, saves it to `sources/skirts/.jpg` (+ a `.json` with the prompt and seed), and adds a default `skirt` block to the map in `maps.json`. `tile.py` then bakes it into the **trimmed** pyramid only: the texture is made seamless (offset-blend) and tiled with varied flips, colour-matched to the band just inside the polygon, laid under the whole rectangle and faded out toward its edge; the art is soft-cut at the polygon and its own frame is discarded. The original pyramid (what the editors show) is untouched. Knobs in `maps.json` → `skirt`: `scale` (texture px → map px, 0.6), `featherIn` (soft cut width, 80 px), `fadeOut` (fraction of the short side, 0.12), `matchColours` (true). Re-roll with `--seed N`, or `--prompt "…"` to skip vision. Limits: `mmx` is text-to-image only, so the skirt matches terrain and palette but cannot continue roads or buildings across the edge; it also fills tiles that were empty before (Woods trimmed: 4.4 → 7.8 MB). ## Serving Two read-only options, both selected with `server/run.ps1 -ReadOnly`: | | `serve.py` | Caddy | | --- | --- | --- | | Dependencies | none (stdlib) | one 47 MB binary | | conc 8 | 2,622 req/s · p95 4.0 ms | **6,987 req/s** · p95 1.9 ms | | conc 32 | 462 req/s · max **1,013 ms** | **5,877 req/s** · max 21 ms | | ETags / compression | no | yes (zstd, gzip) | Measured on loopback, 480 tile requests over reused connections. Tile responses are cached for one year and marked `immutable`. Versioned tile URLs make that safe after rebuilds and let a CDN serve repeat requests without returning to the origin VPS. The number that matters is the second row. `serve.py` is thread-per-connection behind the GIL, so under load it doesn't just slow down — throughput *falls* and tail latency goes past a second. Caddy stays flat. Use Caddy for anything real; `serve.py` exists so a fresh clone works with nothing installed. `serve.py` was also defaulting to **HTTP/1.0**, which closes the socket after every response — one TCP handshake per tile, ~30 per map view. It now sets HTTP/1.1, which is most of its improvement above. Neither runs HTTP/2: browsers only negotiate h2 over TLS, and putting a trusted cert on every phone isn't worth it on a LAN. The Caddy win is Go's I/O, not h2. To reach it from a phone, allow the port once (elevated): ```bash netsh advfirewall firewall add rule name="TarkovMap 8080" dir=in action=allow protocol=TCP localport=8080 ``` ## Licence Map art is by [re3mr.com](https://re3mr.com) under **CC BY-NC-SA 4.0**. Attribution is shown in the viewer and must stay there. Use is non-commercial, and derivative map images inherit the same licence. Local and LAN hosting is fine; get sign-off before hosting publicly.