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

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

NameTypeDescription
mapPick<ChizuMap, "projection">

The world or country map to hand over to.

localPick<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 true
true true

What it prints (run when this page was built)

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