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

ChizuInsettype

A region the map draws in a box of its own, instead of where its projection put it (Alaska, Hawaii, Okinawa).

Import it

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

Definition

interface ChizuInset {
    code: string;
    box: MapBox;
    outlyingBelow?: number;
    within?: MapBox;
    magnify?: boolean;
}

Members

NameTypeDescription
codestring

The region drawn in the box.

boxMapBox

Where the box is on the map's canvas.

outlyingBelow (optional)number | undefined

Only the region's outlying islands go in the box: the pieces that begin below this line on the canvas. The rest stays where it is.

within (optional)MapBox | undefined

Only the pieces of the region that lie wholly inside this part of the canvas go in the box, where the projection put them. A region may have several boxes this way, each holding the islands of its own part of the sea: Okinawa is its main islands in one, the Sakishima Islands in another and the Daito Islands in a third, so each is drawn at a size it can be seen at. A piece no box takes stays where it is.

magnify (optional)boolean | undefined

Whether the box may make what it holds bigger than life. Off, a region is only ever shrunk to fit.

Examples

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

const japan = (await loadDivisions("jp"))!;
// Kagoshima stays where it is; only its islands south of Yakushima go in the box.
const kagoshima: ChizuInset = japan.insets.find((inset) => inset.code === "46")!;
console.log(kagoshima.box, kagoshima.outlyingBelow !== undefined);
// { x: 300, y: 160, width: 110, height: 230 } true
{ x: 300, y: 160, width: 110, height: 230 } true

What it prints (run when this page was built)

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