I'm building a fan map of Leonida, the state in GTA 6. About 3,700 places, drawn with MapLibre GL. MapLibre wants real longitude and latitude. A game world has neither, so here's how I bent it into shape.
Fake the globe
The game data is in metres, from -16,384 to 16,384 on both axes. Web Mercator is a square too. So I stretch the game square over the whole Mercator square and treat lng/lat as a carrier, not a place on Earth:
const WORLD = 16384; export function toLngLat(x, y) { const u = (x + WORLD) / (2 * WORLD); const v = (WORLD - y) / (2 * WORLD); return [u * 360 - 180, Math.atan(Math.sinh(Math.PI * (1 - 2 * v))) * 180 / Math.PI]; } Everything is stored in game metres. Only this one file knows about lat/lng.
A nice side effect: the community tiles from GTADB (CC BY 4.0) line up with standard XYZ tiles, just shifted by two zoom levels. At the deepest level one pixel is half a metre.
The catch is that MapLibre's idea of distance is now meaningless. No scale bar. I measure in game metres myself.
Share links
People send each other "the safe is here" links all the time. #@25.7612,-80.1918,5.5 works, but it looks awful in a chat.
Round the centre to 4 m and each axis has 8,192 steps, so 13 bits. Zoom to one decimal fits in 7 bits. That's 33 bits, and 36^7 is about 78 billion, so a whole view fits in 7 base-36 characters:
function viewCode(lat, lng, zoom) { const [x, y] = fromLngLat(lng, lat); const q = (v) => Math.max(0, Math.min(8191, Math.round((v + WORLD) / 4))); const z = Math.max(0, Math.min(127, Math.round((zoom + 2) * 10))); return ((q(x) * 8192 + q(y)) * 128 + z).toString(36).padStart(7, '0'); } A single place is a 5-character hash of its ID. Old long links still parse.
Don't make phones wait for the map
This one mattered most. On a phone, a first-time visitor sat on a loading screen for 6 to 10 seconds while the map library, every place and the icon sprite came in.
Now the HTML ships a small picture of the island, with the popular guide spots as plain links on top. They're positioned with the same maths the map uses, so when MapLibre fades in over them nothing moves. Tap a spot before the map is ready and it's just a link.
The heavy files are marked in the page and only start loading once the first screen is drawn:
for (const l of document.querySelectorAll('link[data-later]')) { const n = document.createElement('link'); n.rel = l.dataset.later; n.as = l.getAttribute('as'); n.href = l.getAttribute('href'); document.head.append(n); } In the same test, the popular spots now show at 1.5 s instead of 5.1 s. The full map arrives 0.4 s later than before. I'll take that.
The map is at gta-6-map.org if you want to poke at it.

