本文へ移動

Chizu地図

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

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

目次

リファレンス · 地図と地物を読み込む

loadFeatures関数

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

The named features of a map (its seas, lakes, rivers, landforms and peaks), drawn on its own canvas, by the map or its id: a file of its own, fetched only when asked for. null for a map that has none. Pass it to drawChizu and mountChizu as featureLayer, with features: ["water"] (or any group or kind) to draw them; mountChizu also takes this function itself, and fetches each map's layer the first time it is shown.

インポート

import { loadFeatures } from "@johnmorrisdotca/chizu/load";

定義

function loadFeatures(map: string | Pick<ChizuMap, "id">): Promise<ChizuFeatureLayer | null>

引数

名前型説明
mapstring | Pick<ChizuMap, "id">

The native map or map fields required by this signature; coordinates and region codes belong to its canvas.

戻り値

Promise<ChizuFeatureLayer | null>

The matching feature layer, or null when the requested map has no built-in layer.

例

import { loadFeatures } from "@johnmorrisdotca/chizu/load";

const japan = (await loadFeatures("divisions-jp"))!;
const seto = japan.features.find((one) => one.nameJa === "瀬戸内海")!;
console.log(japan.map, seto.name, seto.kind, seto.reading, await loadFeatures("divisions-xx"));
// divisions-jp Seto Inland Sea sea せとないかい null
divisions-jp Seto Inland Sea sea せとないかい null

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

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

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