Claude f49a00bc98 Version tile URLs so rebuilt maps cannot serve a previous build
Tile paths are stable across rebuilds but their contents are not: moving a
map's `place` makes tiles/<id>/6/17/33.webp different imagery at the same
URL. Combined with the immutable week-long cache added earlier, a browser
that had seen an older build blended the two and drew duplicated, offset
terrain -- visible as a second copy of Lighthouse.

Each map now carries a `version` in world.json, hashed from its geometry,
zoom range and source file stamp, and appended to every tile URL as ?v=.
Re-tiled maps get fresh URLs; identical rebuilds keep the same version so
nothing is re-fetched needlessly.

Also corrects the runbook's base-layer table, which still listed the
pre-correction layers for Woods, Reserve, Interchange and Streets.

Verified: 733 tiles across seven map views, all carrying ?v=, zero broken,
and the focused map topmost in every case.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-08 14:59:41 -07:00

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

python -m pip install -r tools/requirements.txt
python tools/build.py
pwsh server/get-caddy.ps1
pwsh server/run.ps1

Open the printed URL. The LAN address works from a phone on the same network.

run.ps1 uses Caddy when server/caddy.exe is present and falls back to serve.py otherwise, so the first step is optional — see Serving.

Source PSDs are not in the repo (see .gitignore) — get them from the shared drive and put them under sources/.

Adding a map

See 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/<id>/base.png   (base group only)
  tile.py          base.png -> web/tiles/<id>/{z}/{x}/{y}.webp
  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/           gitignored — source PSDs
build/             gitignored — intermediate PNGs
web/tiles/         gitignored — generated tiles

How the shared canvas works

The base is sources/overall/overall.jpeg, rotated 35° 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; 35° lines the maps up better by eye. 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 — and has a minZoom below which it doesn't load at all. So the overview is just the base map, and detail maps appear as you go in.

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/<id>/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 → 1816 × 1812 rotated → world 116 160 × 115 968.

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.

Tile resolution and sharpness

World maxZoom is 9, set so the whole 116 160 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). Cached for a week and served by Caddy, that is a fair trade.

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.

Serving

Two options, both driven by server/run.ps1:

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.

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):

netsh advfirewall firewall add rule name="TarkovMap 8080" dir=in action=allow protocol=TCP localport=8080

Licence

Map art is by 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.

S
Description
A interactive map for Escape from Tarkov
https://map.luci.ooo
Readme
8.1 GiB
0 Stars 1 Watchers 0 Forks
Languages
Python 59.2%
JavaScript 32.8%
CSS 5.7%
HTML 1.2%
PowerShell 1.1%