本文へ移動

Chikyu Earth地球

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

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

目次

リファレンス · 地球上の目印

hereCityLabels関数

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

The city for each here place, nearest first within maxKm, named in lang. A favourite is left out. A place with no city inside the limit is left out, so the page's own label stays. The lookup is the source's: this adds none.

インポート

import { hereCityLabels } from "@johnmorrisdotca/chikyu-earth/markers";

定義

function hereCityLabels(places: readonly Pick<Place, "lon" | "lat" | "kind">[], source: HereCitySource, options: { lang: "en" | "ja"; maxKm: number; }): HereCityHit[]

引数

名前型説明
placesreadonly Pick<Place, "kind" | "lon" | "lat">[]

The places, as the element holds them.

sourceHereCitySource

A city list with nearest (kuni's CitySet).

options{ lang: "en" | "ja"; maxKm: number; }

lang (en or ja) and maxKm.

戻り値

HereCityHit[]

One hit for each here place that has a city inside the limit, in the list's order.

例

import { hereCityLabels } from "@johnmorrisdotca/chikyu-earth/markers";

const paris = { id: "Q90", name: { en: "Paris", ja: "パリ" } };
const source = {
  nearest(_point: { lat: number; lon: number }, options?: { maxKm?: number }) {
    return options?.maxKm !== undefined && options.maxKm < 5 ? null : { city: paris, km: 2 };
  },
};
const places = [{ lon: 2.35, lat: 48.86, kind: "here" as const }, { lon: 4.84, lat: 45.76, kind: "favourite" as const }];
console.log(hereCityLabels(places, source, { lang: "en", maxKm: 100 })[0]?.label);
console.log(hereCityLabels(places, source, { lang: "ja", maxKm: 100 })[0]?.label);
console.log(hereCityLabels(places, source, { lang: "en", maxKm: 1 }).length);
Paris
パリ
0

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

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

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