本文へ移動

Chizu地図

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

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

目次

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

ChizuRegion型

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

One place on a map: a country on the world, a province or state on a country.

インポート

import type { ChizuRegion } from "@johnmorrisdotca/chizu";

定義

interface ChizuRegion {
    code: string;
    iso?: string;
    name: string;
    nameJa?: string;
    nameShortJa?: string;
    reading?: string;
    group: string;
    groupJa?: string;
    unnamed?: boolean;
    groupAliases?: string[];
    type?: string;
    iso3?: string;
    path: string;
    bbox: [
        number,
        number,
        number,
        number
    ];
    centroid: [
        number,
        number
    ];
    neighbors: string[];
}

メンバー

名前型説明
codestring

Its code within its map: an ISO 3166-1 alpha-2 code on the world (JP), the postal or ISO 3166-2 part on a country (ON), the prefecture number in Japan (13).

iso (省略可)string | undefined

Its ISO 3166-2 code, the full form (JP-13, CA-ON, US-TX), on a country's regions, from kuni 国 (@johnmorrisdotca/kuni) at build time, so a figure keyed by ISO code joins to the map and a region joins to kuni. Where Natural Earth draws one ISO subdivision as several regions (County Dublin's four councils), each carries the code of the one it lies in. Absent where ISO 3166-2 has no code for the region drawn (a county merged away, a territory with none); docs/iso-codes.md in the repository lists them with the reasons.

namestring

Its English name.

nameJa (省略可)string | undefined

Its name in Japanese, where there is one.

nameShortJa (省略可)string | undefined

The everyday short name where it is not nameJa (アメリカ for アメリカ合衆国).

reading (省略可)string | undefined

How nameShortJa ?? nameJa is read, in kana, where it is written with kanji and the reading is known.

groupstring

What kind of region it sits among, for choosing look-alikes: a continent on the world, a larger part of the country on a country's map.

groupJa (省略可)string | undefined

group in Japanese, where it is known: the continent on the world (アジア), the region on Japan's map (関東地方), the Census region on the United States' (南部).

unnamed (省略可)boolean | undefined

True for a piece of land the map draws but does not name: the one is a 38 km² piece of the Yamal coast Natural Earth gives no name or code. It is drawn, so the coast has no hole, but findQuestion and pickDistractors never ask about it or offer it, regionGroups leaves it out, and a page leaves it out of its lists.

groupAliases (省略可)string[] | undefined

Other names group goes by, in either language, where it has them: Kansai and 関西 for Japan's Kinki (近畿地方).

type (省略可)string | undefined

What kind of division it is, as Natural Earth names it, lower case: province, state, prefecture.

iso3 (省略可)string | undefined

The three-letter code, on the world and on a country's own map.

pathstring

Its outline, M x,y L x,y … Z with one piece for each part (islands are pieces), on the map's canvas.

bbox[number, number, number, number]

The box round all of it.

centroid[number, number]

The middle of it, which falls in the sea when the place is a chain or a crescent: landAnchor finds a point on its land.

neighborsstring[]

The codes of the regions that share a border point with it, in order.

例

import { loadDivisions } from "@johnmorrisdotca/chizu/load";
import type { ChizuRegion } from "@johnmorrisdotca/chizu";

const canada = (await loadDivisions("ca"))!;
const ontario: ChizuRegion = canada.regions.find((region) => region.code === "ON")!;
console.log(ontario.iso, ontario.name, ontario.nameJa, ontario.group, ontario.neighbors.join(" "));
// CA-ON Ontario オンタリオ州 Central MB QC
CA-ON Ontario オンタリオ州 Central MB QC

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

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

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