Skip to the content

Chizu地図

Draw SVG maps, frame regions, place numbered callouts and build geography quizzes with English and Japanese names.

Chizu is the Japanese word 地図 for map. About the name

Contents

Reference · Framing, geometry and quiz tools

ChizuRegiontype

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

Import it

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

Definition

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[];
}

Members

NameTypeDescription
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 (optional)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 (optional)string | undefined

Its name in Japanese, where there is one.

nameShortJa (optional)string | undefined

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

reading (optional)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 (optional)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 (optional)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 (optional)string[] | undefined

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

type (optional)string | undefined

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

iso3 (optional)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.

Examples

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

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/chizu 1.5.0.