canvas-globe 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +76 -4
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/codemeta.json +1 -1
- package/dist/canvas-globe.umd.js +182 -6
- package/package.json +34 -2
- package/src/charts.js +458 -0
- package/src/controls.js +187 -0
- package/src/data/places.js +5 -0
- package/src/fx/effects/ambient.js +355 -0
- package/src/fx/effects/data.js +438 -0
- package/src/fx/effects/entrances.js +111 -0
- package/src/fx/effects/interaction.js +850 -0
- package/src/fx/effects/scene.js +571 -0
- package/src/fx/effects/transitions.js +209 -0
- package/src/fx/index.js +52 -0
- package/src/fx/pointer.js +94 -0
- package/src/fx/runtime.js +161 -0
- package/src/geo-globe.js +170 -4
- package/src/license.js +11 -1
- package/src/places.js +97 -0
- package/src/recipes.js +188 -0
- package/src/version.js +1 -1
- package/types/charts.d.ts +82 -0
- package/types/controls.d.ts +54 -0
- package/types/fx-interaction.d.ts +16 -0
- package/types/fx.d.ts +313 -0
- package/types/index.d.ts +48 -0
- package/types/places.d.ts +43 -0
- package/types/recipes.d.ts +54 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { GeoGlobe } from "./index";
|
|
2
|
+
|
|
3
|
+
/** Unbinds a control and restores whatever it changed. */
|
|
4
|
+
export type Unbind = () => void;
|
|
5
|
+
|
|
6
|
+
/** What a search resolves to: a coordinate, or a country to frame. */
|
|
7
|
+
export interface PlaceHit {
|
|
8
|
+
lon?: number;
|
|
9
|
+
lat?: number;
|
|
10
|
+
label?: string;
|
|
11
|
+
shape?: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare function searchAndFly(
|
|
15
|
+
globe: GeoGlobe,
|
|
16
|
+
input: HTMLInputElement,
|
|
17
|
+
options?: {
|
|
18
|
+
zoom?: number;
|
|
19
|
+
/** Your own `{ "Ahmedabad": [72.58, 23.03] }` table. */
|
|
20
|
+
gazetteer?: Record<string, [number, number] | { lon: number; lat: number }>;
|
|
21
|
+
/** Async resolver for anything the bundled data cannot reach. */
|
|
22
|
+
source?: (query: string) => PlaceHit | PlaceHit[] | null | Promise<PlaceHit | PlaceHit[] | null>;
|
|
23
|
+
minLength?: number;
|
|
24
|
+
onMatch?: (hit: PlaceHit) => void;
|
|
25
|
+
onMiss?: (query: string) => void;
|
|
26
|
+
}
|
|
27
|
+
): Unbind;
|
|
28
|
+
|
|
29
|
+
export declare function timelineBrush(
|
|
30
|
+
globe: GeoGlobe,
|
|
31
|
+
slider: HTMLInputElement,
|
|
32
|
+
options?: {
|
|
33
|
+
field?: string;
|
|
34
|
+
onChange?: (shown: unknown[], upTo: Date) => void;
|
|
35
|
+
}
|
|
36
|
+
): Unbind;
|
|
37
|
+
|
|
38
|
+
export declare function thresholdFilter(
|
|
39
|
+
globe: GeoGlobe,
|
|
40
|
+
slider: HTMLInputElement,
|
|
41
|
+
options?: {
|
|
42
|
+
field?: string;
|
|
43
|
+
onChange?: (shown: unknown[], cutoff: number) => void;
|
|
44
|
+
}
|
|
45
|
+
): Unbind;
|
|
46
|
+
|
|
47
|
+
export declare function crossfilter(
|
|
48
|
+
globe: GeoGlobe,
|
|
49
|
+
container: HTMLElement,
|
|
50
|
+
options?: {
|
|
51
|
+
attribute?: string;
|
|
52
|
+
active?: string;
|
|
53
|
+
}
|
|
54
|
+
): Unbind;
|
package/types/fx.d.ts
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/** Type declarations for `canvas-globe/fx`. */
|
|
2
|
+
import type { CountryShape, GeoGlobe, GlobeEffect } from "./index.js";
|
|
3
|
+
|
|
4
|
+
export interface Coordinate {
|
|
5
|
+
lon: number;
|
|
6
|
+
lat: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* -------------------------------- effects -------------------------------- */
|
|
10
|
+
|
|
11
|
+
export declare function particleAssemble(options?: {
|
|
12
|
+
duration?: number; hold?: number; color?: string; spacing?: number; size?: number; seed?: number;
|
|
13
|
+
}): GlobeEffect;
|
|
14
|
+
|
|
15
|
+
export declare function radarSweep(options?: {
|
|
16
|
+
duration?: number; hold?: number; color?: string;
|
|
17
|
+
}): GlobeEffect;
|
|
18
|
+
|
|
19
|
+
export declare function markerCascade(options?: {
|
|
20
|
+
duration?: number; hold?: number; color?: string;
|
|
21
|
+
}): GlobeEffect;
|
|
22
|
+
|
|
23
|
+
export declare function scanlines(options?: {
|
|
24
|
+
duration?: number; color?: string; gap?: number; strength?: number;
|
|
25
|
+
}): GlobeEffect;
|
|
26
|
+
|
|
27
|
+
export declare function breathe(options?: {
|
|
28
|
+
duration?: number; color?: string; strength?: number;
|
|
29
|
+
}): GlobeEffect;
|
|
30
|
+
|
|
31
|
+
export declare function lightTrails(options?: {
|
|
32
|
+
duration?: number; fade?: number; strength?: number;
|
|
33
|
+
}): GlobeEffect;
|
|
34
|
+
|
|
35
|
+
export declare function torch(options?: {
|
|
36
|
+
radius?: number; darkness?: number; ring?: boolean;
|
|
37
|
+
}): GlobeEffect;
|
|
38
|
+
|
|
39
|
+
export declare function meshGradient(options?: {
|
|
40
|
+
duration?: number; colors?: string[]; background?: string;
|
|
41
|
+
}): GlobeEffect;
|
|
42
|
+
|
|
43
|
+
export declare function cityLights(options?: { duration?: number; warm?: string }): GlobeEffect;
|
|
44
|
+
|
|
45
|
+
export declare function starfield(options?: {
|
|
46
|
+
duration?: number; layers?: number; per?: number; seed?: number;
|
|
47
|
+
}): GlobeEffect;
|
|
48
|
+
|
|
49
|
+
export declare function shineSweep(options?: {
|
|
50
|
+
duration?: number; width?: number; strength?: number;
|
|
51
|
+
}): GlobeEffect;
|
|
52
|
+
|
|
53
|
+
export declare function glassSphere(options?: {
|
|
54
|
+
tint?: string; rim?: number; gloss?: number;
|
|
55
|
+
}): GlobeEffect;
|
|
56
|
+
|
|
57
|
+
export declare function neonFlicker(options?: {
|
|
58
|
+
duration?: number; color?: string; strength?: number; seed?: number;
|
|
59
|
+
}): GlobeEffect;
|
|
60
|
+
|
|
61
|
+
export declare function arcLaunch(options?: {
|
|
62
|
+
from?: Coordinate;
|
|
63
|
+
to?: Coordinate[];
|
|
64
|
+
duration?: number;
|
|
65
|
+
hold?: number;
|
|
66
|
+
color?: string;
|
|
67
|
+
lift?: number;
|
|
68
|
+
steps?: number;
|
|
69
|
+
}): GlobeEffect;
|
|
70
|
+
|
|
71
|
+
export declare function spikesRising(options?: {
|
|
72
|
+
duration?: number; hold?: number; height?: number; width?: number; color?: string;
|
|
73
|
+
}): GlobeEffect;
|
|
74
|
+
|
|
75
|
+
export declare function pinDrop(options?: {
|
|
76
|
+
duration?: number; hold?: number; color?: string; drop?: number; size?: number;
|
|
77
|
+
}): GlobeEffect;
|
|
78
|
+
|
|
79
|
+
export declare function orbitSubject(options?: {
|
|
80
|
+
at?: Coordinate; duration?: number; lon?: number; lat?: number;
|
|
81
|
+
}): GlobeEffect;
|
|
82
|
+
|
|
83
|
+
export declare function markerBloom(options?: {
|
|
84
|
+
duration?: number; ring?: string; dot?: string; reach?: number;
|
|
85
|
+
}): GlobeEffect;
|
|
86
|
+
|
|
87
|
+
/* ------------------------- transitions and camera ------------------------- */
|
|
88
|
+
|
|
89
|
+
export declare function trimPaths(options?: {
|
|
90
|
+
from?: Coordinate;
|
|
91
|
+
to?: Coordinate[];
|
|
92
|
+
duration?: number;
|
|
93
|
+
hold?: number;
|
|
94
|
+
steps?: number;
|
|
95
|
+
hue?: number;
|
|
96
|
+
width?: number;
|
|
97
|
+
}): GlobeEffect;
|
|
98
|
+
|
|
99
|
+
export declare function liquidWipe(options?: {
|
|
100
|
+
duration?: number; hold?: number; lobes?: number; wobble?: number;
|
|
101
|
+
}): GlobeEffect;
|
|
102
|
+
|
|
103
|
+
export declare function matchCut(options?: {
|
|
104
|
+
duration?: number; from?: Coordinate; to?: Coordinate; cycles?: number; maxZoom?: number;
|
|
105
|
+
fromLabel?: string; toLabel?: string; color?: string;
|
|
106
|
+
}): GlobeEffect;
|
|
107
|
+
|
|
108
|
+
export declare function dropFromOrbit(options?: {
|
|
109
|
+
duration?: number; hold?: number; at?: Coordinate; fromZoom?: number; toZoom?: number;
|
|
110
|
+
}): GlobeEffect;
|
|
111
|
+
|
|
112
|
+
export declare function dayNightSweep(options?: {
|
|
113
|
+
duration?: number; start?: number;
|
|
114
|
+
}): GlobeEffect;
|
|
115
|
+
|
|
116
|
+
/* --------------------------------- scene --------------------------------- */
|
|
117
|
+
|
|
118
|
+
export declare function mapUnfold(options?: {
|
|
119
|
+
duration?: number; hold?: number; fill?: string; stroke?: string; background?: string;
|
|
120
|
+
}): GlobeEffect;
|
|
121
|
+
|
|
122
|
+
export declare function firework(options?: {
|
|
123
|
+
at?: Coordinate;
|
|
124
|
+
duration?: number;
|
|
125
|
+
hold?: number;
|
|
126
|
+
sparks?: number;
|
|
127
|
+
rise?: number;
|
|
128
|
+
seed?: number;
|
|
129
|
+
colors?: string[];
|
|
130
|
+
}): GlobeEffect;
|
|
131
|
+
|
|
132
|
+
export declare function glitch(options?: {
|
|
133
|
+
duration?: number; slices?: number; spread?: number; seed?: number;
|
|
134
|
+
}): GlobeEffect;
|
|
135
|
+
|
|
136
|
+
export declare function lowerThird(options?: {
|
|
137
|
+
title?: string; subtitle?: string; duration?: number; hold?: number; accent?: string;
|
|
138
|
+
}): GlobeEffect;
|
|
139
|
+
|
|
140
|
+
export declare function splitFlap(options?: {
|
|
141
|
+
to?: number;
|
|
142
|
+
duration?: number;
|
|
143
|
+
hold?: number;
|
|
144
|
+
caption?: string;
|
|
145
|
+
digits?: number;
|
|
146
|
+
accent?: string;
|
|
147
|
+
seed?: number;
|
|
148
|
+
}): GlobeEffect;
|
|
149
|
+
|
|
150
|
+
export declare function textOnCircle(options?: {
|
|
151
|
+
text?: string; duration?: number; color?: string; size?: number; offset?: number;
|
|
152
|
+
}): GlobeEffect;
|
|
153
|
+
|
|
154
|
+
export declare function countryMatte(options?: {
|
|
155
|
+
country?: string; duration?: number; stops?: string[]; outline?: string;
|
|
156
|
+
}): GlobeEffect;
|
|
157
|
+
|
|
158
|
+
export declare function ghostTrail(options?: {
|
|
159
|
+
duration?: number; hold?: number; ghosts?: number; color?: string;
|
|
160
|
+
}): GlobeEffect;
|
|
161
|
+
|
|
162
|
+
/** Advances particles from the previous frame; reproduces in sequential order. */
|
|
163
|
+
export declare function windField(options?: {
|
|
164
|
+
count?: number; seed?: number; speed?: number; life?: number; fade?: number;
|
|
165
|
+
}): GlobeEffect;
|
|
166
|
+
|
|
167
|
+
export declare function aurora(options?: {
|
|
168
|
+
duration?: number; colors?: string[]; bands?: number; lat?: number;
|
|
169
|
+
}): GlobeEffect;
|
|
170
|
+
|
|
171
|
+
export declare function jellySquash(options?: {
|
|
172
|
+
duration?: number; amount?: number;
|
|
173
|
+
}): GlobeEffect;
|
|
174
|
+
|
|
175
|
+
export declare function dataDesk(options?: {
|
|
176
|
+
title?: string; standfirst?: string; source?: string; accent?: string;
|
|
177
|
+
}): GlobeEffect;
|
|
178
|
+
|
|
179
|
+
export declare function counterRoll(options?: {
|
|
180
|
+
to?: number; from?: number; duration?: number; hold?: number; caption?: string;
|
|
181
|
+
format?: (value: number) => string; size?: number; color?: string;
|
|
182
|
+
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
183
|
+
}): GlobeEffect;
|
|
184
|
+
|
|
185
|
+
export declare function shockwave(options?: {
|
|
186
|
+
at?: Coordinate; duration?: number; hold?: number; color?: string; reach?: number; rings?: number;
|
|
187
|
+
}): GlobeEffect;
|
|
188
|
+
|
|
189
|
+
export declare function choroplethCascade(options?: {
|
|
190
|
+
values?: Record<string, number>; duration?: number; hold?: number; hue?: number;
|
|
191
|
+
}): GlobeEffect;
|
|
192
|
+
|
|
193
|
+
export declare function routeDashes(options?: {
|
|
194
|
+
routes?: { from: Coordinate; to: Coordinate }[];
|
|
195
|
+
duration?: number; hold?: number; color?: string; icon?: string; steps?: number;
|
|
196
|
+
}): GlobeEffect;
|
|
197
|
+
|
|
198
|
+
export declare function tally(options?: {
|
|
199
|
+
caption?: string; duration?: number; hold?: number; accent?: string;
|
|
200
|
+
}): GlobeEffect;
|
|
201
|
+
|
|
202
|
+
export declare function magneticMarkers(options?: {
|
|
203
|
+
reach?: number; pull?: number; color?: string;
|
|
204
|
+
}): GlobeEffect;
|
|
205
|
+
|
|
206
|
+
export declare function measureTool(options?: { color?: string; accent?: string }): GlobeEffect;
|
|
207
|
+
|
|
208
|
+
export declare function lassoSelect<M = unknown>(options?: {
|
|
209
|
+
drawMode?: boolean;
|
|
210
|
+
color?: string; accent?: string; caption?: string;
|
|
211
|
+
value?: (hits: M[]) => string;
|
|
212
|
+
onSelect?: (hits: M[]) => void;
|
|
213
|
+
}): GlobeEffect;
|
|
214
|
+
|
|
215
|
+
export declare function hoverLift(options?: { color?: string; scale?: number }): GlobeEffect;
|
|
216
|
+
|
|
217
|
+
export declare function pingProbe(options?: {
|
|
218
|
+
from?: Coordinate; color?: string; head?: string; duration?: number;
|
|
219
|
+
}): GlobeEffect;
|
|
220
|
+
|
|
221
|
+
export declare function parallaxTilt(options?: {
|
|
222
|
+
count?: number; depth?: number; seed?: number; camera?: number;
|
|
223
|
+
}): GlobeEffect;
|
|
224
|
+
|
|
225
|
+
export declare function cursorLight(options?: {
|
|
226
|
+
warmth?: number; darkness?: number; spec?: number;
|
|
227
|
+
}): GlobeEffect;
|
|
228
|
+
|
|
229
|
+
export declare function drillDown(options?: {
|
|
230
|
+
padding?: number;
|
|
231
|
+
color?: string;
|
|
232
|
+
onEnter?: (shape: CountryShape, globe: GeoGlobe) => void;
|
|
233
|
+
onExit?: (globe: GeoGlobe) => void;
|
|
234
|
+
}): GlobeEffect;
|
|
235
|
+
|
|
236
|
+
export declare function radialMenu(options?: {
|
|
237
|
+
items?: string[];
|
|
238
|
+
radius?: number;
|
|
239
|
+
color?: string;
|
|
240
|
+
onPick?: (item: string, at: [number, number] | null, globe: GeoGlobe) => void;
|
|
241
|
+
}): GlobeEffect;
|
|
242
|
+
|
|
243
|
+
export declare function spinToWin<M = unknown>(options?: {
|
|
244
|
+
color?: string;
|
|
245
|
+
caption?: string;
|
|
246
|
+
duration?: number;
|
|
247
|
+
turns?: number;
|
|
248
|
+
onLand?: (marker: M, globe: GeoGlobe) => void;
|
|
249
|
+
}): GlobeEffect;
|
|
250
|
+
|
|
251
|
+
export declare function serviceRadius(options?: {
|
|
252
|
+
km?: number; color?: string; caption?: string; at?: Coordinate;
|
|
253
|
+
}): GlobeEffect;
|
|
254
|
+
|
|
255
|
+
export declare function timezoneOverlap(options?: {
|
|
256
|
+
color?: string; warn?: string; dayStart?: number; dayEnd?: number;
|
|
257
|
+
}): GlobeEffect;
|
|
258
|
+
|
|
259
|
+
export declare function compareCountries(options?: {
|
|
260
|
+
color?: string;
|
|
261
|
+
accent?: string;
|
|
262
|
+
metric?: string;
|
|
263
|
+
values?: Record<string, number>;
|
|
264
|
+
}): GlobeEffect;
|
|
265
|
+
|
|
266
|
+
export declare function geoQuiz(options?: {
|
|
267
|
+
pool?: string[];
|
|
268
|
+
color?: string;
|
|
269
|
+
wrong?: string;
|
|
270
|
+
rounds?: number;
|
|
271
|
+
onAnswer?: (correct: boolean, shape: CountryShape, globe: GeoGlobe) => void;
|
|
272
|
+
}): GlobeEffect;
|
|
273
|
+
|
|
274
|
+
/* -------------------------------- runtime -------------------------------- */
|
|
275
|
+
|
|
276
|
+
export declare const TAU: number;
|
|
277
|
+
export declare function linear(t: number): number;
|
|
278
|
+
export declare function easeIn(t: number): number;
|
|
279
|
+
export declare function easeOut(t: number): number;
|
|
280
|
+
export declare function easeInOut(t: number): number;
|
|
281
|
+
export declare function backOut(t: number): number;
|
|
282
|
+
export declare function pingPong(t: number): number;
|
|
283
|
+
export declare function clamp01(t: number): number;
|
|
284
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
285
|
+
export declare function stagger(t: number, index: number, count: number, overlap?: number): number;
|
|
286
|
+
|
|
287
|
+
/** Deterministic RNG - effects must not call Math.random() per frame. */
|
|
288
|
+
export declare function rng(seed?: number): () => number;
|
|
289
|
+
export declare function particles<T>(count: number, seed: number, make: (random: () => number, i: number) => T): T[];
|
|
290
|
+
|
|
291
|
+
export declare function scratch(globe: GeoGlobe, key?: string): { canvas: HTMLCanvasElement; ctx: CanvasRenderingContext2D } | null;
|
|
292
|
+
export declare function releaseScratch(globe: GeoGlobe, key?: string): void;
|
|
293
|
+
|
|
294
|
+
export declare function destination(lon: number, lat: number, bearing: number, degrees: number): [number, number];
|
|
295
|
+
export declare function ring(lon: number, lat: number, degrees: number, steps?: number): [number, number][];
|
|
296
|
+
export declare function drawPath(ctx: CanvasRenderingContext2D, globe: GeoGlobe, points: [number, number][], close?: boolean): void;
|
|
297
|
+
export declare function centroid(shape: CountryShape | { coordinates: unknown }): [number, number];
|
|
298
|
+
|
|
299
|
+
export declare function panel(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, options?: { fill?: string; stroke?: string; radius?: number }): void;
|
|
300
|
+
export declare function label(ctx: CanvasRenderingContext2D, text: string, x: number, y: number, options?: { size?: number; weight?: number; color?: string; align?: CanvasTextAlign; font?: string }): void;
|
|
301
|
+
export declare function readout(ctx: CanvasRenderingContext2D, x: number, y: number, caption: string, value: string, options?: { accent?: string; width?: number }): void;
|
|
302
|
+
export declare function bar(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, fraction: number, options?: { fill?: string; track?: string; radius?: number }): void;
|
|
303
|
+
|
|
304
|
+
/* -------------------------------- pointer -------------------------------- */
|
|
305
|
+
|
|
306
|
+
export declare function onTap(globe: GeoGlobe, handler: (point: { x: number; y: number }, at: [number, number] | null, event: PointerEvent) => void, slop?: number): () => void;
|
|
307
|
+
export declare function onDragPath(globe: GeoGlobe, handlers: {
|
|
308
|
+
start?: (path: { x: number; y: number }[]) => void;
|
|
309
|
+
move?: (path: { x: number; y: number }[]) => void;
|
|
310
|
+
end?: (path: { x: number; y: number }[]) => void;
|
|
311
|
+
}, enabled?: () => boolean): () => void;
|
|
312
|
+
export declare function nearest<T extends Coordinate>(globe: GeoGlobe, items: T[], x: number, y: number, radius?: number): T | null;
|
|
313
|
+
export declare function pointInPath(x: number, y: number, path: { x: number; y: number }[]): boolean;
|
package/types/index.d.ts
CHANGED
|
@@ -506,6 +506,32 @@ export interface GeoGlobeOptions {
|
|
|
506
506
|
onCountryHover?: (country: CountryShape | null, position: { x: number; y: number } | null) => void;
|
|
507
507
|
onCountryClick?: (country: CountryShape, position: { x: number; y: number }) => void;
|
|
508
508
|
onRender?: (instance: GeoGlobe) => void;
|
|
509
|
+
/** Effects installed when the globe is created. */
|
|
510
|
+
effects?: GlobeEffect[];
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** Where an effect paints relative to the globe itself. */
|
|
514
|
+
export type EffectStage = "beneath" | "above" | "post";
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* An effect derives its whole appearance from `t` (0→1), which is why
|
|
518
|
+
* `renderFrame()` can reproduce any frame exactly.
|
|
519
|
+
*/
|
|
520
|
+
export interface GlobeEffect<S = any> {
|
|
521
|
+
name?: string;
|
|
522
|
+
/** Default "above". */
|
|
523
|
+
stage?: EffectStage;
|
|
524
|
+
/** Paint order within a stage. Lower paints first. Default 0. */
|
|
525
|
+
z?: number;
|
|
526
|
+
/** Milliseconds for one cycle. Default 1000. */
|
|
527
|
+
duration?: number;
|
|
528
|
+
/** Milliseconds held at the end before looping. Default 0. */
|
|
529
|
+
hold?: number;
|
|
530
|
+
/** Default true. */
|
|
531
|
+
loop?: boolean;
|
|
532
|
+
setup?(globe: GeoGlobe): S;
|
|
533
|
+
frame(ctx: CanvasRenderingContext2D, globe: GeoGlobe, t: number, state: S): void;
|
|
534
|
+
dispose?(state: S, globe: GeoGlobe): void;
|
|
509
535
|
}
|
|
510
536
|
|
|
511
537
|
export interface FlyToOptions {
|
|
@@ -593,6 +619,28 @@ export declare class GeoGlobe {
|
|
|
593
619
|
countryAt(x: number, y: number): CountryShape | null;
|
|
594
620
|
/** Marks the next frame as needing a redraw. */
|
|
595
621
|
invalidate(): this;
|
|
622
|
+
|
|
623
|
+
/** Pointer position in canvas pixels and the coordinate beneath it. */
|
|
624
|
+
readonly pointer: { x: number; y: number; lon: number; lat: number; over: boolean };
|
|
625
|
+
/** Effects currently installed, in paint order. */
|
|
626
|
+
readonly effects: GlobeEffect[];
|
|
627
|
+
use(effect: GlobeEffect): this;
|
|
628
|
+
remove(effect: GlobeEffect | string): this;
|
|
629
|
+
clearEffects(): this;
|
|
630
|
+
/** Pins the effect clock so a frame can be reproduced. */
|
|
631
|
+
seek(ms: number): this;
|
|
632
|
+
/** Releases the clock back to wall time. */
|
|
633
|
+
play(): this;
|
|
634
|
+
/** Draws the frame belonging at `ms` on the effect clock. */
|
|
635
|
+
renderFrame(ms: number): this;
|
|
636
|
+
/** Traces a country outline into a path using the current projection. */
|
|
637
|
+
tracePath(
|
|
638
|
+
shape: CountryShape | { coordinates: unknown },
|
|
639
|
+
ctx?: CanvasRenderingContext2D,
|
|
640
|
+
transform?: (coord: [number, number]) => [number, number],
|
|
641
|
+
): this;
|
|
642
|
+
/** Land sample points as `[lon, lat]` pairs. */
|
|
643
|
+
landPoints(spacing?: number): [number, number][];
|
|
596
644
|
resize(): this;
|
|
597
645
|
render(): this;
|
|
598
646
|
snapshot(type?: string, quality?: number): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** A place from the bundled Natural Earth table. */
|
|
2
|
+
export interface Place {
|
|
3
|
+
name: string;
|
|
4
|
+
/** Accent-folded, lowercase name used for matching. */
|
|
5
|
+
key: string;
|
|
6
|
+
lon: number;
|
|
7
|
+
lat: number;
|
|
8
|
+
/** ISO 3166-1 alpha-2 country code. */
|
|
9
|
+
country: string;
|
|
10
|
+
/** Admin-1 name, present only where it disambiguates a repeated name. */
|
|
11
|
+
region: string;
|
|
12
|
+
population: number;
|
|
13
|
+
/** `"Springfield, Illinois, US"` - ready to show in a results list. */
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Lowercases and strips accents, so "São Paulo" answers to "sao paulo". */
|
|
18
|
+
export declare function fold(value: string): string;
|
|
19
|
+
|
|
20
|
+
/** Places matching `query`, prefix matches first, then by population. */
|
|
21
|
+
export declare function searchPlaces(
|
|
22
|
+
query: string,
|
|
23
|
+
options?: {
|
|
24
|
+
limit?: number;
|
|
25
|
+
country?: string;
|
|
26
|
+
/** Also match names that contain the query, not just start with it. */
|
|
27
|
+
contains?: boolean;
|
|
28
|
+
}
|
|
29
|
+
): Place[];
|
|
30
|
+
|
|
31
|
+
/** Coordinate for an exact-ish name, matching the shape of `geocode()`. */
|
|
32
|
+
export declare function placePoint(
|
|
33
|
+
name: string,
|
|
34
|
+
options?: { country?: string }
|
|
35
|
+
): { lon: number; lat: number } | null;
|
|
36
|
+
|
|
37
|
+
/** Ready-made resolver for `searchAndFly({ source })`. */
|
|
38
|
+
export declare function placeSource(
|
|
39
|
+
options?: { limit?: number; country?: string; contains?: boolean }
|
|
40
|
+
): (query: string) => Place[];
|
|
41
|
+
|
|
42
|
+
/** How many places the bundled table holds. */
|
|
43
|
+
export declare function placeCount(): number;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { GeoGlobe, GlobeOptions, Coordinate } from "./index";
|
|
2
|
+
import type { GlobeEffect } from "./fx";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A complete look: options, effects, and optionally a call into the
|
|
6
|
+
* imperative API. Plain data, so it can be read and pulled apart.
|
|
7
|
+
*/
|
|
8
|
+
export interface GlobeRecipe {
|
|
9
|
+
name: string;
|
|
10
|
+
options?: Partial<GlobeOptions>;
|
|
11
|
+
effects?: GlobeEffect[];
|
|
12
|
+
/** Runs after the options and effects are applied. Returns a teardown. */
|
|
13
|
+
start?: (globe: GeoGlobe) => (() => void) | void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Applies a recipe and returns a function that undoes it. */
|
|
17
|
+
export declare function applyRecipe(globe: GeoGlobe, recipe: GlobeRecipe): () => void;
|
|
18
|
+
|
|
19
|
+
export declare function devPlatformGlobe(options?: {
|
|
20
|
+
hub?: Coordinate;
|
|
21
|
+
spokes?: number;
|
|
22
|
+
}): GlobeRecipe;
|
|
23
|
+
|
|
24
|
+
export declare function keynoteGlobe(options?: {
|
|
25
|
+
hub?: Coordinate;
|
|
26
|
+
countries?: number;
|
|
27
|
+
caption?: string;
|
|
28
|
+
}): GlobeRecipe;
|
|
29
|
+
|
|
30
|
+
export declare function satelliteOrbits(options?: {
|
|
31
|
+
count?: number;
|
|
32
|
+
preset?: string;
|
|
33
|
+
rotateSpeed?: number;
|
|
34
|
+
}): GlobeRecipe;
|
|
35
|
+
|
|
36
|
+
export declare function growthOverTime(options?: {
|
|
37
|
+
duration?: number;
|
|
38
|
+
loop?: boolean;
|
|
39
|
+
preset?: string;
|
|
40
|
+
}): GlobeRecipe;
|
|
41
|
+
|
|
42
|
+
export declare function celebrationBurst(options?: {
|
|
43
|
+
at?: Coordinate;
|
|
44
|
+
label?: string;
|
|
45
|
+
emoji?: string;
|
|
46
|
+
every?: number;
|
|
47
|
+
burst?: number;
|
|
48
|
+
}): GlobeRecipe;
|
|
49
|
+
|
|
50
|
+
export declare function cityTour(options?: {
|
|
51
|
+
stops?: Coordinate[];
|
|
52
|
+
dwell?: number;
|
|
53
|
+
zoom?: number;
|
|
54
|
+
}): GlobeRecipe;
|