Skip to content

KcdMp.mapTiles

The address of the world map’s tiles, for a zoomable map.

The address has {z}, {x} and {y} in it - the form Leaflet’s L.tileLayer and OpenLayers’ XYZ source take. Each tile is 256 by 256 pixels. Zoom 0 shows the whole map smallest (the Kuttenberg region 384 pixels wide), each zoom after it doubles it, and zoom 5 is the map at its full size (12288 pixels wide). A tile beyond the map’s edge fails to load, which those libraries take in their stride.

The tiles fit an image of width by height pixels at zoom maxZoom (from KcdMp.mapInfo): in Leaflet, that is a CRS.Simple map whose bounds are map.unproject([0, info.height], info.maxZoom) to map.unproject([info.width, 0], info.maxZoom). A library of your own goes in your interface’s files, like any script. In a browser, in mock mode, every tile is the same stand-in picture.

KcdMp.mapTiles(options?)
Parameter Type
options KcdMpMapOptions the level and the town (width is not used) (optional)

string - the tiles’ address with {z}, {x} and {y} in it, or "" when an option is of the wrong shape

Which map picture KcdMp.mapImage and KcdMp.mapTiles give.

Field Type
level string the level: "kutnohorsko" (the Kuttenberg region), "trosecko" (the Trosky region), "klaster" (Sedletz) - or "current", the level the server runs, which is the default (optional)
town string a town’s detailed map instead of the region’s - its name in KcdMp.mapInfo’s towns ("kutna_hora" is Kuttenberg’s) (optional)
width number KcdMp.mapImage alone: the picture’s width in pixels, 64 to 4096 (1024 by default); its height follows the map’s shape (optional)
// Leaflet (its files in your interface's folder)
const info = await KcdMp.mapInfo();
const map = L.map("map", { crs: L.CRS.Simple, minZoom: 0, maxZoom: info.maxZoom });
const bounds = L.latLngBounds(map.unproject([0, info.height], info.maxZoom), map.unproject([info.width, 0], info.maxZoom));
L.tileLayer(KcdMp.mapTiles(), { bounds, tileSize: info.tileSize, maxNativeZoom: info.maxZoom, noWrap: true }).addTo(map);
map.fitBounds(bounds);
// a marker where the game mode says the player is
KcdMp.onServer("me.pos", ({ x, y }) => {
const p = KcdMp.worldToMap(info, x, y);
L.marker(map.unproject([p.x, p.y], info.maxZoom)).addTo(map);
});

KcdMp.mapInfo · KcdMp.mapImage · KcdMp.worldToMap · the The game’s pictures and typefaces group of the index