本文へ移動

Chizu地図

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

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

目次

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

ChizuLocalMarkerInput型

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

A picture to put on a local map, given as the caller has it. See ChizuLocalMarker for what it becomes.

インポート

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

定義

type ChizuLocalMarkerInput = {
    name?: string;
    nameJa?: string;
    id?: string;
    at: readonly [
        number,
        number
    ];
    svg: string;
    viewBox?: readonly [
        number,
        number,
        number,
        number
    ];
    metresPerUnit?: number;
    size?: readonly [
        number,
        number
    ];
    bearing?: number;
    anchor?: readonly [
        number,
        number
    ];
    class?: string | readonly string[];
};

メンバー

名前型説明
name (省略可)string | undefined

A name for it: its <title>, its label and what a screen reader hears.

nameJa (省略可)string | undefined
id (省略可)string | undefined
atreadonly [number, number]

Where its anchor goes: longitude and latitude, in degrees.

svgstring

Its picture: a whole <svg viewBox="…">…</svg>, or bare markup with viewBox given. Cleaned on the way in (no script, style sheet, image or outside reference).

viewBox (省略可)readonly [number, number, number, number] | undefined

The picture's own window, for bare markup (or to override the <svg>'s): [x, y, width, height] in the picture's units.

metresPerUnit (省略可)number | undefined

How many metres a unit of the picture is. Default 1, so a picture drawn in metres is true to size.

size (省略可)readonly [number, number] | undefined

Or how big the picture's window is on the ground, [width, height] in metres: the scale is worked out from the width (the height only checks).

bearing (省略可)number | undefined

The direction the picture's top points, in degrees clockwise from true north. Default 0.

anchor (省略可)readonly [number, number] | undefined

The point of the picture, in its own units, that sits on at. Default the middle of its window.

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

Classes for your own style: letters, digits, - and _.

例

import { localMap, type ChizuLocalMarkerInput } from "@johnmorrisdotca/chizu";

// A 100 m by 60 m pitch, drawn in metres, turned 30° east of north.
const pitch: ChizuLocalMarkerInput = {
  at: [139.7006, 35.7004],
  svg: '<svg viewBox="0 0 100 60"><rect width="100" height="60" fill="#9bd18a"/><line x1="50" y1="0" x2="50" y2="60" stroke="#fff"/></svg>',
  bearing: 30,
  name: "Pitch",
};
console.log(localMap({ centre: [139.7006, 35.7004], widthMetres: 300, markers: [pitch] }).markers.length);
// 1
1

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

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

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