Reference · Map, locator and quiz elements
ChizuElementOptionstype
Options that require host code rather than an HTML attribute. The existing mounted-map options stay available.
Import it
import type { ChizuElementOptions } from "@johnmorrisdotca/chizu/element";
Also exported from: @johnmorrisdotca/chizu/element/define
Definition
type ChizuElementOptions = Partial<ChizuMountOptions> & {
data?: Readonly<Record<string, number>>;
capital?: boolean;
};
Members
| Name | Type | Description |
|---|---|---|
map (optional) | MapData | undefined | The map to show: |
language (optional) | ChizuLanguage | undefined | The language of the names and of the buttons. Default: the page's |
zoom (optional) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | undefined | The zoom step to start at (1 to 10). Default 1. |
tones (optional) | Readonly<Record<string, string>> | undefined | Tones by code ( |
colors (optional) | Readonly<Record<string, string>> | undefined | A colour for each region by code ( |
callouts (optional) | readonly string[] | Omit<CalloutRequest, "box"> | undefined | Numbered callouts ( |
labels (optional) | boolean | readonly string[] | undefined | Print names on the land. |
selected (optional) | string | null | undefined | The chosen region's code, or null. |
fit (optional) | boolean | undefined | Zoom in on a region when it is chosen. Default true. |
selectable (optional) | boolean | undefined | Whether pressing a region chooses it. Off, a press does nothing and the map is only looked at (a quiz that asks the question itself). Default true. |
controls (optional) | boolean | undefined | Show the zoom buttons and the zoom level. Default true. |
onSelect (optional) | ((code: string | null) => void) | undefined | A region was pressed (or its number): its code. Pressing the chosen one again passes null. |
detail (optional) | MapData | (() => Promise<MapData>) | undefined | A finer drawing of the same map, drawn from |
detailFrom (optional) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | undefined | The zoom step the finer drawing starts at. Default 4. |
onView (optional) | ((view: ChizuView) => void) | undefined | The view changed: after a zoom, and when a drag ends. |
features (optional) | readonly ChizuFeatureChoice[] | undefined | Which named features to draw ( |
featureLayer (optional) | ChizuFeatureLayer | ((mapId: string) => Promise<ChizuFeatureLayer | null>) | null | undefined | The map's named features: a layer ( |
featureLabels (optional) | boolean | undefined | Print the features' names. Default true. |
data (optional) | Readonly<Record<string, number>> | undefined | Finite figures keyed by a region's code or ISO code, drawn in five shades. |
capital (optional) | boolean | undefined | Add capital markers; false hides them even when all features are chosen. Defaults to true for map/locator embeds; quiz feature choices stay unchanged. |
Examples
import { ChizuMapElement, type ChizuElementOptions } from "@johnmorrisdotca/chizu/element";
const options: ChizuElementOptions = { controls: false, data: { JP: 10 }, colors: { JP: "#2f6b4f" }, capital: false };
const map = new ChizuMapElement();
map.options = options;
document.body.append(map);