本文へ移動

Chizu地図

SVGの地図を描き、地域を表示範囲に収め、番号付きの注記や地理クイズを英語と日本語の名前で作れます。

「地図」は、土地や場所を図で表したものです。 名前について(英語)

目次

リファレンス · 操作できる地図

mountChizu関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Puts a map in an element, to look at by touch, mouse and keyboard: drag to move it, the buttons, the wheel or a pinch to zoom in ten steps, a press to choose a region, the arrow keys and plus and minus. The world wraps: it pans east and west without stopping. Every part of it is the package's own drawing (drawChizu) in the page's own DOM, with no shadow DOM and nothing the page's style cannot reach.

インポート

import { mountChizu } from "@johnmorrisdotca/chizu/mount";

定義

function mountChizu(host: HTMLElement, initial: ChizuMountOptions): ChizuMount

引数

名前型説明
hostHTMLElement

The page or shadow-root element that receives the native map and its scoped styles.

initialChizuMountOptions

The initial native map, framing, display settings and interaction callbacks.

戻り値

ChizuMount

The mounted native map handle; call destroy when removing its host.

例

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

const mount = mountChizu(document.querySelector<HTMLElement>("#map")!, {
  map: WORLD,
  onSelect: (code) => console.log("chosen", code),
});
mount.show(["JP", "KR"]);

ソースを見るGitHub で編集@johnmorrisdotca/chizu 1.5.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。