Reference · Framing, geometry and quiz tools
mapBoxFromLocalfunction
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 it
import { mapBoxFromLocal } from "@johnmorrisdotca/chizu";
Definition
function mapBoxFromLocal(map: Pick<ChizuMap, "projection">, local: Pick<ChizuMap, "projection" | "width" | "height">, box?: MapBox): MapBox | null
Parameters
| Name | Type | Description |
|---|---|---|
map | Pick<ChizuMap, "projection"> | The world or country map to hand over to. |
local | Pick<ChizuMap, "width" | "height" | "projection"> | The local map to hand back from. |
box (optional) | MapBox | undefined | A window on the local map; the whole canvas when left out. |
Returns
MapBox | null
The window on the world or country map, or null where the local map or the map cannot be read back.
Examples
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 truetrue trueWhat it prints (run when this page was built)