Skip to the content

Chizu地図

Draw SVG maps, frame regions, place numbered callouts and build geography quizzes with English and Japanese names.

Chizu is the Japanese word 地図 for map. About the name

Contents

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

NameTypeDescription
mapPick<ChizuMap, "projection">

A world or country map.

boxMapBox

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 across
3300 km across

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/chizu 1.5.0.