本文へ移動

Chikyu Earth地球

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

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

目次

リファレンス · データの入口(自分で用意した地球の地図や軌道データを、ライセンスと出典つきのソースとして渡し、いま画面にあるのは誰のデータかを示します)

SourceBook型

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

A view's sources, as <chikyu-earth-realistic> and <chikyu-passes> keep them: addSource, removeSource, enableSource and ownOnly are the element's methods of the same names.

インポート

import type { SourceBook } from "@johnmorrisdotca/chikyu-earth/door";

定義

interface SourceBook {
    readonly sources: readonly DataSource[];
    addSource(source: unknown): () => void;
    removeSource(id: string): boolean;
    enableSource(id: string, on: boolean): void;
    isEnabled(id: string): boolean;
    ownOnly(on: boolean): void;
    readonly onlyOwn: boolean;
    active(): readonly DataSource[];
    mapSources(layer: MapLayer): readonly EarthMapSource[];
    elementLists(): readonly {
        id: string;
        sets: readonly ElementSet[];
    }[];
    isOwn(source: DataSource): boolean;
    get(id: string): DataSource | undefined;
    signal(id: string): AbortSignal;
    onChange(listener: () => void): () => void;
    stats(): SourceStats;
    readonly version: number;
    ready(): Promise<void>;
    dispose(): void;
}

メンバー

名前型説明
sourcesreadonly DataSource[]

The sources now in the view, in the order added (the package's own folder of tiles is not among them unless a page added it).

addSource(source: unknown): () => void

Adds a source. It throws a TypeError at once for a source validateSource refuses, an id already in the view, a kind this view cannot draw, or a map source with no layer. Returns the function that removes it.

removeSource(id: string): boolean

Removes a source by id: aborts its reads, frees its records. Returns whether there was one.

enableSource(id: string, on: boolean): void

Switches a source off (false) or on: off aborts its read and frees its records, and the source stays in the view.

isEnabled(id: string): boolean

True while a source is in the view and switched on.

ownOnly(on: boolean): void

true ignores every source that is not the package's own, at once (the attribute data="own").

onlyOwnboolean
active(): readonly DataSource[]

The sources in use: in the view, switched on, and not ignored by ownOnly.

mapSources(layer: MapLayer): readonly EarthMapSource[]

The map sources in use for a layer, the last one added first (it is the one the layer is drawn from).

elementLists(): readonly { id: string; sets: readonly ElementSet[]; }[]

The element sets of every record source in use, read so far, with the id of the source each came from, in the order added.

isOwn(source: DataSource): boolean

True for a source the package made itself.

get(id: string): DataSource | undefined

The source of this id, if it is in the view.

signal(id: string): AbortSignal

The signal of a source: it aborts when the source is removed, switched off or ignored, so what a view started for it stops.

onChange(listener: () => void): () => void

Calls listener when something changed that a view may want to draw again for: a source added, removed or switched, records read. Returns the function that stops it.

stats(): SourceStats
versionnumber

A number that changes whenever the sources in use change (a source read, switched, added or removed), so a view looks again only then.

ready(): Promise<void>

Resolves when every record source has been read.

dispose(): void

Frees everything: aborts every read and signal, frees every record. The book is not used again.

例

import { createSourceBook } from "@johnmorrisdotca/chikyu-earth/door";

const book = createSourceBook();
console.log(book.sources.length, book.active().length);
0 0

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

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

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