Reference · Framing, geometry and quiz tools
groupMapfunction
The map cut down to a group: the same canvas, only the regions whose codes are given (in the map's order), only their boxes, and neighbours only among themselves. What a quiz or a callout sheet within the group is given, so that "which country of Africa is this?" offers African look-alikes and numbers African countries only. Codes the map does not have are passed over.
Import it
import { groupMap } from "@johnmorrisdotca/chizu";
Definition
function groupMap(map: ChizuMap, codes: ReadonlyArray<string | number>, names?: { id?: string; name?: string; nameJa?: string; }): ChizuMap
Parameters
| Name | Type | Description |
|---|---|---|
map | ChizuMap | The native map or map fields required by this signature; coordinates and region codes belong to its canvas. |
codes | readonly (string | number)[] | Native region codes from this map, in the requested order. |
names (optional) | { id?: string; name?: string; nameJa?: string; } | Optional names for the resulting group map. |
Returns
ChizuMap
The map cut down to a group: the same canvas, only the regions whose codes are given (in the map's order), only their boxes, and neighbours only among themselves. What a quiz or a callout sheet within the group is given, so that "which country of Africa is this?" offers African look-alikes and numbers African countries only. Codes the map does not have are passed over.
Examples
import WORLD from "@johnmorrisdotca/chizu/world";
import { CHIZU_CONTINENTS } from "@johnmorrisdotca/chizu/names";
import { findQuestion, groupMap, seededRandom } from "@johnmorrisdotca/chizu";
const africa = CHIZU_CONTINENTS.find((continent) => continent.code === "AF")!;
const map = groupMap(WORLD, africa.codes, { name: africa.name, nameJa: africa.nameJa });
console.log(map.regions.length, findQuestion(map, "KE", seededRandom(1))?.choices.length);
// 50 450 4What it prints (run when this page was built)