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[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
places | readonly Pick<Place, "kind" | "lon" | "lat">[] | The places, as the element holds them. |
source | HereCitySource | A city list with |
options | { lang: "en" | "ja"; maxKm: number; } |
|
戻り値
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出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。