Reference · Framing, geometry and quiz tools
mapBoxMetresfunction
How many metres of ground a window on a world or country map shows, across and down: the number to compare with a
city's size when deciding that a map has been zoomed past what Natural Earth can say and a local map should take
over. null for a map whose canvas cannot be read back to longitude and latitude (a country's regions).
Import it
import { mapBoxMetres } from "@johnmorrisdotca/chizu";
Definition
function mapBoxMetres(map: Pick<ChizuMap, "projection">, box: MapBox): { width: number; height: number; } | null
Parameters
| Name | Type | Description |
|---|---|---|
map | Pick<ChizuMap, "projection"> | A world or country map. |
box | MapBox | A window on that map. |
Returns
{ width: number; height: number; } | null
The width and height of the window in metres, or null when the map cannot be read back to longitude and latitude.
Examples
import WORLD from "@johnmorrisdotca/chizu/world";
import { mapBoxMetres, zoomBox } from "@johnmorrisdotca/chizu";
const window = zoomBox(WORLD, 10, { x: 457.5, y: 212.5 });
console.log(Math.round(mapBoxMetres(WORLD, window)!.width / 100_000) * 100, "km across");
// 3300 km across3300 km acrossWhat it prints (run when this page was built)