本文へ移動

Chizu地図

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

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

目次

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

MapPiece型

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

How one region is drawn: usually in one piece, where it is.

A region in a box of its own is that one piece moved into the box. A region with outlying islands in a box - a prefecture whose far islands belong down their own chain rather than in the sea off the mainland - is two: the region where it is, and the islands in their frame. Both carry the same region, so whichever piece is clicked is the same place.

インポート

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

定義

type MapPiece = {
    d: string;
    transform: InsetTransform | null;
};

メンバー

名前型説明
dstring
transformInsetTransform | null

例

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

const japan = (await loadDivisions("jp"))!;
const tokyo = japan.regions.find((region) => region.code === "13")!;
const pieces: MapPiece[] = mapRegionPieces(tokyo, insetFor(japan, "13"));
console.log(pieces.map((piece) => (piece.transform ? "in its box" : "in place")).join(", "));
// in place, in its box
in place, in its box

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

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

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