本文へ移動

Chizu地図

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

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

目次

リファレンス · SVGで地図を描く

drawLocal関数

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

A local map as SVG text: the ground, the caller's shapes in the order given (areas, lines, points), the pictures at their places, true size and bearing, and optionally names, numbered callouts, a scale bar in metres and the credit lines. A string, like drawChizu's, so it works on a server, in a build step and in innerHTML; the look is CHIZU_STYLE and CHIZU_LOCAL_STYLE (style: true carries both inside).

Nothing is fetched. A unit of the canvas is data-metres-per-unit metres, written on the <svg>, and the viewBox is in those units, so the window box is chosen with the same zoomBox, focusBox and regionBox as any map. The pictures are the caller's own markup, cleaned of scripts and outside references (ChizuLocalMarkerInput).

インポート

import { drawLocal } from "@johnmorrisdotca/chizu/draw";

定義

function drawLocal(map: ChizuLocalMap, options?: ChizuLocalDrawOptions): string

引数

名前型説明
mapChizuLocalMap

The local map to draw, from localMap.

options (省略可)ChizuLocalDrawOptions

What to draw besides the shapes: labels, callouts, the scale bar, language and style.

戻り値

string

The drawing, as SVG text.

例

import { drawLocal } from "@johnmorrisdotca/chizu/draw";
import { localMap } from "@johnmorrisdotca/chizu";

const map = localMap({
  centre: [139.7006, 35.7004],
  widthMetres: 400,
  data: { type: "Feature", id: "hall", properties: { name: "Hall", kind: "building" }, geometry: { type: "Polygon", coordinates: [[[139.6998, 35.6999], [139.7014, 35.6999], [139.7014, 35.7009], [139.6998, 35.7009], [139.6998, 35.6999]]] } },
  credits: ["Shapes made up for this example"],
});
const svg = drawLocal(map, { labels: true, style: true });
console.log(svg.startsWith("<svg"), svg.includes('data-type="building"'), svg.includes("Shapes made up"));
// true true true
true true true

出力(このページを作ったときに実行した結果)

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

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