本文へ移動

Chizu地図

SVGの地図を描き、地域を表示範囲に収め、番号付きの注記や地理クイズを英語と日本語の名前で作れます。

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

目次

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

ChizuInset型

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

A region the map draws in a box of its own, instead of where its projection put it (Alaska, Hawaii, Okinawa).

インポート

import type { ChizuInset } from "@johnmorrisdotca/chizu";

定義

interface ChizuInset {
    code: string;
    box: MapBox;
    outlyingBelow?: number;
    within?: MapBox;
    magnify?: boolean;
}

メンバー

名前型説明
codestring

The region drawn in the box.

boxMapBox

Where the box is on the map's canvas.

outlyingBelow (省略可)number | undefined

Only the region's outlying islands go in the box: the pieces that begin below this line on the canvas. The rest stays where it is.

within (省略可)MapBox | undefined

Only the pieces of the region that lie wholly inside this part of the canvas go in the box, where the projection put them. A region may have several boxes this way, each holding the islands of its own part of the sea: Okinawa is its main islands in one, the Sakishima Islands in another and the Daito Islands in a third, so each is drawn at a size it can be seen at. A piece no box takes stays where it is.

magnify (省略可)boolean | undefined

Whether the box may make what it holds bigger than life. Off, a region is only ever shrunk to fit.

例

import { loadDivisions } from "@johnmorrisdotca/chizu/load";
import type { ChizuInset } from "@johnmorrisdotca/chizu";

const japan = (await loadDivisions("jp"))!;
// Kagoshima stays where it is; only its islands south of Yakushima go in the box.
const kagoshima: ChizuInset = japan.insets.find((inset) => inset.code === "46")!;
console.log(kagoshima.box, kagoshima.outlyingBelow !== undefined);
// { x: 300, y: 160, width: 110, height: 230 } true
{ x: 300, y: 160, width: 110, height: 230 } true

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

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

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