layoutCities関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Lays the names out for one draw: the cities in sight, the most important first, each named beside its dot (right, then left, above, below) where no earlier name is in the way; a city with no room is left out.
インポート
import { layoutCities } from "@johnmorrisdotca/chikyu-earth/realistic";
定義
function layoutCities(cities: readonly NamedCity[], frame: CityFrame, lang: "en" | "ja", options: CityLayoutOptions): CityName[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
cities | readonly NamedCity[] | The cities of the tiers shown, the highest rank first (see |
frame | CityFrame | Where the Earth is on the screen. |
lang | "en" | "ja" | The page's language, |
options | CityLayoutOptions | The most names, the text size and the dot's radius. |
戻り値
CityName[]
The names to show, the most important first.
例
import { layoutCities } from "@johnmorrisdotca/chikyu-earth/realistic";
const frame = { width: 300, height: 300, radius: 120, project: (lon: number, lat: number, out: { x: number; y: number }) => { out.x = 150 + (lon - 133) * 6; out.y = 150 - (lat - 36) * 6; return 1; } };
const tokyo = { id: "Q1490", name: { en: "Tokyo", ja: "東京都" }, lat: 35.7, lon: 139.7, population: 37_000_000, capital: "national" as const };
const seoul = { id: "Q8684", name: { en: "Seoul" }, lat: 37.6, lon: 127, population: 10_000_000, capital: "national" as const };
console.log(layoutCities([tokyo, seoul], frame, "en", { max: 10, size: 12, dot: 3 }).map((one) => one.text));[ 'Tokyo', 'Seoul' ]出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。