Skip to the content

Chizu地図

Draw SVG maps of the world, its 253 countries and the regions of 33 of them, frame them, place numbered callouts and build geography quizzes, with names in English and Japanese today (Spanish, German and Chinese are planned).

Chizu is the Japanese word 地図 for map. About the name

Contents

Reference · Framing, geometry and quiz tools

placeCitiesfunction

Which cities a window names, and where each name goes: in rank order, each name on the first free side of its dot (right, left, above, below), and a city left out when none is free. On a map of one country alone, only that country's cities are named. A name never covers another name or another city's dot, and no two dots touch. Cities off the window, or on a map that cannot place a point, are left out.

Import it

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

Definition

function placeCities(map: Pick<ChizuMap, "projection"> & Partial<Pick<ChizuMap, "kind" | "regions">>, cities: readonly ChizuCity[], box: MapBox, offsets: readonly number[], options: { language: ChizuLanguage; minPopulation?: number; }): ChizuCityPlaced[]

Parameters

NameTypeDescription
mapPick<ChizuMap, "projection"> & Partial<Pick<ChizuMap, "regions" | "kind">>

The map the cities go on.

citiesreadonly ChizuCity[]

The cities to choose from.

boxMapBox

The window.

offsetsreadonly number[]

The copies of the canvas drawn across a wrapping map ([0] for one).

options{ language: ChizuLanguage; minPopulation?: number; }

The language, and an optional population floor.

Returns

ChizuCityPlaced[]

The cities named, with their place and side.

Examples

import WORLD from "@johnmorrisdotca/chizu/world";
import { placeCities, wholeMapBox } from "@johnmorrisdotca/chizu";

const placed = placeCities(WORLD, [{ id: "Q1490", name: { en: "Tokyo", ja: "東京" }, lat: 35.69, lon: 139.69, population: 14_000_000 }], wholeMapBox(WORLD), [0], { language: "ja" });
console.log(placed[0]?.name, placed[0]?.side);
// 東京 right
東京 right

What it prints (run when this page was built)

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