kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
146 lines (145 loc) • 4.22 kB
TypeScript
import datasetSchema from './dataset-schema';
import mapStyleSchema from './map-style-schema';
import mapStateSchema from './map-state-schema';
import { SavedDatasetV1, ParsedDataset } from './dataset-schema';
import { visStateSchema } from './vis-state-schema';
import { VERSIONS } from './versions';
import { MapInfo, SavedVisState, SavedMapStyle, ParsedConfig, BaseMapStyle } from '@kepler.gl/types';
export declare type SavedMapState = {
bearing: number;
dragRotate: boolean;
latitude: number;
longitude: number;
pitch: number;
zoom: number;
isSplit: boolean;
isViewportSynced?: true;
isZoomLocked?: false;
splitMapViewports?: [];
};
export declare type SavedLayerGroups = {
[key: string]: boolean;
};
export declare type SavedCustomMapStyle = {
[key: string]: {
accessToken?: string;
custom: BaseMapStyle['custom'];
icon: string;
id: string;
label: string;
url: string;
};
};
/** Schema for v1 saved configuration */
export declare type SavedConfigV1 = {
version: 'v1';
config: {
visState: SavedVisState;
mapState: SavedMapState;
mapStyle: SavedMapStyle;
};
};
export declare type SavedMap = {
datasets: SavedDatasetV1[];
config: SavedConfigV1;
info: {
app: string;
created_at: string;
title: string;
description: string;
};
};
export declare type LoadedMap = {
datasets?: ParsedDataset[] | null;
config?: ParsedConfig | null;
};
export declare const reducerSchema: {
[key: string]: typeof mapStateSchema | typeof visStateSchema | typeof mapStyleSchema;
};
export declare class KeplerGLSchema {
_validVersions: typeof VERSIONS;
_version: 'v1';
_reducerSchemas: typeof reducerSchema;
_datasetSchema: typeof datasetSchema;
_datasetLastSaved: SavedDatasetV1[] | null;
_savedDataset: SavedDatasetV1[] | null;
constructor({ reducers, datasets, validVersions, version }?: {
reducers?: typeof reducerSchema;
datasets?: typeof datasetSchema;
validVersions?: typeof VERSIONS;
version?: 'v1';
});
/**
* stateToSave = {
* datasets: [
* {
* version: 'v0',
* data: {id, label, color, allData, fields}
* },
* {
* version: 'v0',
* data: {id, label, color, allData, fields}
* }
* ],
* config: {
* version: 'v0',
* config: {}
* },
* info: {
* app: 'kepler.gl',
* create_at: 'Mon May 28 2018 21:04:46 GMT-0700 (PDT)'
* }
* }
*
* Get config and data of current map to save
* @param state
* @returns app state to save
*/
save(state: any): SavedMap;
getMapInfo(state: any): MapInfo;
/**
* Load saved map, argument can be (datasets, config) or ({datasets, config})
* @param savedDatasets
* @param savedConfig
*/
load(savedDatasets: SavedMap | SavedMap['datasets'] | any, savedConfig: SavedMap['config'] | any): LoadedMap;
/**
* Get data to save
* @param state - app state
* @returns - dataset to save
*/
getDatasetToSave(state: any): SavedDatasetV1[];
/**
* Get App config to save
* @param {Object} state - app state
* @returns {{version: String, config: Object}} - config to save
*/
getConfigToSave(state: any): SavedConfigV1;
/**
* Parse saved data
* @param datasets
* @returns - dataset to pass to addDataToMap
*/
parseSavedData(datasets: any): ParsedDataset[] | null;
/**
* Parse saved App config
*/
parseSavedConfig({ version, config }: {
version: any;
config: any;
}, state?: {}): ParsedConfig | null;
/**
* Validate version
* @param version
* @returns validVersion
*/
validateVersion(version: any): string | null;
/**
* Check if data has changed since last save
* @param state
* @returns - whether data has changed or not
*/
hasDataChanged(state: any): boolean;
}
declare const KeplerGLSchemaManager: KeplerGLSchema;
export default KeplerGLSchemaManager;