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 · The data door: hand the package your own maps of the Earth or orbit data as a source with its own licence and credit, and see whose data is on the screen

SourceBooktype

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 it

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

Definition

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;
}

Members

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

Examples

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

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

What it prints (run when this page was built)

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