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

focusRegionFitfunction

What choosing one place computes: zoom in to fit it, whatever zoom the reader was already at. null for a code the map does not hold, so a caller can tell "nothing to focus" from "fit the whole thing", which zoomToFit cannot.

Import it

import { focusRegionFit } from "@johnmorrisdotca/chizu";

Definition

function focusRegionFit(map: Frameable, code: string | number | null): { zoom: MapZoom; centre: { x: number; y: number; }; } | null

Parameters

NameTypeDescription
mapFrameable

The native map or map fields required by this signature; coordinates and region codes belong to its canvas.

codestring | number | null

The native region or country code; null clears a region selection where accepted.

Returns

{ zoom: MapZoom; centre: { x: number; y: number; }; } | null

The zoom step and centre fitting the chosen region, or null for a null or unknown region code.

Examples

import WORLD from "@johnmorrisdotca/chizu/world";
import { focusRegionFit } from "@johnmorrisdotca/chizu";

console.log(focusRegionFit(WORLD, "JP")?.zoom, focusRegionFit(WORLD, "XX"));
// 8 null
8 null

What it prints (run when this page was built)

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