本文へ移動

Chikyu Earth地球

世界の国の輪郭を線で描いた地球儀です。地球と同じ速さで回ります。宇宙から見たような地球と、好きな場所の目印も使えます。

「地球」(ちきゅう) は、私たちが住む星の名前です。 名前について(英語)

目次

リファレンス · リアルな地球の計算部分

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[]

引数

名前型説明
citiesreadonly NamedCity[]

The cities of the tiers shown, the highest rank first (see cityRank).

frameCityFrame

Where the Earth is on the screen.

lang"en" | "ja"

The page's language, en or ja.

optionsCityLayoutOptions

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' ]

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

ソースを見るGitHub で編集@johnmorrisdotca/chikyu-earth 0.51.1 のソースから作成しました。

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