本文へ移動

Chizu地図

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

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

目次

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

mapBoxFromLocal関数

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

The window on a world or country map that a local map covers, the way back from the city: the smallest window that holds the ground of the local window (all of the canvas unless box is given). null where the map cannot be read back to longitude and latitude.

インポート

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

定義

function mapBoxFromLocal(map: Pick<ChizuMap, "projection">, local: Pick<ChizuMap, "projection" | "width" | "height">, box?: MapBox): MapBox | null

引数

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

The world or country map to hand over to.

localPick<ChizuMap, "width" | "height" | "projection">

The local map to hand back from.

box (省略可)MapBox | undefined

A window on the local map; the whole canvas when left out.

戻り値

MapBox | null

The window on the world or country map, or null where the local map or the map cannot be read back.

例

import WORLD from "@johnmorrisdotca/chizu/world";
import { localMap, mapBoxFromLocal } from "@johnmorrisdotca/chizu";

const city = localMap({ centre: [139.7671, 35.6812], widthMetres: 20_000 });
const window = mapBoxFromLocal(WORLD, city)!;
console.log(window.width < 5, window.x < 457.5 && 457.5 < window.x + window.width);
// true true
true true

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

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

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