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; }>
引数
| 名前 | 型 | 説明 |
|---|---|---|
entries | readonly { item: T; centroid: readonly [number, number]; }[] | Native places to order or lay out. |
radius | number | The circle or label radius in native map units. |
box | MapBox | 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 ba b出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。