本文へ移動

Chizu地図

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

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

目次

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

ChizuLocalMarker型

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

A picture placed on a local map: where it is on the canvas, how many canvas units a unit of the picture is, and the turn that puts its top towards its bearing (the bearing less the map's grid convergence, localConvergence).

インポート

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

定義

type ChizuLocalMarker = {
    id: string;
    name?: string;
    nameJa?: string;
    classes: string[];
    at: [
        number,
        number
    ];
    bearing: number;
    rotation: number;
    scale: number;
    anchor: [
        number,
        number
    ];
    viewBox: [
        number,
        number,
        number,
        number
    ];
    markup: string;
    bbox: [
        number,
        number,
        number,
        number
    ];
};

メンバー

名前型説明
idstring
name (省略可)string | undefined
nameJa (省略可)string | undefined
classesstring[]
at[number, number]

Where its anchor is on the canvas.

bearingnumber

The bearing it was given.

rotationnumber

The turn on the canvas, in degrees clockwise.

scalenumber

Canvas units to a unit of the picture.

anchor[number, number]

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

viewBox[number, number, number, number]

The picture's window: [x, y, width, height] in its own units.

markupstring

The cleaned markup, ready to sit in an <svg>.

bbox[number, number, number, number]

The box round the turned picture on the canvas: left, top, right, bottom.

例

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

const field = '<svg viewBox="0 0 100 50"><rect width="100" height="50"/></svg>';
const marker: ChizuLocalMarker = localMap({ centre: [139.7, 35.7], widthMetres: 400, markers: [{ at: [139.7, 35.7], svg: field, bearing: 90 }] }).markers[0]!;
console.log(marker.id, marker.scale, marker.rotation);
// marker-1 2.5 90
marker-1 2.5 90

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

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

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