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

mapRegionPiecesfunction

The region’s separate drawn pieces, including the geometry moved into its inset boxes.

Import it

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

Definition

function mapRegionPieces(region: { path: string; bbox: readonly [number, number, number, number]; }, inset: ChizuInset | readonly ChizuInset[] | null): MapPiece[]

Parameters

NameTypeDescription
region{ path: string; bbox: readonly [number, number, number, number]; }

The native region, or built-in map selector where the signature requires text.

insetChizuInset | readonly ChizuInset[] | null

The native inset placement and optional restriction to part of a region.

Returns

MapPiece[]

The region’s separate drawn pieces, including the geometry moved into its inset boxes.

Examples

import { loadDivisions } from "@johnmorrisdotca/chizu/load";
import { insetFor, mapRegionPieces } from "@johnmorrisdotca/chizu";

const us = (await loadDivisions("us"))!;
const alaska = us.regions.find((region) => region.code === "AK")!;
console.log(mapRegionPieces(alaska, insetFor(us, "AK")).length, mapRegionPieces(alaska, null)[0]!.transform);
// 1 null
1 null

What it prints (run when this page was built)

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