本文へ移動

Chizu地図

世界、253の国、33か国の州や県などの地域を、SVGの地図に描けます。表示する範囲を決めたり、番号付きの注記をつけたり、地理クイズを作ったりもできます。名前は今のところ英語と日本語で、スペイン語、ドイツ語、中国語にも対応する予定です。

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

目次

リファレンス · 世界の小さな国を点で表示

withSmallStates関数

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

The world with its smallest countries put back as dots. The 1:110m world has no outline for 62 of the 238 countries (Singapore, Malta, Bahrain, most of the Caribbean and the Pacific); this adds each as a small: true region, a small round shape at the middle of its largest island or piece, with its code, names, reading, continent and the countries it touches. Every region the map already has is kept as it is and the dots come after them, so the world is drawn, framed, labelled, called out and asked in a quiz as before, with the 62 as countries like any other. Only the world (id world) and its finer drawing (world-detail) get dots: any other map, and a world cut down to a group (groupMap), come back as they are, as does a world that already has every dot. The same map is returned for the same input, and the map given is never changed.

It is its own entry, so the table costs nothing until it is used. Draw or ask with the dots by giving the functions the map it returns: drawChizu(withSmallStates(WORLD)), findQuestion(withSmallStates(WORLD), "SG", random), pickDistractors(withSmallStates(WORLD), "SG"). mountChizu (smallStates: true), <chizu-map small-states> and <chizu-quiz small-states> fetch the entry themselves, only when that is on.

インポート

import { withSmallStates } from "@johnmorrisdotca/chizu/small-states";

定義

function withSmallStates<M extends SmallStatesMap>(map: M): M

引数

名前型説明
mapM

The world map, or its finer drawing; any other map is returned unchanged.

戻り値

M

The map with a dot added for each small country it does not draw, or map itself when there is nothing to add.

例

import WORLD from "@johnmorrisdotca/chizu/world";
import { withSmallStates } from "@johnmorrisdotca/chizu/small-states";

const withDots = withSmallStates(WORLD);
const singapore = withDots.regions.find((region) => region.code === "SG")!;
console.log(WORLD.regions.length, withDots.regions.length, singapore.small, singapore.nameJa);
// 173 235 true シンガポール
173 235 true シンガポール

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

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

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