本文へ移動

Chizu地図

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

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

目次

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

runwaysSvg関数

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

The runways a window shows as SVG, for drawChizu: a <g class="cz-runways"> holding a <line class="cz-runway" data-airport="…"> for each runway of each airport in ports that the window's tier shows, the line between its two ends with the stroke as wide as the runway is on the ground (no thinner than a hairline). A runway shorter than 1.2% of the window's width is left out, so none is drawn until the window shows a few hundred kilometres. Empty when none is.

インポート

import { runwaysSvg } from "@johnmorrisdotca/chizu";

定義

function runwaysSvg(map: Pick<ChizuMap, "projection">, ports: readonly ChizuPort[], runways: ChizuRunways, box: MapBox, offsets: readonly number[], options: ChizuPortOptions): string

引数

名前型説明
mapPick<ChizuMap, "projection">

The map the runways go on.

portsreadonly ChizuPort[]

The airports to draw the runways of (a harbour is passed over).

runwaysReadonly<Record<string, readonly ChizuRunway[]>>

The runways, by airport id.

boxMapBox

The window.

offsetsreadonly number[]

The copies of the canvas across a wrapping map ([0] for one).

optionsChizuPortOptions

The tier (portOptions's).

戻り値

string

The SVG text, or "".

例

import { localMap, runwaysSvg, wholeMapBox, type ChizuPort } from "@johnmorrisdotca/chizu";

const map = localMap({ centre: [139.78, 35.55], widthMetres: 6000 });
const haneda: ChizuPort = { id: "hnd", kind: "airport", name: { en: "Haneda" }, country: "JP", lat: 35.55, lon: 139.78, tier: 1 };
const svg = runwaysSvg(map, [haneda], { hnd: [[139.77, 35.54, 139.79, 35.56, 60]] }, wholeMapBox(map), [0], {});
console.log(svg.includes('data-airport="hnd"'));
// true
true

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

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

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