本文へ移動

Chizu地図

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

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

目次

リファレンス · SVGで地図を描く

ChizuLocalDrawOptions型

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

What a drawing of a local map shows beyond the shapes. Every part is optional.

インポート

import type { ChizuLocalDrawOptions } from "@johnmorrisdotca/chizu/draw";

定義

type ChizuLocalDrawOptions = {
    box?: MapBox;
    language?: ChizuLanguage;
    label?: string;
    style?: boolean;
    styles?: Readonly<Record<string, ChizuLocalStyle>>;
    tones?: Readonly<Record<string, string>>;
    labels?: boolean | readonly string[];
    callouts?: readonly string[] | Omit<CalloutRequest, "box">;
    interactive?: boolean;
    markers?: boolean;
    scaleBar?: boolean;
    credits?: readonly string[];
    naturalEarth?: boolean;
};

メンバー

名前型説明
box (省略可)MapBox | undefined

The window to show, in the canvas's units (as zoomBox, focusBox and regionBox frame a local map too). Default: the whole canvas.

language (省略可)ChizuLanguage | undefined
label (省略可)string | undefined

What a screen reader hears of the drawing, instead of "Map of {name}".

style (省略可)boolean | undefined

Put CHIZU_STYLE and CHIZU_LOCAL_STYLE inside, so the drawing stands alone as an image.

styles (省略可)Readonly<Record<string, ChizuLocalStyle>> | undefined

The look of a shape, by its kind (water), a class it has, or its id; those that apply are merged in that order, the id last.

tones (省略可)Readonly<Record<string, string>> | undefined

A tone for each shape, by id, as drawChizu's tones.

labels (省略可)boolean | readonly string[] | undefined

Print the names: all that fit, or just these ids.

callouts (省略可)readonly string[] | Omit<CalloutRequest, "box"> | undefined

Numbered circles with leader lines to these ids (shapes, pictures), placed by layoutCallouts in the open ground.

interactive (省略可)boolean | undefined

Give every shape and picture its data-code as a thing to press, with role="button" and tabindex="-1".

markers (省略可)boolean | undefined

Draw the pictures. Default true.

scaleBar (省略可)boolean | undefined

A scale bar in metres. Default true.

credits (省略可)readonly string[] | undefined

More credit lines, after the map's own.

naturalEarth (省略可)boolean | undefined

Begin the credit with chizu's own: the outlines are Natural Earth's (public domain). Say so when the drawing goes beside or over one of its maps. Default false.

例

import { drawLocal, type ChizuLocalDrawOptions } from "@johnmorrisdotca/chizu/draw";
import { localMap } from "@johnmorrisdotca/chizu";

const options: ChizuLocalDrawOptions = { style: true, scaleBar: true, credits: ["Shapes made up for this example"] };
console.log(drawLocal(localMap({ centre: [139.7, 35.7], widthMetres: 500 }), options).includes("Shapes made up"));
// true
true

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

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

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