本文へ移動

Chizu地図

世界、253の国、33か国の州や県などの地域を、SVGの地図に描けます。表示する範囲を決めたり、番号付きの注記をつけたり、地理クイズを作ったりもできます。名前は今のところ英語と日本語で、スペイン語、ドイツ語、中国語にも対応する予定です。

「地図」は、土地や場所を図で表したものです。 名前について(英語)

目次

リファレンス · 表示範囲・形・クイズの道具

placeCities関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 { placeCities } from "@johnmorrisdotca/chizu";

定義

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[]

引数

名前型説明
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.

戻り値

ChizuCityPlaced[]

The cities named, with their place and side.

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/chizu 1.17.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。