リファレンス · データの入口(自分で用意した地球の地図や軌道データを、ライセンスと出典つきのソースとして渡し、いま画面にあるのは誰のデータかを示します)
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;
}
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
sources | readonly 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 |
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 ( |
isEnabled | (id: string): boolean | True while a source is in the view and switched on. |
ownOnly | (on: boolean): void |
|
onlyOwn | boolean | |
active | (): readonly DataSource[] | The sources in use: in the view, switched on, and not ignored by |
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 |
stats | (): SourceStats | |
version | number | 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出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。