Saving and Loading Maps with Schema Manager
Last updated
Was this helpful?
Was this helpful?
import KeplerGlSchema from '@kepler.gl/schemas';
const mapToSave = KeplerGlSchema.save(state.keplerGl.foo);
// mapToSave = {datasets: [], config: {}, info: {}};
const dataToSave = KeplerGlSchema.getDatasetToSave(state.keplerGl.foo);
// dataToSave = [{version: '', data: {id, label, color, allData, fields}}]
const configToSave = KeplerGlSchema.getConfigToSave(state.keplerGl.foo);
// configToSave = {version: '', config: {}}import KeplerGlSchema from '@kepler.gl/schemas';
import {addDataToMap} from '@kepler.gl/actions';
const mapToLoad = KeplerGlSchema.load(savedDatasets, savedConfig);
// mapToLoad = {datasets: [], config: {}};
this.props.dispatch(addDataToMap(mapToLoad));import KeplerGlSchema from '@kepler.gl/schemas';
import {addDataToMap} from '@kepler.gl/actions';
// save current map data and config
const {datasets, config} = KeplerGlSchema.save(state.keplerGl.foo);
// mapToLoad = {datasets: [], config: {}};
// receive some new data
const newData = someNewData;
// newData = [{rows, fields}]
// match id with old datasets
const newDatasets = newData.map((d, i) => ({
version: datasets[i].version,
data: {
...datasets[i].data,
allData: d.rows,
fields: d.fields
}
}));
// load config with new datasets
const mapToLoad = KeplerGlSchema.load(newDatasets, config);
this.props.dispatch(addDataToMap(mapToLoad));