本文へ移動

Chizu地図

SVGの地図を描き、地域を表示範囲に収め、番号付きの注記や地理クイズを英語と日本語の名前で作れます。

「地図」は、土地や場所を図で表したものです。 名前について(英語)

目次

リファレンス · 表示範囲・形・クイズの道具

groupMap関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 { groupMap } from "@johnmorrisdotca/chizu";

定義

function groupMap(map: ChizuMap, codes: ReadonlyArray<string | number>, names?: { id?: string; name?: string; nameJa?: string; }): ChizuMap

引数

名前型説明
mapChizuMap

The native map or map fields required by this signature; coordinates and region codes belong to its canvas.

codesreadonly (string | number)[]

Native region codes from this map, in the requested order.

names (省略可){ id?: string; name?: string; nameJa?: string; }

Optional names for the resulting group map.

戻り値

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.

例

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 4
50 4

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/chizu 1.5.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。