localCanvasFromBox関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The local canvas that shows the ground a window on a world or country map shows, so a page can hand over from the
map to the city at the moment it has zoomed past what the map knows, with nothing jumping: at its own 1× the local map
covers the same ground as the window did. null where mapBoxMetres is.
インポート
import { localCanvasFromBox } from "@johnmorrisdotca/chizu";
定義
function localCanvasFromBox(map: Pick<ChizuMap, "projection">, box: MapBox): Required<ChizuLocalCanvas> | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
map | Pick<ChizuMap, "projection"> | A world or country map. |
box | MapBox | A window on that map. |
戻り値
Required<ChizuLocalCanvas> | null
A local canvas covering the window, or null when the map cannot be read back or the window is near a pole.
例
import WORLD from "@johnmorrisdotca/chizu/world";
import { localCanvasFromBox, projectPoint } from "@johnmorrisdotca/chizu";
const [x, y] = projectPoint(WORLD, 139.7671, 35.6812)!;
const canvas = localCanvasFromBox(WORLD, { x: x - 1, y: y - 1, width: 2, height: 2 })!;
console.log(canvas.centre.map((value) => value.toFixed(2)).join(", "), Math.round(canvas.widthMetres / 10_000) * 10, "km");
// 139.77, 35.68 70 km139.77, 35.68 70 km出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。