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

placeCalloutsfunction

Places every circle in the open space around the map.

The hardest region chooses first: the one whose nearest room is furthest away has nothing else to take, and a coastal region that picked early would leave an inland one nowhere to go. Then the arrangement is walked downhill - each circle offered a better place, each crossing pair offered each other's - until nothing improves.

Import it

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

Definition

function placeCallouts<T>(entries: ReadonlyArray<{ item: T; centroid: readonly [number, number]; }>, radius: number, box: MapBox, keepOut?: CalloutKeepOut, land?: readonly CalloutLand[], options?: { polish?: boolean; }): Array<HandleSpot & { item: T; }>

Parameters

NameTypeDescription
entriesreadonly { item: T; centroid: readonly [number, number]; }[]

Native places to order or lay out.

radiusnumber

The circle or label radius in native map units.

boxMapBox

The window in native map units, or the inset destination specified by this signature.

keepOut (optional)CalloutKeepOut

The native frame areas reserved against callout placement.

land (optional)readonly CalloutLand[]

Native land geometry or land obstacles that labels must avoid.

options (optional){ polish?: boolean; }

The optional native drawing, matching, layout or quiz settings described by this signature.

Returns

(HandleSpot & { item: T; })[]

Places every circle in the open space around the map.

Examples

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

const spots = placeCallouts([{ item: "a", centroid: [40, 50] }, { item: "b", centroid: [60, 50] }], 4, { x: 0, y: 0, width: 100, height: 100 });
console.log(spots.map((spot) => spot.item).join(" "));
// a b
a b

What it prints (run when this page was built)

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