zoomToFit関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The zoom step and centre that show all of these regions at once: for opening a region from its heading, which wants it filling the view and not the whole map with a few regions lit somewhere in it.
It picks the closest step whose window still holds everything, with the same room around it that a focus box leaves; a set that will not fit at 2× is shown at 1× rather than cut. Measured where the regions are drawn, so an inset's region is its box and not its true position out at sea. The room is a share of each side, and a set that cannot fit closer with the margin gets one more try at the bare shape before it is shown at 1×: the margin is what makes a fit comfortable, not what makes it a fit.
インポート
import { zoomToFit } from "@johnmorrisdotca/chizu";
定義
function zoomToFit(map: Frameable, codes: ReadonlyArray<string | number>): { zoom: MapZoom; centre: { x: number; y: number; }; }
引数
| 名前 | 型 | 説明 |
|---|---|---|
map | Frameable | The native map or map fields required by this signature; coordinates and region codes belong to its canvas. |
codes | readonly (string | number)[] | Native region codes from this map, in the requested order. |
戻り値
{ zoom: MapZoom; centre: { x: number; y: number; }; }
The zoom step and centre that show all of these regions at once: for opening a region from its heading, which wants it filling the view and not the whole map with a few regions lit somewhere in it.
例
import WORLD from "@johnmorrisdotca/chizu/world";
import { zoomToFit } from "@johnmorrisdotca/chizu";
const fit = zoomToFit(WORLD, ["GB", "IE"]);
console.log(fit.zoom, Math.round(fit.centre.x), Math.round(fit.centre.y));
// 10 58 14810 58 148出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。