本文へ移動

Chizu地図

世界、253の国、33か国の州や県などの地域を、SVGの地図に描けます。表示する範囲を決めたり、番号付きの注記をつけたり、地理クイズを作ったりもできます。名前は今のところ英語と日本語で、スペイン語、ドイツ語、中国語にも対応する予定です。

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

目次

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

ChizuOverlay型

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

One overlay. A line runs through its points in order, unbroken across the date line: each step is taken the short way round (170 to -170 is 20 degrees east, and 350 to 10 is 20 degrees too), so a track that goes round the world is one line; give each part of a track its own line for a style of its own. A mark is a dot at a point, with an optional label; its longitude may be any number of turns round. An area is a ring of points filled (the night side), drawn as given: its longitudes must run on without a jump (170 to 190, not 170 to -170, which fills a band round the whole map), and a ring round a pole runs along its edge from -180 to 180 and back along the pole. Latitudes past a pole are held to it. Colours are CSS colours or var(--name); widths and sizes are in CSS pixels, so a small map reads as well as a large one; opacity is the area's fill opacity, 0 to 1.

インポート

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

定義

type ChizuOverlay = {
    kind: "line";
    points: readonly ChizuLatLon[];
    color?: string;
    width?: number;
    dash?: readonly number[];
    id?: string;
} | {
    kind: "mark";
    at: ChizuLatLon;
    label?: string;
    color?: string;
    size?: number;
    id?: string;
} | {
    kind: "area";
    ring: readonly ChizuLatLon[];
    color?: string;
    opacity?: number;
    id?: string;
};

例

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

const overlays: ChizuOverlay[] = [
  { kind: "line", points: [[0, 170], [10, -170]], color: "#c33", width: 2 },
  { kind: "mark", at: [35.68, 139.69], label: "Tokyo" },
];
console.log(overlays.length);
// 2
2

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

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

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