本文へ移動

Chizu地図

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

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

目次

リファレンス · 表示範囲・形・クイズの道具

placeCallouts関数

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

Places every circle in the open space around the map.

The hardest region chooses first: the one whose nearest room is furthest away has nothing else to take, and a coastal region that picked early would leave an inland one nowhere to go. Then the arrangement is walked downhill - each circle offered a better place, each crossing pair offered each other's - until nothing improves.

インポート

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

定義

function placeCallouts<T>(entries: ReadonlyArray<{ item: T; centroid: readonly [number, number]; }>, radius: number, box: MapBox, keepOut?: CalloutKeepOut, land?: readonly CalloutLand[], options?: { polish?: boolean; }): Array<HandleSpot & { item: T; }>

引数

名前型説明
entriesreadonly { item: T; centroid: readonly [number, number]; }[]

Native places to order or lay out.

radiusnumber

The circle or label radius in native map units.

boxMapBox

The window in native map units, or the inset destination specified by this signature.

keepOut (省略可)CalloutKeepOut

The native frame areas reserved against callout placement.

land (省略可)readonly CalloutLand[]

Native land geometry or land obstacles that labels must avoid.

options (省略可){ polish?: boolean; }

The optional native drawing, matching, layout or quiz settings described by this signature.

戻り値

(HandleSpot & { item: T; })[]

Places every circle in the open space around the map.

例

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

const spots = placeCallouts([{ item: "a", centroid: [40, 50] }, { item: "b", centroid: [60, 50] }], 4, { x: 0, y: 0, width: 100, height: 100 });
console.log(spots.map((spot) => spot.item).join(" "));
// a b
a b

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

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

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