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

regionBoxfunction

A window tight on one region, for drawing it on its own.

Two things decide it, and getting either wrong draws a country instead of a shape. The room around the region is a fraction of that side of it, not of its longest side. And the window takes the shape of the frame it will be drawn in (aspect, how much wider than tall), because an SVG scaled to fit keeps its window's proportions and fills the rest of the frame with whatever is next to it. With both right the region fills the side that limits it, and the room left over falls on the other side, where it does what the room was for: the neighbours show in outline, so it is a place rather than a blob. Framed where it is drawn, so a region in an inset is framed there.

Import it

import { regionBox } from "@johnmorrisdotca/chizu";

Definition

function regionBox(map: Frameable, code: string | number, aspect?: number): MapBox

Parameters

NameTypeDescription
mapFrameable

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

codestring | number

The native region or country code; null clears a region selection where accepted.

aspect (optional)number

The desired window width divided by its height.

Returns

MapBox

A window tight on one region, for drawing it on its own.

Examples

import WORLD from "@johnmorrisdotca/chizu/world";
import { boxToViewBox, regionBox } from "@johnmorrisdotca/chizu";

const box = regionBox(WORLD, "IT", 4 / 3);
console.log((box.width / box.height).toFixed(3));
// 1.333
1.333

What it prints (run when this page was built)

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