KcdMp.mapImage
The address of the world map as one picture, for an <img> or a CSS background.
The picture is the map the M key opens - the whole region of the level, or a town’s detailed map with town - made
by the player’s own game at the width you ask for (its height follows the map’s shape: the Kuttenberg region is 6 : 5,
the Trosky region square). The first time a size is asked for, the game takes a moment to make it - a tenth of a second
for 1024 pixels, about two seconds for 4096 - and asks for it again are answered at once while it is kept. The largest
pictures are heavy (a 4096-pixel map is 20 to 40 MB): for a map the player zooms and drags, use KcdMp.mapTiles,
whose tiles take a few milliseconds each.
Parts of the Kuttenberg region’s picture that the game has no painting for (its corners) are transparent. A level or a
town that has no map fails to load like any missing image: the <img>’s error event fires. In a browser, in mock
mode, a plain stand-in picture is given. Options of the wrong shape give "".
Syntax
Section titled “Syntax”KcdMp.mapImage(options?)| Parameter | Type | |
|---|---|---|
options |
KcdMpMapOptions |
the level, the town and the width - all optional: KcdMp.mapImage() is the server’s level 1024 pixels wide (optional) |
Returns
Section titled “Returns”string - the picture’s address, or "" when an option is of the wrong shape
KcdMpMapOptions
Section titled “KcdMpMapOptions”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) |
Example
Section titled “Example”const img = document.querySelector("#map");img.src = KcdMp.mapImage({ width: 2048 }); // the server's levelimg.style.width = "100%"; // it scales like any picture
const town = document.querySelector("#town");town.src = KcdMp.mapImage({ level: "kutnohorsko", town: "kutna_hora", width: 1024 });See also
Section titled “See also”KcdMp.mapTiles · KcdMp.mapInfo · KcdMp.worldToMap · the The game’s pictures and typefaces group of the index
