Reference · Framing, geometry and quiz tools
windowKilometresfunction
How many kilometres of ground the window shows from side to side, at its middle; null for a map whose canvas
cannot be read back to longitude and latitude (a country's regions).
Import it
import { windowKilometres } from "@johnmorrisdotca/chizu";
Definition
function windowKilometres(map: Pick<ChizuMap, "projection">, box: MapBox): number | null
Parameters
| Name | Type | Description |
|---|---|---|
map | Pick<ChizuMap, "projection"> | The map whose canvas the window is on. |
box | MapBox | The window. |
Returns
number | null
Kilometres across, or null.
Examples
import WORLD from "@johnmorrisdotca/chizu/world";
import { windowKilometres, wholeMapBox } from "@johnmorrisdotca/chizu";
console.log(Math.round(windowKilometres(WORLD, wholeMapBox(WORLD))! / 1000) > 30);
// truetrueWhat it prints (run when this page was built)