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

mainlandBoundsfunction

The box around a region as anyone would picture it: its largest outline, and whatever else is close enough to belong in the same glance.

A region's own bounds are its whole reach, which is the wrong frame for a picture of it. Kagoshima's run from the foot of Kyushu to the Amami islands, three hundred kilometres south, so the prefecture drew at a quarter of the size it could with two specks under it.

reach is how far a ring may sit from the mainland and still be framed with it, as a share of the mainland's own longer side - so a near island comes along and a far one is left out of the picture, which is where the map itself now draws it anyway.

Import it

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

Definition

function mainlandBounds(rings: readonly MapRing[], reach?: number): [number, number, number, number] | null

Parameters

NameTypeDescription
ringsreadonly MapRing[]

Closed outline rings in native map units.

reach (optional)number

The maximum native map-unit search distance.

Returns

[number, number, number, number] | null

Bounds around the mainland and nearby pieces, or null when no ring exists.

Examples

import WORLD from "@johnmorrisdotca/chizu/world";
import { mainlandBounds, mapOutlines } from "@johnmorrisdotca/chizu";

const index = WORLD.regions.findIndex((region) => region.code === "FR");
// France on the world reaches French Guiana; its mainland does not.
const mainland = mainlandBounds(mapOutlines(WORLD)[index]!.rings)!;
console.log(mainland[3] - mainland[1] < WORLD.regions[index]!.bbox[3] - WORLD.regions[index]!.bbox[1]);
// true
true

What it prints (run when this page was built)

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