Skip to the content

Chikyu Earth地球

A line-drawn globe of the world's countries that turns at the Earth's own rate, with an optional realistic Earth from space and markers for any place.

Chikyu is the Japanese word 地球 for the Earth. About the name

Contents

Reference · Markers on the globe

hereCityLabelsfunction

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 it

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

Definition

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

Parameters

NameTypeDescription
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.

Returns

HereCityHit[]

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

Examples

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

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/chikyu-earth 0.51.1.