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 · Map, locator and quiz elements

readMapColorsfunction

Parse region colours, including native CSS colours with commas inside rgb()/hsl().

Import it

import { readMapColors } from "@johnmorrisdotca/chizu/element";

Also exported from: @johnmorrisdotca/chizu/element/define

Definition

function readMapColors(text: string | null): Record<string, string> | null

Parameters

NameTypeDescription
textstring | null

Comma-separated code:colour pairs; null or empty means no overrides.

Returns

Record<string, string> | null

The validated colour map, or null for malformed or unsafe values.

Examples

import { readMapColors } from "@johnmorrisdotca/chizu/element";
console.log(readMapColors("JP:#2f6b4f,GB:rgb(138,59,59)")?.JP);
console.log(readMapColors("JP:url(evil)"));
// #2f6b4f
// null
#2f6b4f
null

What it prints (run when this page was built)

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