react-globe.gl 2.18.11
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/LICENSE +21 -0
- package/README.md +310 -0
- package/dist/react-globe.gl.common.js +174 -0
- package/dist/react-globe.gl.d.ts +241 -0
- package/dist/react-globe.gl.js +79238 -0
- package/dist/react-globe.gl.js.map +1 -0
- package/dist/react-globe.gl.min.js +20 -0
- package/dist/react-globe.gl.module.js +166 -0
- package/package.json +65 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Material, Object3D, Scene, Camera, WebGLRenderer } from 'three';
|
|
3
|
+
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
4
|
+
import { ConfigOptions, GlobeInstance } from 'globe.gl';
|
|
5
|
+
|
|
6
|
+
type Accessor<In, Out> = Out | string | ((obj: In) => Out);
|
|
7
|
+
type ObjAccessor<T> = Accessor<object, T>;
|
|
8
|
+
type HexBinAccessor<T> = Accessor<HexBin, T>;
|
|
9
|
+
|
|
10
|
+
interface HexBin {
|
|
11
|
+
points: object[],
|
|
12
|
+
sumWeight: number,
|
|
13
|
+
center: { lat: number, lng: number }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface GeoJsonGeometry {
|
|
17
|
+
type: string;
|
|
18
|
+
coordinates: number[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface TypeFace {}
|
|
22
|
+
|
|
23
|
+
type LabelOrientation = 'right' | 'top' | 'bottom';
|
|
24
|
+
|
|
25
|
+
interface GeoCoords {
|
|
26
|
+
lat: number;
|
|
27
|
+
lng: number;
|
|
28
|
+
altitude: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface CartesianCoords {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
z: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ScreenCoords {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface GlobeProps extends ConfigOptions {
|
|
43
|
+
// Container layout
|
|
44
|
+
width?: number;
|
|
45
|
+
height?: number;
|
|
46
|
+
backgroundColor?: string;
|
|
47
|
+
backgroundImageUrl?: string | null;
|
|
48
|
+
|
|
49
|
+
// Globe layer
|
|
50
|
+
globeImageUrl?: string | null;
|
|
51
|
+
bumpImageUrl?: string | null;
|
|
52
|
+
showGlobe?: boolean;
|
|
53
|
+
showGraticules?: boolean;
|
|
54
|
+
showAtmosphere?: boolean;
|
|
55
|
+
atmosphereColor?: string;
|
|
56
|
+
atmosphereAltitude?: number;
|
|
57
|
+
globeMaterial?: Material;
|
|
58
|
+
onGlobeReady?: () => void;
|
|
59
|
+
onGlobeClick?: (coords: { lat, lng }, event: MouseEvent) => void;
|
|
60
|
+
onGlobeRightClick?: (coords: { lat, lng }, event: MouseEvent) => void;
|
|
61
|
+
|
|
62
|
+
// Points layer
|
|
63
|
+
pointsData?: object[];
|
|
64
|
+
pointLat?: ObjAccessor<number>;
|
|
65
|
+
pointLng?: ObjAccessor<number>;
|
|
66
|
+
pointColor?: ObjAccessor<string>;
|
|
67
|
+
pointAltitude?: ObjAccessor<number>;
|
|
68
|
+
pointRadius?: ObjAccessor<number>;
|
|
69
|
+
pointResolution?: number;
|
|
70
|
+
pointsMerge?: boolean;
|
|
71
|
+
pointsTransitionDuration?: number;
|
|
72
|
+
pointLabel?: ObjAccessor<string>;
|
|
73
|
+
onPointClick?: (point: object, event: MouseEvent) => void;
|
|
74
|
+
onPointRightClick?: (point: object, event: MouseEvent) => void;
|
|
75
|
+
onPointHover?: (point: object | null, prevPoint: object | null) => void;
|
|
76
|
+
|
|
77
|
+
// Arcs layer
|
|
78
|
+
arcsData?: object[];
|
|
79
|
+
arcStartLat?: ObjAccessor<number>;
|
|
80
|
+
arcStartLng?: ObjAccessor<number>;
|
|
81
|
+
arcEndLat?: ObjAccessor<number>;
|
|
82
|
+
arcEndLng?: ObjAccessor<number>;
|
|
83
|
+
arcColor?: ObjAccessor<string | string[]>;
|
|
84
|
+
arcAltitude?: ObjAccessor<number | null>;
|
|
85
|
+
arcAltitudeAutoScale?: ObjAccessor<number>;
|
|
86
|
+
arcStroke?: ObjAccessor<number | null>;
|
|
87
|
+
arcCurveResolution?: number;
|
|
88
|
+
arcCircularResolution?: number;
|
|
89
|
+
arcDashLength?: ObjAccessor<number>;
|
|
90
|
+
arcDashGap?: ObjAccessor<number>;
|
|
91
|
+
arcDashInitialGap?: ObjAccessor<number>;
|
|
92
|
+
arcDashAnimateTime?: ObjAccessor<number>;
|
|
93
|
+
arcsTransitionDuration?: number;
|
|
94
|
+
arcLabel?: ObjAccessor<string>;
|
|
95
|
+
onArcClick?: (arc: object, event: MouseEvent) => void;
|
|
96
|
+
onArcRightClick?: (arc: object, event: MouseEvent) => void;
|
|
97
|
+
onArcHover?: (arc: object | null, prevArc: object | null) => void;
|
|
98
|
+
|
|
99
|
+
// Polygons layer
|
|
100
|
+
polygonsData?: object[];
|
|
101
|
+
polygonGeoJsonGeometry?: ObjAccessor<GeoJsonGeometry>;
|
|
102
|
+
polygonCapColor?: ObjAccessor<string>;
|
|
103
|
+
polygonCapMaterial?: ObjAccessor<Material>;
|
|
104
|
+
polygonSideColor?: ObjAccessor<string>;
|
|
105
|
+
polygonSideMaterial?: ObjAccessor<Material>;
|
|
106
|
+
polygonStrokeColor?: ObjAccessor<string | boolean | null>;
|
|
107
|
+
polygonAltitude?: ObjAccessor<number>;
|
|
108
|
+
polygonCapCurvatureResolution?: ObjAccessor<number>;
|
|
109
|
+
polygonsTransitionDuration?: number;
|
|
110
|
+
polygonLabel?: ObjAccessor<string>;
|
|
111
|
+
onPolygonClick?: (polygon: object, event: MouseEvent) => void;
|
|
112
|
+
onPolygonRightClick?: (polygon: object, event: MouseEvent) => void;
|
|
113
|
+
onPolygonHover?: (polygon: object | null, prevPolygon: object | null) => void;
|
|
114
|
+
|
|
115
|
+
// Paths layer
|
|
116
|
+
pathsData?: object[];
|
|
117
|
+
pathPoints?: ObjAccessor<any[]>;
|
|
118
|
+
pathPointLat?: Accessor<any, number>;
|
|
119
|
+
pathPointLng?: Accessor<any, number>;
|
|
120
|
+
pathPointAlt?: Accessor<any, number>;
|
|
121
|
+
pathResolution?: number;
|
|
122
|
+
pathColor?: ObjAccessor<string | string[]>;
|
|
123
|
+
pathStroke?: ObjAccessor<number | null>;
|
|
124
|
+
pathDashLength?: ObjAccessor<number>;
|
|
125
|
+
pathDashGap?: ObjAccessor<number>;
|
|
126
|
+
pathDashInitialGap?: ObjAccessor<number>;
|
|
127
|
+
pathDashAnimateTime?: ObjAccessor<number>;
|
|
128
|
+
pathTransitionDuration?: number;
|
|
129
|
+
pathLabel?: ObjAccessor<string>;
|
|
130
|
+
onPathClick?: (path: object, event: MouseEvent) => void;
|
|
131
|
+
onPathRightClick?: (path: object, event: MouseEvent) => void;
|
|
132
|
+
onPathHover?: (path: object | null, prevPath: object | null) => void;
|
|
133
|
+
|
|
134
|
+
// Hex Bin layer
|
|
135
|
+
hexBinPointsData?: object[];
|
|
136
|
+
hexBinPointLat?: ObjAccessor<number>;
|
|
137
|
+
hexBinPointLng?: ObjAccessor<number>;
|
|
138
|
+
hexBinPointWeight?: ObjAccessor<number>;
|
|
139
|
+
hexBinResolution?: number;
|
|
140
|
+
hexMargin?: HexBinAccessor<number>;
|
|
141
|
+
hexAltitude?: HexBinAccessor<number>;
|
|
142
|
+
hexTopCurvatureResolution?: number;
|
|
143
|
+
hexTopColor?: HexBinAccessor<string>;
|
|
144
|
+
hexSideColor?: HexBinAccessor<string>;
|
|
145
|
+
hexBinMerge?: boolean;
|
|
146
|
+
hexTransitionDuration?: number;
|
|
147
|
+
hexLabel?: HexBinAccessor<string>;
|
|
148
|
+
onHexClick?: (hex: HexBin, event: MouseEvent) => void;
|
|
149
|
+
onHexRightClick?: (hex: HexBin, event: MouseEvent) => void;
|
|
150
|
+
onHexHover?: (hex: HexBin | null, prevHex: HexBin | null) => void;
|
|
151
|
+
|
|
152
|
+
// Hexed Polygons layer
|
|
153
|
+
hexPolygonsData?: object[];
|
|
154
|
+
hexPolygonGeoJsonGeometry?: ObjAccessor<GeoJsonGeometry>;
|
|
155
|
+
hexPolygonColor?: ObjAccessor<string>;
|
|
156
|
+
hexPolygonAltitude?: ObjAccessor<number>;
|
|
157
|
+
hexPolygonResolution?: ObjAccessor<number>;
|
|
158
|
+
hexPolygonMargin?: ObjAccessor<number>;
|
|
159
|
+
hexPolygonCurvatureResolution?: ObjAccessor<number>;
|
|
160
|
+
hexPolygonsTransitionDuration?: number;
|
|
161
|
+
hexPolygonLabel?: ObjAccessor<string>;
|
|
162
|
+
onHexPolygonClick?: (polygon: object, event: MouseEvent) => void;
|
|
163
|
+
onHexPolygonRightClick?: (polygon: object, event: MouseEvent) => void;
|
|
164
|
+
onHexPolygonHover?: (polygon: object | null, prevPolygon: object | null) => void;
|
|
165
|
+
|
|
166
|
+
// Tiles layer
|
|
167
|
+
tilesData?: object[];
|
|
168
|
+
tileLat?: ObjAccessor<number>;
|
|
169
|
+
tileLng?: ObjAccessor<number>;
|
|
170
|
+
tileAltitude?: ObjAccessor<number>;
|
|
171
|
+
tileWidth?: ObjAccessor<number>;
|
|
172
|
+
tileHeight?: ObjAccessor<number>;
|
|
173
|
+
tileUseGlobeProjection?: ObjAccessor<boolean>;
|
|
174
|
+
tileMaterial?: ObjAccessor<Material>;
|
|
175
|
+
tileCurvatureResolution?: ObjAccessor<number>;
|
|
176
|
+
tilesTransitionDuration?: number;
|
|
177
|
+
tileLabel?: ObjAccessor<string>;
|
|
178
|
+
onTileClick?: (tile: object, event: MouseEvent) => void;
|
|
179
|
+
onTileRightClick?: (tile: object, event: MouseEvent) => void;
|
|
180
|
+
onTileHover?: (tile: object | null, prevTile: object | null) => void;
|
|
181
|
+
|
|
182
|
+
// Labels layer
|
|
183
|
+
labelsData?: object[];
|
|
184
|
+
labelLat?: ObjAccessor<number>;
|
|
185
|
+
labelLng?: ObjAccessor<number>;
|
|
186
|
+
labelText?: ObjAccessor<string>;
|
|
187
|
+
labelColor?: ObjAccessor<string>;
|
|
188
|
+
labelAltitude?: ObjAccessor<number>;
|
|
189
|
+
labelSize?: ObjAccessor<number>;
|
|
190
|
+
labelTypeFace?: TypeFace;
|
|
191
|
+
labelRotation?: ObjAccessor<number>;
|
|
192
|
+
labelResolution?: number;
|
|
193
|
+
labelIncludeDot?: ObjAccessor<boolean>;
|
|
194
|
+
labelDotRadius?: ObjAccessor<number>;
|
|
195
|
+
labelDotOrientation?: ObjAccessor<LabelOrientation>;
|
|
196
|
+
labelsTransitionDuration?: number;
|
|
197
|
+
labelLabel?: ObjAccessor<string>;
|
|
198
|
+
onLabelClick?: (label: object, event: MouseEvent) => void;
|
|
199
|
+
onLabelRightClick?: (label: object, event: MouseEvent) => void;
|
|
200
|
+
onLabelHover?: (label: object | null, prevLabel: object | null) => void;
|
|
201
|
+
|
|
202
|
+
// Custom layer
|
|
203
|
+
customLayerData?: object[];
|
|
204
|
+
customThreeObject?: Object3D | string | ((d: object, globeRadius: number) => Object3D);
|
|
205
|
+
customThreeObjectUpdate?: string | ((obj: Object3D, objData: object, globeRadius: number) => void);
|
|
206
|
+
customLayerLabel?: ObjAccessor<string>;
|
|
207
|
+
onCustomLayerClick?: (obj: object, event: MouseEvent) => void;
|
|
208
|
+
onCustomLayerRightClick?: (obj: object, event: MouseEvent) => void;
|
|
209
|
+
onCustomLayerHover?: (obj: object | null, prevObj: object | null) => void;
|
|
210
|
+
|
|
211
|
+
// Render control
|
|
212
|
+
enablePointerInteraction?: boolean;
|
|
213
|
+
pointerEventsFilter?: (object: Object3D, data?: object) => boolean;
|
|
214
|
+
lineHoverPrecision?: number;
|
|
215
|
+
onZoom?: (pov: GeoCoords) => void;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
interface GlobeMethods {
|
|
219
|
+
// Render control
|
|
220
|
+
pointOfView(): GeoCoords;
|
|
221
|
+
pointOfView(pov: { lat?: number, lng?: number, altitude?: number }, transitionMs?: number): GlobeInstance;
|
|
222
|
+
pauseAnimation(): GlobeInstance;
|
|
223
|
+
resumeAnimation(): GlobeInstance;
|
|
224
|
+
scene(): Scene;
|
|
225
|
+
camera(): Camera;
|
|
226
|
+
renderer(): WebGLRenderer;
|
|
227
|
+
postProcessingComposer(): EffectComposer;
|
|
228
|
+
controls(): object;
|
|
229
|
+
|
|
230
|
+
// Utilities
|
|
231
|
+
getCoords(lat: number, lng: number, altitude?: number): CartesianCoords;
|
|
232
|
+
getScreenCoords(lat: number, lng: number, altitude?: number): ScreenCoords;
|
|
233
|
+
toGeoCoords(coords: CartesianCoords): GeoCoords;
|
|
234
|
+
toGlobeCoords(x: number, y: number): { lat: number, lng: number} | null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
type FCwithRef<P = {}, R = {}> = React.FunctionComponent<P & { ref?: React.MutableRefObject<R | undefined> }>;
|
|
238
|
+
|
|
239
|
+
declare const Globe: FCwithRef<GlobeProps, GlobeMethods>;
|
|
240
|
+
|
|
241
|
+
export { GlobeMethods, GlobeProps, Globe as default };
|